Skip to content

Commit ab7e4e4

Browse files
committed
Consider downstream force closed flag for PaymentForwarded event tests
1 parent a42994b commit ab7e4e4

6 files changed

+14
-15
lines changed

lightning/src/ln/chanmon_update_fail_tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,7 @@ fn test_monitor_update_fail_reestablish() {
11021102
assert!(updates.update_fee.is_none());
11031103
assert_eq!(updates.update_fulfill_htlcs.len(), 1);
11041104
nodes[1].node.handle_update_fulfill_htlc(&nodes[2].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
1105-
expect_payment_forwarded!(nodes[1], nodes[0], nodes[2], Some(1000), false);
1105+
expect_payment_forwarded!(nodes[1], nodes[0], nodes[2], Some(1000), false, false);
11061106
check_added_monitors!(nodes[1], 1);
11071107
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
11081108
commitment_signed_dance!(nodes[1], nodes[2], updates.commitment_signed, false);
@@ -2087,7 +2087,7 @@ fn test_fail_htlc_on_broadcast_after_claim() {
20872087
nodes[1].node.handle_update_fulfill_htlc(&nodes[2].node.get_our_node_id(), &cs_updates.update_fulfill_htlcs[0]);
20882088
let bs_updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
20892089
check_added_monitors!(nodes[1], 1);
2090-
expect_payment_forwarded!(nodes[1], nodes[0], nodes[2], Some(1000), false);
2090+
expect_payment_forwarded!(nodes[1], nodes[0], nodes[2], Some(1000), false, false);
20912091

20922092
mine_transaction(&nodes[1], &bs_txn[0]);
20932093
check_closed_event!(nodes[1], 1, ClosureReason::CommitmentTxConfirmed);
@@ -2468,7 +2468,7 @@ fn do_test_reconnect_dup_htlc_claims(htlc_status: HTLCStatusAtDupClaim, second_f
24682468
assert_eq!(fulfill_msg, cs_updates.update_fulfill_htlcs[0]);
24692469
}
24702470
nodes[1].node.handle_update_fulfill_htlc(&nodes[2].node.get_our_node_id(), &fulfill_msg);
2471-
expect_payment_forwarded!(nodes[1], nodes[0], nodes[2], Some(1000), false);
2471+
expect_payment_forwarded!(nodes[1], nodes[0], nodes[2], Some(1000), false, false);
24722472
check_added_monitors!(nodes[1], 1);
24732473

24742474
let mut bs_updates = None;

lightning/src/ln/functional_test_utils.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,7 +1327,7 @@ macro_rules! expect_payment_path_successful {
13271327
}
13281328

13291329
macro_rules! expect_payment_forwarded {
1330-
($node: expr, $source_node: expr, $sink_node: expr, $expected_fee: expr, $upstream_force_closed: expr) => {
1330+
($node: expr, $source_node: expr, $sink_node: expr, $expected_fee: expr, $upstream_force_closed: expr, $downstream_force_closed: expr) => {
13311331
let events = $node.node.get_and_clear_pending_events();
13321332
assert_eq!(events.len(), 1);
13331333
match events[0] {
@@ -1336,10 +1336,9 @@ macro_rules! expect_payment_forwarded {
13361336
if fee_earned_msat.is_some() {
13371337
// Is the event source_channel_id in one of the channels between the two nodes?
13381338
assert!($node.node.list_channels().iter().any(|x| x.counterparty.node_id == $source_node.node.get_our_node_id() && x.channel_id == source_channel_id.unwrap()));
1339-
// After close, channel isn't available
1340-
if $node.node.list_channels().len() > 1 {
1341-
assert!($node.node.list_channels().iter().any(|x| x.counterparty.node_id == $sink_node.node.get_our_node_id() && x.channel_id == sink_channel_id.unwrap()));
1342-
}
1339+
}
1340+
if !$downstream_force_closed {
1341+
assert!($node.node.list_channels().iter().any(|x| x.counterparty.node_id == $sink_node.node.get_our_node_id() && x.channel_id == sink_channel_id.unwrap()));
13431342
}
13441343
assert_eq!(claim_from_onchain_tx, $upstream_force_closed);
13451344
},
@@ -1583,7 +1582,7 @@ pub fn do_claim_payment_along_route<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>,
15831582
{
15841583
$node.node.handle_update_fulfill_htlc(&$prev_node.node.get_our_node_id(), &next_msgs.as_ref().unwrap().0);
15851584
let fee = $node.node.channel_state.lock().unwrap().by_id.get(&next_msgs.as_ref().unwrap().0.channel_id).unwrap().config.forwarding_fee_base_msat;
1586-
expect_payment_forwarded!($node, $next_node, $prev_node, Some(fee as u64), false);
1585+
expect_payment_forwarded!($node, $next_node, $prev_node, Some(fee as u64), false, false);
15871586
expected_total_fee_msat += fee as u64;
15881587
check_added_monitors!($node, 1);
15891588
let new_next_msgs = if $new_msgs {

lightning/src/ln/functional_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5290,7 +5290,7 @@ fn test_duplicate_payment_hash_one_failure_one_success() {
52905290
// Note that the fee paid is effectively double as the HTLC value (including the nodes[1] fee
52915291
// and nodes[2] fee) is rounded down and then claimed in full.
52925292
mine_transaction(&nodes[1], &htlc_success_txn[0]);
5293-
expect_payment_forwarded!(nodes[1], nodes[0], nodes[2], Some(196*2), true);
5293+
expect_payment_forwarded!(nodes[1], nodes[0], nodes[2], Some(196*2), true, true);
52945294
let updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
52955295
assert!(updates.update_add_htlcs.is_empty());
52965296
assert!(updates.update_fail_htlcs.is_empty());
@@ -8872,7 +8872,7 @@ fn do_test_onchain_htlc_settlement_after_close(broadcast_alice: bool, go_onchain
88728872
assert_eq!(carol_updates.update_fulfill_htlcs.len(), 1);
88738873

88748874
nodes[1].node.handle_update_fulfill_htlc(&nodes[2].node.get_our_node_id(), &carol_updates.update_fulfill_htlcs[0]);
8875-
expect_payment_forwarded!(nodes[1], nodes[0], nodes[2], if go_onchain_before_fulfill || force_closing_node == 1 { None } else { Some(1000) }, false);
8875+
expect_payment_forwarded!(nodes[1], nodes[0], nodes[2], if go_onchain_before_fulfill || force_closing_node == 1 { None } else { Some(1000) }, false, false);
88768876
// If Alice broadcasted but Bob doesn't know yet, here he prepares to tell her about the preimage.
88778877
if !go_onchain_before_fulfill && broadcast_alice {
88788878
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
@@ -495,7 +495,7 @@ fn do_retry_with_no_persist(confirm_before_reload: bool) {
495495
let bs_htlc_claim_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap().split_off(0);
496496
assert_eq!(bs_htlc_claim_txn.len(), 1);
497497
check_spends!(bs_htlc_claim_txn[0], as_commitment_tx);
498-
expect_payment_forwarded!(nodes[1], nodes[0], nodes[2], None, false);
498+
expect_payment_forwarded!(nodes[1], nodes[0], nodes[2], None, false, false);
499499

500500
if !confirm_before_reload {
501501
mine_transaction(&nodes[0], &as_commitment_tx);

lightning/src/ln/reorg_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ fn do_test_onchain_htlc_reorg(local_commitment: bool, claim: bool) {
138138
// ChannelManager only polls chain::Watch::release_pending_monitor_events when we
139139
// probe it for events, so we probe non-message events here (which should just be the
140140
// PaymentForwarded event).
141-
expect_payment_forwarded!(nodes[1], nodes[0], nodes[2], Some(1000), true);
141+
expect_payment_forwarded!(nodes[1], nodes[0], nodes[2], Some(1000), true, true);
142142
} else {
143143
// Confirm the timeout tx and check that we fail the HTLC backwards
144144
let block = Block {

lightning/src/ln/shutdown_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ fn updates_shutdown_wait() {
110110
assert!(updates.update_fee.is_none());
111111
assert_eq!(updates.update_fulfill_htlcs.len(), 1);
112112
nodes[1].node.handle_update_fulfill_htlc(&nodes[2].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
113-
expect_payment_forwarded!(nodes[1], nodes[0], nodes[2], Some(1000), false);
113+
expect_payment_forwarded!(nodes[1], nodes[0], nodes[2], Some(1000), false, false);
114114
check_added_monitors!(nodes[1], 1);
115115
let updates_2 = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
116116
commitment_signed_dance!(nodes[1], nodes[2], updates.commitment_signed, false);
@@ -279,7 +279,7 @@ fn do_test_shutdown_rebroadcast(recv_count: u8) {
279279
assert!(updates.update_fee.is_none());
280280
assert_eq!(updates.update_fulfill_htlcs.len(), 1);
281281
nodes[1].node.handle_update_fulfill_htlc(&nodes[2].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
282-
expect_payment_forwarded!(nodes[1], nodes[0], nodes[2], Some(1000), false);
282+
expect_payment_forwarded!(nodes[1], nodes[0], nodes[2], Some(1000), false, false);
283283
check_added_monitors!(nodes[1], 1);
284284
let updates_2 = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
285285
commitment_signed_dance!(nodes[1], nodes[2], updates.commitment_signed, false);

0 commit comments

Comments
 (0)