@@ -3464,7 +3464,7 @@ fn test_lost_preimage_monitor_events() {
3464
3464
do_test_lost_preimage_monitor_events ( false ) ;
3465
3465
}
3466
3466
3467
- fn do_test_lost_timeout_monitor_events ( on_counterparty_tx : bool ) {
3467
+ fn do_test_lost_timeout_monitor_events ( on_counterparty_tx : bool , dust_htlcs : bool ) {
3468
3468
// `MonitorEvent`s aren't delivered to the `ChannelManager` in a durable fasion - if the
3469
3469
// `ChannelManager` fetches the pending `MonitorEvent`s, then the `ChannelMonitor` gets
3470
3470
// persisted (i.e. due to a block update) then the node crashes, prior to persisting the
@@ -3509,8 +3509,11 @@ fn do_test_lost_timeout_monitor_events(on_counterparty_tx: bool) {
3509
3509
connect_blocks ( & nodes[ 1 ] , node_max_height - nodes[ 1 ] . best_block_info ( ) . 1 ) ;
3510
3510
connect_blocks ( & nodes[ 2 ] , node_max_height - nodes[ 2 ] . best_block_info ( ) . 1 ) ;
3511
3511
3512
- let ( _, hash_a, ..) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] , & nodes[ 2 ] ] , 5_000_000 ) ;
3513
- let ( _, hash_b, ..) = route_payment ( & nodes[ 1 ] , & [ & nodes[ 2 ] ] , 5_000_000 ) ;
3512
+ send_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] , & nodes[ 2 ] ] , 25_000_000 ) ;
3513
+
3514
+ let amt = if dust_htlcs { 1_000 } else { 10_000_000 } ;
3515
+ let ( _, hash_a, ..) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] , & nodes[ 2 ] ] , amt) ;
3516
+ let ( _, hash_b, ..) = route_payment ( & nodes[ 1 ] , & [ & nodes[ 2 ] ] , amt) ;
3514
3517
3515
3518
nodes[ 1 ] . node . peer_disconnected ( nodes[ 2 ] . node . get_our_node_id ( ) ) ;
3516
3519
nodes[ 2 ] . node . peer_disconnected ( nodes[ 1 ] . node . get_our_node_id ( ) ) ;
@@ -3568,23 +3571,22 @@ fn do_test_lost_timeout_monitor_events(on_counterparty_tx: bool) {
3568
3571
3569
3572
connect_blocks ( & nodes[ 1 ] , TEST_FINAL_CLTV - ANTI_REORG_DELAY + 1 ) ;
3570
3573
if !on_counterparty_tx {
3571
- let mut events = nodes[ 1 ] . chain_monitor . chain_monitor . get_and_clear_pending_events ( ) ;
3572
- assert_eq ! ( events. len( ) , 1 , "{events:?}" ) ;
3573
- match events. pop ( ) . unwrap ( ) {
3574
- Event :: BumpTransaction ( bump_event) => {
3575
- nodes[ 1 ] . bump_tx_handler . handle_event ( & bump_event) ;
3576
- } ,
3577
- _ => panic ! ( "Unexpected event" ) ,
3574
+ if !dust_htlcs {
3575
+ handle_bump_events ( & nodes[ 1 ] , false , 1 ) ;
3578
3576
}
3579
3577
}
3580
3578
let bs_htlc_timeouts =
3581
3579
nodes[ 1 ] . tx_broadcaster . txn_broadcasted . lock ( ) . unwrap ( ) . split_off ( 0 ) ;
3582
- assert_eq ! ( bs_htlc_timeouts. len( ) , 1 ) ;
3580
+ if dust_htlcs {
3581
+ assert_eq ! ( bs_htlc_timeouts. len( ) , 0 ) ;
3582
+ } else {
3583
+ assert_eq ! ( bs_htlc_timeouts. len( ) , 1 ) ;
3583
3584
3584
- // Now replay the timeouts on node B, which after 6 confirmations should fail the HTLCs via
3585
- // `MonitorUpdate`s
3586
- mine_transactions ( & nodes[ 1 ] , & bs_htlc_timeouts. iter ( ) . collect :: < Vec < _ > > ( ) ) ;
3587
- connect_blocks ( & nodes[ 1 ] , ANTI_REORG_DELAY - 1 ) ;
3585
+ // Now replay the timeouts on node B, which after 6 confirmations should fail the HTLCs via
3586
+ // `MonitorUpdate`s
3587
+ mine_transactions ( & nodes[ 1 ] , & bs_htlc_timeouts. iter ( ) . collect :: < Vec < _ > > ( ) ) ;
3588
+ connect_blocks ( & nodes[ 1 ] , ANTI_REORG_DELAY - 1 ) ;
3589
+ }
3588
3590
3589
3591
// Now simulate a restart where the B<->C ChannelMonitor has been persisted (i.e. because we
3590
3592
// just processed a new block) but the ChannelManager was not. This should be exceedingly rare
@@ -3637,6 +3639,8 @@ fn do_test_lost_timeout_monitor_events(on_counterparty_tx: bool) {
3637
3639
3638
3640
#[ test]
3639
3641
fn test_lost_timeout_monitor_events ( ) {
3640
- do_test_lost_timeout_monitor_events ( true ) ;
3641
- do_test_lost_timeout_monitor_events ( false ) ;
3642
+ do_test_lost_timeout_monitor_events ( true , false ) ;
3643
+ do_test_lost_timeout_monitor_events ( false , false ) ;
3644
+ do_test_lost_timeout_monitor_events ( true , true ) ;
3645
+ do_test_lost_timeout_monitor_events ( false , true ) ;
3642
3646
}
0 commit comments