@@ -2524,31 +2524,33 @@ mod tests {
2524
2524
{
2525
2525
use std:: time:: { SystemTime , UNIX_EPOCH } ;
2526
2526
2527
- let tracking_time = SystemTime :: now ( ) . duration_since ( UNIX_EPOCH ) . expect ( "Time must be > 1970" ) . as_secs ( ) ;
2528
-
2529
- // Clear tracked nodes and channels for clean slate
2530
- network_graph. removed_channels . lock ( ) . unwrap ( ) . clear ( ) ;
2531
- network_graph. removed_nodes . lock ( ) . unwrap ( ) . clear ( ) ;
2532
-
2533
- // Add a channel and nodes from channel announcement. So our network graph will
2534
- // now only consist of two nodes and one channel between them.
2535
- assert ! ( network_graph. update_channel_from_announcement(
2536
- & valid_channel_announcement, & chain_source) . is_ok( ) ) ;
2537
-
2538
- // Mark the channel as permanently failed. This will also remove the two nodes
2539
- // and all of the entries will be tracked as removed.
2540
- network_graph. channel_failed ( short_channel_id, true ) ;
2541
-
2542
- // Should not remove from tracking if insufficient time has passed
2543
- network_graph. remove_stale_channels_and_tracking_with_time (
2544
- tracking_time + REMOVED_ENTRIES_TRACKING_AGE_LIMIT_SECS - 1 ) ;
2545
- assert_eq ! ( network_graph. removed_channels. lock( ) . unwrap( ) . len( ) , 1 ) ;
2546
-
2547
- // Provide a later time so that sufficient time has passed
2548
- network_graph. remove_stale_channels_and_tracking_with_time (
2549
- tracking_time + REMOVED_ENTRIES_TRACKING_AGE_LIMIT_SECS ) ;
2550
- assert ! ( network_graph. removed_channels. lock( ) . unwrap( ) . is_empty( ) ) ;
2551
- assert ! ( network_graph. removed_nodes. lock( ) . unwrap( ) . is_empty( ) ) ;
2527
+ for _ in 0 ..500 {
2528
+ let tracking_time = SystemTime :: now ( ) . duration_since ( UNIX_EPOCH ) . expect ( "Time must be > 1970" ) . as_secs ( ) ;
2529
+
2530
+ // Clear tracked nodes and channels for clean slate
2531
+ network_graph. removed_channels . lock ( ) . unwrap ( ) . clear ( ) ;
2532
+ network_graph. removed_nodes . lock ( ) . unwrap ( ) . clear ( ) ;
2533
+
2534
+ // Add a channel and nodes from channel announcement. So our network graph will
2535
+ // now only consist of two nodes and one channel between them.
2536
+ assert ! ( network_graph. update_channel_from_announcement(
2537
+ & valid_channel_announcement, & chain_source) . is_ok( ) ) ;
2538
+
2539
+ // Mark the channel as permanently failed. This will also remove the two nodes
2540
+ // and all of the entries will be tracked as removed.
2541
+ network_graph. channel_failed ( short_channel_id, true ) ;
2542
+
2543
+ // Should not remove from tracking if insufficient time has passed
2544
+ network_graph. remove_stale_channels_and_tracking_with_time (
2545
+ tracking_time + REMOVED_ENTRIES_TRACKING_AGE_LIMIT_SECS - 1 ) ;
2546
+ assert_eq ! ( network_graph. removed_channels. lock( ) . unwrap( ) . len( ) , 1 , "Removed channel count ≠ 1 with tracking_time {}" , tracking_time) ;
2547
+
2548
+ // Provide a later time so that sufficient time has passed
2549
+ network_graph. remove_stale_channels_and_tracking_with_time (
2550
+ tracking_time + REMOVED_ENTRIES_TRACKING_AGE_LIMIT_SECS ) ;
2551
+ assert ! ( network_graph. removed_channels. lock( ) . unwrap( ) . is_empty( ) , "Unexpectedly removed channels with tracking_time {}" , tracking_time) ;
2552
+ assert ! ( network_graph. removed_nodes. lock( ) . unwrap( ) . is_empty( ) , "Unexpectedly removed nodes with tracking_time {}" , tracking_time) ;
2553
+ }
2552
2554
}
2553
2555
2554
2556
#[ cfg( not( feature = "std" ) ) ]
0 commit comments