@@ -1653,7 +1653,7 @@ impl<L: Deref> NetworkGraph<L> where L::Target: Logger {
1653
1653
if info. two_to_one . is_some ( ) && info. two_to_one . as_ref ( ) . unwrap ( ) . last_update < min_time_unix {
1654
1654
info. two_to_one = None ;
1655
1655
}
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 ( ) {
1657
1657
// We check the announcement_received_time here to ensure we don't drop
1658
1658
// announcements that we just received and are just waiting for our peer to send a
1659
1659
// channel_update for.
@@ -2550,14 +2550,21 @@ mod tests {
2550
2550
{
2551
2551
// In std mode, a further check is performed before fully removing the channel -
2552
2552
// 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.
2555
2554
assert_eq ! ( network_graph. read_only( ) . channels( ) . len( ) , 1 ) ;
2556
2555
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( ) ) ;
2558
2556
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( ) ) ;
2559
2561
use std:: time:: { SystemTime , UNIX_EPOCH } ;
2560
2562
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( ) ) ;
2561
2568
network_graph. remove_stale_channels_and_tracking_with_time ( announcement_time + 1 + STALE_CHANNEL_UPDATE_AGE_LIMIT_SECS ) ;
2562
2569
}
2563
2570
0 commit comments