@@ -1690,7 +1690,7 @@ impl<L: Deref> NetworkGraph<L> where L::Target: Logger {
1690
1690
if info. two_to_one . is_some ( ) && info. two_to_one . as_ref ( ) . unwrap ( ) . last_update < min_time_unix {
1691
1691
info. two_to_one = None ;
1692
1692
}
1693
- if info. one_to_two . is_none ( ) && info. two_to_one . is_none ( ) {
1693
+ if info. one_to_two . is_none ( ) || info. two_to_one . is_none ( ) {
1694
1694
// We check the announcement_received_time here to ensure we don't drop
1695
1695
// announcements that we just received and are just waiting for our peer to send a
1696
1696
// channel_update for.
@@ -2582,14 +2582,21 @@ mod tests {
2582
2582
{
2583
2583
// In std mode, a further check is performed before fully removing the channel -
2584
2584
// the channel_announcement must have been received at least two weeks ago. We
2585
- // fudge that here by indicating the time has jumped two weeks. Note that the
2586
- // directional channel information will have been removed already..
2585
+ // fudge that here by indicating the time has jumped two weeks.
2587
2586
assert_eq ! ( network_graph. read_only( ) . channels( ) . len( ) , 1 ) ;
2588
2587
assert_eq ! ( network_graph. read_only( ) . nodes( ) . len( ) , 2 ) ;
2589
- assert ! ( network_graph. read_only( ) . channels( ) . get( & short_channel_id) . unwrap( ) . one_to_two. is_none( ) ) ;
2590
2588
2589
+ // Note that the directional channel information will have been removed already..
2590
+ // We want to check that this will work even if *one* of the channel updates is recent,
2591
+ // so we should add it with a recent timestamp.
2592
+ assert ! ( network_graph. read_only( ) . channels( ) . get( & short_channel_id) . unwrap( ) . one_to_two. is_none( ) ) ;
2591
2593
use std:: time:: { SystemTime , UNIX_EPOCH } ;
2592
2594
let announcement_time = SystemTime :: now ( ) . duration_since ( UNIX_EPOCH ) . expect ( "Time must be > 1970" ) . as_secs ( ) ;
2595
+ let valid_channel_update = get_signed_channel_update ( |unsigned_channel_update| {
2596
+ unsigned_channel_update. timestamp = ( announcement_time + 1 + STALE_CHANNEL_UPDATE_AGE_LIMIT_SECS ) as u32 ;
2597
+ } , node_1_privkey, & secp_ctx) ;
2598
+ assert ! ( gossip_sync. handle_channel_update( & valid_channel_update) . is_ok( ) ) ;
2599
+ assert ! ( network_graph. read_only( ) . channels( ) . get( & short_channel_id) . unwrap( ) . one_to_two. is_some( ) ) ;
2593
2600
network_graph. remove_stale_channels_and_tracking_with_time ( announcement_time + 1 + STALE_CHANNEL_UPDATE_AGE_LIMIT_SECS ) ;
2594
2601
}
2595
2602
0 commit comments