Skip to content

Commit fb2c959

Browse files
committed
Refactor mpp_retry[_overpay] tests to use SendEvent::from_event
.. as a follow-up from #2417.
1 parent 39c5bbc commit fb2c959

File tree

1 file changed

+6
-32
lines changed

1 file changed

+6
-32
lines changed

lightning/src/ln/payment_tests.rs

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -114,19 +114,9 @@ fn mpp_retry() {
114114

115115
// Add the HTLC along the first hop.
116116
let fail_path_msgs_1 = remove_first_msg_event_to_node(&nodes[2].node.get_our_node_id(), &mut events);
117-
let (update_add, commitment_signed) = match fail_path_msgs_1 {
118-
MessageSendEvent::UpdateHTLCs { node_id: _, updates: msgs::CommitmentUpdate { ref update_add_htlcs, ref update_fulfill_htlcs, ref update_fail_htlcs, ref update_fail_malformed_htlcs, ref update_fee, ref commitment_signed } } => {
119-
assert_eq!(update_add_htlcs.len(), 1);
120-
assert!(update_fail_htlcs.is_empty());
121-
assert!(update_fulfill_htlcs.is_empty());
122-
assert!(update_fail_malformed_htlcs.is_empty());
123-
assert!(update_fee.is_none());
124-
(update_add_htlcs[0].clone(), commitment_signed.clone())
125-
},
126-
_ => panic!("Unexpected event"),
127-
};
128-
nodes[2].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &update_add);
129-
commitment_signed_dance!(nodes[2], nodes[0], commitment_signed, false);
117+
let send_event = SendEvent::from_event(fail_path_msgs_1);
118+
nodes[2].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &send_event.msgs[0]);
119+
commitment_signed_dance!(nodes[2], nodes[0], &send_event.commitment_msg, false);
130120

131121
// Attempt to forward the payment and complete the 2nd path's failure.
132122
expect_pending_htlcs_forwardable!(&nodes[2]);
@@ -225,25 +215,9 @@ fn mpp_retry_overpay() {
225215

226216
// Add the HTLC along the first hop.
227217
let fail_path_msgs_1 = remove_first_msg_event_to_node(&nodes[2].node.get_our_node_id(), &mut events);
228-
let (update_add, commitment_signed) = match fail_path_msgs_1 {
229-
MessageSendEvent::UpdateHTLCs {
230-
node_id: _,
231-
updates: msgs::CommitmentUpdate {
232-
ref update_add_htlcs, ref update_fulfill_htlcs, ref update_fail_htlcs,
233-
ref update_fail_malformed_htlcs, ref update_fee, ref commitment_signed
234-
}
235-
} => {
236-
assert_eq!(update_add_htlcs.len(), 1);
237-
assert!(update_fail_htlcs.is_empty());
238-
assert!(update_fulfill_htlcs.is_empty());
239-
assert!(update_fail_malformed_htlcs.is_empty());
240-
assert!(update_fee.is_none());
241-
(update_add_htlcs[0].clone(), commitment_signed.clone())
242-
},
243-
_ => panic!("Unexpected event"),
244-
};
245-
nodes[2].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &update_add);
246-
commitment_signed_dance!(nodes[2], nodes[0], commitment_signed, false);
218+
let send_event = SendEvent::from_event(fail_path_msgs_1);
219+
nodes[2].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &send_event.msgs[0]);
220+
commitment_signed_dance!(nodes[2], nodes[0], &send_event.commitment_msg, false);
247221

248222
// Attempt to forward the payment and complete the 2nd path's failure.
249223
expect_pending_htlcs_forwardable!(&nodes[2]);

0 commit comments

Comments
 (0)