Skip to content

Commit be6edd9

Browse files
committed
Correct expect_payment_forwarded upstream channel checking
`expect_payment_forwarded` takes a bool to indicate that the inbound channel on which we received a forwarded payment has been closed, but then ignores it in favor of looking at the fee in the event. While this is generally correct, in cases where we process an event after a channel was closed, which was generated before a channel closed this is incorrect. Instead, we examine the bool we already passed and use that.
1 parent 57cc3a0 commit be6edd9

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

lightning/src/ln/chanmon_update_fail_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3375,7 +3375,7 @@ fn do_test_durable_preimages_on_closed_channel(close_chans_before_reload: bool,
33753375
} else {
33763376
// While we forwarded the payment a while ago, we don't want to process events too early or
33773377
// we'll run background tasks we wanted to test individually.
3378-
expect_payment_forwarded!(nodes[1], nodes[0], nodes[2], None, false, !close_only_a);
3378+
expect_payment_forwarded!(nodes[1], nodes[0], nodes[2], None, true, !close_only_a);
33793379
}
33803380

33813381
mine_transactions(&nodes[0], &[&as_closing_tx[0], bs_preimage_tx]);

lightning/src/ln/functional_test_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1994,7 +1994,7 @@ macro_rules! expect_payment_forwarded {
19941994
outbound_amount_forwarded_msat: _
19951995
} => {
19961996
assert_eq!(fee_earned_msat, $expected_fee);
1997-
if fee_earned_msat.is_some() {
1997+
if !$upstream_force_closed {
19981998
// Is the event prev_channel_id in one of the channels between the two nodes?
19991999
assert!($node.node.list_channels().iter().any(|x| x.counterparty.node_id == $prev_node.node.get_our_node_id() && x.channel_id == prev_channel_id.unwrap()));
20002000
}

lightning/src/ln/functional_tests.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8614,7 +8614,8 @@ fn do_test_onchain_htlc_settlement_after_close(broadcast_alice: bool, go_onchain
86148614
assert_eq!(carol_updates.update_fulfill_htlcs.len(), 1);
86158615

86168616
nodes[1].node.handle_update_fulfill_htlc(&nodes[2].node.get_our_node_id(), &carol_updates.update_fulfill_htlcs[0]);
8617-
expect_payment_forwarded!(nodes[1], nodes[0], nodes[2], if go_onchain_before_fulfill || force_closing_node == 1 { None } else { Some(1000) }, false, false);
8617+
let went_onchain = go_onchain_before_fulfill || force_closing_node == 1;
8618+
expect_payment_forwarded!(nodes[1], nodes[0], nodes[2], if went_onchain { None } else { Some(1000) }, went_onchain, false);
86188619
// If Alice broadcasted but Bob doesn't know yet, here he prepares to tell her about the preimage.
86198620
if !go_onchain_before_fulfill && broadcast_alice {
86208621
let events = nodes[1].node.get_and_clear_pending_msg_events();

lightning/src/ln/payment_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ fn do_retry_with_no_persist(confirm_before_reload: bool) {
621621
nodes[1].node.handle_update_fulfill_htlc(&nodes[2].node.get_our_node_id(), &htlc_fulfill_updates.update_fulfill_htlcs[0]);
622622
check_added_monitors!(nodes[1], 1);
623623
commitment_signed_dance!(nodes[1], nodes[2], htlc_fulfill_updates.commitment_signed, false);
624-
expect_payment_forwarded!(nodes[1], nodes[0], nodes[2], None, false, false);
624+
expect_payment_forwarded!(nodes[1], nodes[0], nodes[2], None, true, false);
625625

626626
if confirm_before_reload {
627627
let best_block = nodes[0].blocks.lock().unwrap().last().unwrap().clone();

0 commit comments

Comments
 (0)