@@ -815,8 +815,27 @@ fn do_test_revoked_counterparty_commitment_balances(confirm_htlc_spend_first: bo
815
815
connect_blocks ( & nodes[ 0 ] , htlc_cltv_timeout + 1 - 10 ) ;
816
816
check_closed_broadcast ! ( nodes[ 0 ] , true ) ;
817
817
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( ) ) ;
820
839
if let Event :: PendingHTLCsForwardable { .. } = events[ 0 ] { } else { panic ! ( ) ; }
821
840
match & events[ 1 ] {
822
841
Event :: ChannelClosed { reason : ClosureReason :: CommitmentTxConfirmed , .. } => { } ,
@@ -999,7 +1018,7 @@ fn test_revoked_counterparty_htlc_tx_balances() {
999
1018
assert_eq ! ( funding_outpoint. to_channel_id( ) , chan_id) ;
1000
1019
1001
1020
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 ;
1003
1022
let revoked_local_txn = get_local_commitment_txn ! ( nodes[ 1 ] , chan_id) ;
1004
1023
assert_eq ! ( revoked_local_txn[ 0 ] . input. len( ) , 1 ) ;
1005
1024
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() {
1119
1138
sorted_vec( nodes[ 0 ] . chain_monitor. chain_monitor. get_monitor( funding_outpoint) . unwrap( ) . get_claimable_balances( ) ) ) ;
1120
1139
1121
1140
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 } ] ) ;
1123
1143
// As time goes on A may split its revocation claim transaction into multiple.
1124
1144
let as_fewer_input_rbf = nodes[ 0 ] . tx_broadcaster . txn_broadcasted . lock ( ) . unwrap ( ) . split_off ( 0 ) ;
1125
1145
for tx in as_fewer_input_rbf. iter ( ) {
0 commit comments