@@ -1653,7 +1653,7 @@ impl<L: Deref> NetworkGraph<L> where L::Target: Logger {
16531653 if info. two_to_one . is_some ( ) && info. two_to_one . as_ref ( ) . unwrap ( ) . last_update < min_time_unix {
16541654 info. two_to_one = None ;
16551655 }
1656- if info. one_to_two . is_none ( ) && info. two_to_one . is_none ( ) {
1656+ if info. one_to_two . is_none ( ) || info. two_to_one . is_none ( ) {
16571657 // We check the announcement_received_time here to ensure we don't drop
16581658 // announcements that we just received and are just waiting for our peer to send a
16591659 // channel_update for.
@@ -2550,14 +2550,21 @@ mod tests {
25502550 {
25512551 // In std mode, a further check is performed before fully removing the channel -
25522552 // the channel_announcement must have been received at least two weeks ago. We
2553- // fudge that here by indicating the time has jumped two weeks. Note that the
2554- // directional channel information will have been removed already..
2553+ // fudge that here by indicating the time has jumped two weeks.
25552554 assert_eq ! ( network_graph. read_only( ) . channels( ) . len( ) , 1 ) ;
25562555 assert_eq ! ( network_graph. read_only( ) . nodes( ) . len( ) , 2 ) ;
2557- assert ! ( network_graph. read_only( ) . channels( ) . get( & short_channel_id) . unwrap( ) . one_to_two. is_none( ) ) ;
25582556
2557+ // Note that the directional channel information will have been removed already..
2558+ // We want to check that this will work even if *one* of the channel updates is recent,
2559+ // so we should add it with a recent timestamp.
2560+ assert ! ( network_graph. read_only( ) . channels( ) . get( & short_channel_id) . unwrap( ) . one_to_two. is_none( ) ) ;
25592561 use std:: time:: { SystemTime , UNIX_EPOCH } ;
25602562 let announcement_time = SystemTime :: now ( ) . duration_since ( UNIX_EPOCH ) . expect ( "Time must be > 1970" ) . as_secs ( ) ;
2563+ let valid_channel_update = get_signed_channel_update ( |unsigned_channel_update| {
2564+ unsigned_channel_update. timestamp = ( announcement_time + 1 + STALE_CHANNEL_UPDATE_AGE_LIMIT_SECS ) as u32 ;
2565+ } , node_1_privkey, & secp_ctx) ;
2566+ assert ! ( gossip_sync. handle_channel_update( & valid_channel_update) . is_ok( ) ) ;
2567+ assert ! ( network_graph. read_only( ) . channels( ) . get( & short_channel_id) . unwrap( ) . one_to_two. is_some( ) ) ;
25612568 network_graph. remove_stale_channels_and_tracking_with_time ( announcement_time + 1 + STALE_CHANNEL_UPDATE_AGE_LIMIT_SECS ) ;
25622569 }
25632570
0 commit comments