Skip to content

Commit e7051af

Browse files
committed
Better structure prune channel tests
This piece of code is at least confusing, but probably wrong too, and worked only because of the limited tests. Without this change, the following commit fails in no-std unexpectedly.
1 parent 2e343e7 commit e7051af

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lightning/src/routing/gossip.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2573,13 +2573,18 @@ mod tests {
25732573
assert!(gossip_sync.handle_channel_update(&valid_channel_update).is_ok());
25742574
assert!(network_graph.read_only().channels().get(&short_channel_id).unwrap().one_to_two.is_some());
25752575

2576-
network_graph.remove_stale_channels_and_tracking_with_time(100 + STALE_CHANNEL_UPDATE_AGE_LIMIT_SECS);
2577-
assert_eq!(network_graph.read_only().channels().len(), 1);
2578-
assert_eq!(network_graph.read_only().nodes().len(), 2);
2576+
#[cfg(not(feature = "std"))] {
2577+
// t=0 is the default announcement time.
2578+
network_graph.remove_stale_channels_and_tracking_with_time(0 + STALE_CHANNEL_UPDATE_AGE_LIMIT_SECS);
2579+
assert_eq!(network_graph.read_only().channels().len(), 1);
2580+
assert_eq!(network_graph.read_only().nodes().len(), 2);
2581+
network_graph.remove_stale_channels_and_tracking_with_time(1 + STALE_CHANNEL_UPDATE_AGE_LIMIT_SECS);
2582+
}
25792583

2580-
network_graph.remove_stale_channels_and_tracking_with_time(101 + STALE_CHANNEL_UPDATE_AGE_LIMIT_SECS);
25812584
#[cfg(feature = "std")]
25822585
{
2586+
// t=100 is the default announcement time.
2587+
network_graph.remove_stale_channels_and_tracking_with_time(100 + 1 + STALE_CHANNEL_UPDATE_AGE_LIMIT_SECS);
25832588
// In std mode, a further check is performed before fully removing the channel -
25842589
// the channel_announcement must have been received at least two weeks ago. We
25852590
// fudge that here by indicating the time has jumped two weeks. Note that the

0 commit comments

Comments
 (0)