Skip to content

Commit f989fb9

Browse files
committed
Resolving conflict
1 parent 8e3ab7c commit f989fb9

File tree

1 file changed

+25
-23
lines changed

1 file changed

+25
-23
lines changed

lightning/src/ln/blinded_payment_tests.rs

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ fn do_forward_fail_in_process_pending_htlc_fwds(check: ProcessPendingHTLCsCheck,
457457
(chan.0.contents, chan.2)
458458
};
459459

460+
let error_message = "Channel force-closed";
460461
let amt_msat = 5000;
461462
let (_, payment_hash, payment_secret) = get_payment_preimage_hash(&nodes[2], Some(amt_msat), None);
462463
let route_params = get_blinded_route_parameters(amt_msat, payment_secret, 1, 1_0000_0000,
@@ -470,34 +471,35 @@ fn do_forward_fail_in_process_pending_htlc_fwds(check: ProcessPendingHTLCsCheck,
470471
assert_eq!(events.len(), 1);
471472
let ev = remove_first_msg_event_to_node(&nodes[1].node.get_our_node_id(), &mut events);
472473
let mut payment_event = SendEvent::from_event(ev);
473-
let error_message = "Channel force-closed";
474474

475475
nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
476476
check_added_monitors!(nodes[1], 0);
477477
do_commitment_signed_dance(&nodes[1], &nodes[0], &payment_event.commitment_msg, false, false);
478478

479-
match check {
480-
ProcessPendingHTLCsCheck::FwdPeerDisconnected => {
481-
// Disconnect the next-hop peer so when we go to forward in process_pending_htlc_forwards, the
482-
// intro node will error backwards.
483-
nodes[1].node.peer_disconnected(&nodes[2].node.get_our_node_id());
484-
expect_pending_htlcs_forwardable!(nodes[1]);
485-
expect_pending_htlcs_forwardable_and_htlc_handling_failed_ignore!(nodes[1],
486-
vec![HTLCDestination::NextHopChannel { node_id: Some(nodes[2].node.get_our_node_id()), channel_id }]);
487-
},
488-
ProcessPendingHTLCsCheck::FwdChannelClosed => {
489-
// Force close the next-hop channel so when we go to forward in process_pending_htlc_forwards,
490-
// the intro node will error backwards.
491-
nodes[1].node.force_close_broadcasting_latest_txn(&channel_id, &nodes[2].node.get_our_node_id(), error_message.to_string()).unwrap();
492-
let events = nodes[1].node.get_and_clear_pending_events();
493-
match events[0] {
494-
crate::events::Event::PendingHTLCsForwardable { .. } => {},
495-
_ => panic!("Unexpected event {:?}", events),
496-
};
497-
match events[1] {
498-
crate::events::Event::ChannelClosed { .. } => {},
499-
_ => panic!("Unexpected event {:?}", events),
500-
}
479+
macro_rules! cause_error {
480+
($prev_node: expr, $curr_node: expr, $next_node: expr, $failed_chan_id: expr, $failed_scid: expr) => {
481+
match check {
482+
ProcessPendingHTLCsCheck::FwdPeerDisconnected => {
483+
// Disconnect the next-hop peer so when we go to forward in process_pending_htlc_forwards, the
484+
// intro node will error backwards.
485+
$curr_node.node.peer_disconnected(&$next_node.node.get_our_node_id());
486+
expect_pending_htlcs_forwardable!($curr_node);
487+
expect_pending_htlcs_forwardable_and_htlc_handling_failed_ignore!($curr_node,
488+
vec![HTLCDestination::NextHopChannel { node_id: Some($next_node.node.get_our_node_id()), channel_id: $failed_chan_id }]);
489+
},
490+
ProcessPendingHTLCsCheck::FwdChannelClosed => {
491+
// Force close the next-hop channel so when we go to forward in process_pending_htlc_forwards,
492+
// the intro node will error backwards.
493+
$curr_node.node.force_close_broadcasting_latest_txn(&$failed_chan_id, &$next_node.node.get_our_node_id(), error_message.to_string()).unwrap();
494+
let events = $curr_node.node.get_and_clear_pending_events();
495+
match events[0] {
496+
crate::events::Event::PendingHTLCsForwardable { .. } => {},
497+
_ => panic!("Unexpected event {:?}", events),
498+
};
499+
match events[1] {
500+
crate::events::Event::ChannelClosed { .. } => {},
501+
_ => panic!("Unexpected event {:?}", events),
502+
}
501503

502504
$curr_node.node.process_pending_htlc_forwards();
503505
expect_pending_htlcs_forwardable_and_htlc_handling_failed_ignore!($curr_node,

0 commit comments

Comments
 (0)