Skip to content

Commit 603922c

Browse files
committed
Debug #1914.
1 parent ac6e0b3 commit 603922c

File tree

1 file changed

+27
-25
lines changed

1 file changed

+27
-25
lines changed

lightning/src/routing/gossip.rs

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2524,31 +2524,33 @@ mod tests {
25242524
{
25252525
use std::time::{SystemTime, UNIX_EPOCH};
25262526

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+
}
25522554
}
25532555

25542556
#[cfg(not(feature = "std"))]

0 commit comments

Comments
 (0)