@@ -17,7 +17,8 @@ use crate::chain::chaininterface::FEERATE_FLOOR_SATS_PER_KW;
1717use crate :: chain:: chaininterface:: { ConfirmationTarget , TransactionType } ;
1818use crate :: chain:: chainmonitor:: { ChainMonitor , Persist } ;
1919use crate :: chain:: channelmonitor:: {
20- ChannelMonitor , ChannelMonitorUpdate , ChannelMonitorUpdateStep , MonitorEvent ,
20+ ChannelMonitor , ChannelMonitorUpdate , ChannelMonitorUpdateStep , ClaimInfo , ClaimKey ,
21+ MonitorEvent ,
2122} ;
2223use crate :: chain:: transaction:: OutPoint ;
2324use crate :: chain:: WatchedOutput ;
@@ -495,7 +496,8 @@ impl<T: chaininterface::BroadcasterInterface> SyncBroadcaster for T {}
495496impl < T : Persist < TestChannelSigner > > SyncPersist for T { }
496497
497498pub struct TestChainMonitor < ' a > {
498- pub added_monitors : Mutex < Vec < ( ChannelId , ChannelMonitor < TestChannelSigner > ) > > ,
499+ pub added_monitors :
500+ Mutex < Vec < ( ChannelId , ChannelMonitor < TestChannelSigner > , Option < ChannelMonitorUpdate > ) > > ,
499501 pub monitor_updates : Mutex < HashMap < ChannelId , Vec < ChannelMonitorUpdate > > > ,
500502 pub latest_monitor_update_id : Mutex < HashMap < ChannelId , ( u64 , u64 ) > > ,
501503 pub chain_monitor : ChainMonitor <
@@ -507,6 +509,7 @@ pub struct TestChainMonitor<'a> {
507509 & ' a dyn SyncPersist ,
508510 & ' a TestKeysInterface ,
509511 > ,
512+ pub persisted_claim_infos : Mutex < HashMap < ( ChannelId , ClaimKey ) , ClaimInfo > > ,
510513 pub keys_manager : & ' a TestKeysInterface ,
511514 /// If this is set to Some(), the next update_channel call (not watch_channel) must be a
512515 /// ChannelForceClosed event for the given channel_id with should_broadcast set to the given
@@ -537,6 +540,7 @@ impl<'a> TestChainMonitor<'a> {
537540 keys_manager,
538541 keys_manager. get_peer_storage_key ( ) ,
539542 ) ,
543+ persisted_claim_infos : Mutex :: new ( new_hash_map ( ) ) ,
540544 keys_manager,
541545 expect_channel_force_closed : Mutex :: new ( None ) ,
542546 expect_monitor_round_trip_fail : Mutex :: new ( None ) ,
@@ -577,7 +581,7 @@ impl<'a> TestChainMonitor<'a> {
577581 . lock ( )
578582 . unwrap ( )
579583 . insert ( channel_id, ( monitor. get_latest_update_id ( ) , monitor. get_latest_update_id ( ) ) ) ;
580- self . added_monitors . lock ( ) . unwrap ( ) . push ( ( channel_id, monitor) ) ;
584+ self . added_monitors . lock ( ) . unwrap ( ) . push ( ( channel_id, monitor, None ) ) ;
581585 self . chain_monitor . load_existing_monitor ( channel_id, new_monitor)
582586 }
583587
@@ -611,7 +615,7 @@ impl<'a> chain::Watch<TestChannelSigner> for TestChainMonitor<'a> {
611615 . lock ( )
612616 . unwrap ( )
613617 . insert ( channel_id, ( monitor. get_latest_update_id ( ) , monitor. get_latest_update_id ( ) ) ) ;
614- self . added_monitors . lock ( ) . unwrap ( ) . push ( ( channel_id, monitor) ) ;
618+ self . added_monitors . lock ( ) . unwrap ( ) . push ( ( channel_id, monitor, None ) ) ;
615619 self . chain_monitor . watch_channel ( channel_id, new_monitor)
616620 }
617621
@@ -666,9 +670,12 @@ impl<'a> chain::Watch<TestChannelSigner> for TestChainMonitor<'a> {
666670 assert_eq ! ( chan_id, channel_id) ;
667671 assert ! ( new_monitor != * monitor) ;
668672 } else {
669- assert ! ( new_monitor == * monitor) ;
673+ let expected_monitor = monitor. clone ( ) ;
674+ // Compare without [`Event::PersistClaimInfo`] events since we don't persist them.
675+ expected_monitor. get_and_clear_claim_info_events ( ) ;
676+ assert ! ( new_monitor == expected_monitor) ;
670677 }
671- self . added_monitors . lock ( ) . unwrap ( ) . push ( ( channel_id, new_monitor) ) ;
678+ self . added_monitors . lock ( ) . unwrap ( ) . push ( ( channel_id, new_monitor, Some ( update . clone ( ) ) ) ) ;
672679 update_res
673680 }
674681
0 commit comments