@@ -3456,7 +3456,7 @@ fn test_lost_preimage_monitor_events() {
3456
3456
do_test_lost_preimage_monitor_events ( false ) ;
3457
3457
}
3458
3458
3459
- fn do_test_lost_timeout_monitor_events ( on_counterparty_tx : bool ) {
3459
+ fn do_test_lost_timeout_monitor_events ( on_counterparty_tx : bool , dust_htlcs : bool ) {
3460
3460
// `MonitorEvent`s aren't delivered to the `ChannelManager` in a durable fasion - if the
3461
3461
// `ChannelManager` fetches the pending `MonitorEvent`s, then the `ChannelMonitor` gets
3462
3462
// persisted (i.e. due to a block update) then the node crashes, prior to persisting the
@@ -3501,8 +3501,11 @@ fn do_test_lost_timeout_monitor_events(on_counterparty_tx: bool) {
3501
3501
connect_blocks ( & nodes[ 1 ] , node_max_height - nodes[ 1 ] . best_block_info ( ) . 1 ) ;
3502
3502
connect_blocks ( & nodes[ 2 ] , node_max_height - nodes[ 2 ] . best_block_info ( ) . 1 ) ;
3503
3503
3504
- let ( _, hash_a, ..) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] , & nodes[ 2 ] ] , 5_000_000 ) ;
3505
- let ( _, hash_b, ..) = route_payment ( & nodes[ 1 ] , & [ & nodes[ 2 ] ] , 5_000_000 ) ;
3504
+ send_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] , & nodes[ 2 ] ] , 25_000_000 ) ;
3505
+
3506
+ let amt = if dust_htlcs { 1_000 } else { 10_000_000 } ;
3507
+ let ( _, hash_a, ..) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] , & nodes[ 2 ] ] , amt) ;
3508
+ let ( _, hash_b, ..) = route_payment ( & nodes[ 1 ] , & [ & nodes[ 2 ] ] , amt) ;
3506
3509
3507
3510
nodes[ 1 ] . node . peer_disconnected ( nodes[ 2 ] . node . get_our_node_id ( ) ) ;
3508
3511
nodes[ 2 ] . node . peer_disconnected ( nodes[ 1 ] . node . get_our_node_id ( ) ) ;
@@ -3560,23 +3563,22 @@ fn do_test_lost_timeout_monitor_events(on_counterparty_tx: bool) {
3560
3563
3561
3564
connect_blocks ( & nodes[ 1 ] , TEST_FINAL_CLTV - ANTI_REORG_DELAY + 1 ) ;
3562
3565
if !on_counterparty_tx {
3563
- let mut events = nodes[ 1 ] . chain_monitor . chain_monitor . get_and_clear_pending_events ( ) ;
3564
- assert_eq ! ( events. len( ) , 1 , "{events:?}" ) ;
3565
- match events. pop ( ) . unwrap ( ) {
3566
- Event :: BumpTransaction ( bump_event) => {
3567
- nodes[ 1 ] . bump_tx_handler . handle_event ( & bump_event) ;
3568
- } ,
3569
- _ => panic ! ( "Unexpected event" ) ,
3566
+ if !dust_htlcs {
3567
+ handle_bump_events ( & nodes[ 1 ] , false , 1 ) ;
3570
3568
}
3571
3569
}
3572
3570
let bs_htlc_timeouts =
3573
3571
nodes[ 1 ] . tx_broadcaster . txn_broadcasted . lock ( ) . unwrap ( ) . split_off ( 0 ) ;
3574
- assert_eq ! ( bs_htlc_timeouts. len( ) , 1 ) ;
3572
+ if dust_htlcs {
3573
+ assert_eq ! ( bs_htlc_timeouts. len( ) , 0 ) ;
3574
+ } else {
3575
+ assert_eq ! ( bs_htlc_timeouts. len( ) , 1 ) ;
3575
3576
3576
- // Now replay the timeouts on node B, which after 6 confirmations should fail the HTLCs via
3577
- // `MonitorUpdate`s
3578
- mine_transactions ( & nodes[ 1 ] , & bs_htlc_timeouts. iter ( ) . collect :: < Vec < _ > > ( ) ) ;
3579
- connect_blocks ( & nodes[ 1 ] , ANTI_REORG_DELAY - 1 ) ;
3577
+ // Now replay the timeouts on node B, which after 6 confirmations should fail the HTLCs via
3578
+ // `MonitorUpdate`s
3579
+ mine_transactions ( & nodes[ 1 ] , & bs_htlc_timeouts. iter ( ) . collect :: < Vec < _ > > ( ) ) ;
3580
+ connect_blocks ( & nodes[ 1 ] , ANTI_REORG_DELAY - 1 ) ;
3581
+ }
3580
3582
3581
3583
// Now simulate a restart where the B<->C ChannelMonitor has been persisted (i.e. because we
3582
3584
// just processed a new block) but the ChannelManager was not. This should be exceedingly rare
@@ -3629,6 +3631,8 @@ fn do_test_lost_timeout_monitor_events(on_counterparty_tx: bool) {
3629
3631
3630
3632
#[ test]
3631
3633
fn test_lost_timeout_monitor_events ( ) {
3632
- do_test_lost_timeout_monitor_events ( true ) ;
3633
- do_test_lost_timeout_monitor_events ( false ) ;
3634
+ do_test_lost_timeout_monitor_events ( true , false ) ;
3635
+ do_test_lost_timeout_monitor_events ( false , false ) ;
3636
+ do_test_lost_timeout_monitor_events ( true , true ) ;
3637
+ do_test_lost_timeout_monitor_events ( false , true ) ;
3634
3638
}
0 commit comments