Skip to content

Commit 26a44ad

Browse files
committed
f rebase on latest upstream
1 parent 96ed4da commit 26a44ad

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

lightning/src/ln/monitor_tests.rs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -815,8 +815,27 @@ fn do_test_revoked_counterparty_commitment_balances(confirm_htlc_spend_first: bo
815815
connect_blocks(&nodes[0], htlc_cltv_timeout + 1 - 10);
816816
check_closed_broadcast!(nodes[0], true);
817817
check_added_monitors!(nodes[0], 1);
818-
let events = nodes[0].node.get_and_clear_pending_events();
819-
assert_eq!(events.len(), 2);
818+
819+
let mut events = nodes[0].node.get_and_clear_pending_events();
820+
assert_eq!(events.len(), 6);
821+
let mut failed_payments: HashSet<_> =
822+
[timeout_payment_hash, dust_payment_hash, live_payment_hash, missing_htlc_payment_hash]
823+
.iter().map(|a| *a).collect();
824+
events.retain(|ev| {
825+
match ev {
826+
Event::HTLCHandlingFailed { failed_next_destination: HTLCDestination::NextHopChannel { node_id, channel_id }, .. } => {
827+
assert_eq!(*channel_id, chan_id);
828+
assert_eq!(*node_id, Some(nodes[1].node.get_our_node_id()));
829+
false
830+
},
831+
Event::HTLCHandlingFailed { failed_next_destination: HTLCDestination::FailedPayment { payment_hash }, .. } => {
832+
assert!(failed_payments.remove(payment_hash));
833+
false
834+
},
835+
_ => true,
836+
}
837+
});
838+
assert!(failed_payments.is_empty());
820839
if let Event::PendingHTLCsForwardable { .. } = events[0] {} else { panic!(); }
821840
match &events[1] {
822841
Event::ChannelClosed { reason: ClosureReason::CommitmentTxConfirmed, .. } => {},
@@ -999,7 +1018,7 @@ fn test_revoked_counterparty_htlc_tx_balances() {
9991018
assert_eq!(funding_outpoint.to_channel_id(), chan_id);
10001019

10011020
let payment_preimage = route_payment(&nodes[0], &[&nodes[1]], 3_000_000).0;
1002-
route_payment(&nodes[1], &[&nodes[0]], 1_000_000).0;
1021+
let failed_payment_hash = route_payment(&nodes[1], &[&nodes[0]], 1_000_000).1;
10031022
let revoked_local_txn = get_local_commitment_txn!(nodes[1], chan_id);
10041023
assert_eq!(revoked_local_txn[0].input.len(), 1);
10051024
assert_eq!(revoked_local_txn[0].input[0].previous_output.txid, funding_tx.txid());
@@ -1119,7 +1138,8 @@ fn test_revoked_counterparty_htlc_tx_balances() {
11191138
sorted_vec(nodes[0].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances()));
11201139

11211140
connect_blocks(&nodes[0], revoked_htlc_timeout_txn[0].lock_time - nodes[0].best_block_info().1);
1122-
expect_pending_htlcs_forwardable_ignore!(&nodes[0]);
1141+
expect_pending_htlcs_forwardable_and_htlc_handling_failed_ignore!(&nodes[0],
1142+
[HTLCDestination::FailedPayment { payment_hash: failed_payment_hash }]);
11231143
// As time goes on A may split its revocation claim transaction into multiple.
11241144
let as_fewer_input_rbf = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().split_off(0);
11251145
for tx in as_fewer_input_rbf.iter() {

0 commit comments

Comments
 (0)