From: Matt Corallo Date: Thu, 13 May 2021 15:41:05 +0000 (+0000) Subject: Simplify+expand per-channel check in test_announce_disable_channels X-Git-Tag: v0.0.98~25^2 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=refs%2Fheads%2F2021-05-fix-disabled-announcements;p=rust-lightning Simplify+expand per-channel check in test_announce_disable_channels --- diff --git a/lightning/src/ln/functional_tests.rs b/lightning/src/ln/functional_tests.rs index 8b3301600..10270e68a 100644 --- a/lightning/src/ln/functional_tests.rs +++ b/lightning/src/ln/functional_tests.rs @@ -7586,13 +7586,13 @@ fn test_announce_disable_channels() { nodes[0].node.timer_tick_occurred(); // DisabledStaged -> Disabled let msg_events = nodes[0].node.get_and_clear_pending_msg_events(); assert_eq!(msg_events.len(), 3); + let mut chans_disabled: HashSet = [short_id_1, short_id_2, short_id_3].iter().map(|a| *a).collect(); for e in msg_events { match e { MessageSendEvent::BroadcastChannelUpdate { ref msg } => { assert_eq!(msg.contents.flags & (1<<1), 1<<1); // The "channel disabled" bit should be set - let short_id = msg.contents.short_channel_id; - // Check generated channel_update match list in PendingChannelUpdate - if short_id != short_id_1 && short_id != short_id_2 && short_id != short_id_3 { + // Check that each channel gets updated exactly once + if !chans_disabled.remove(&msg.contents.short_channel_id) { panic!("Generated ChannelUpdate for wrong chan!"); } }, @@ -7628,13 +7628,13 @@ fn test_announce_disable_channels() { nodes[0].node.timer_tick_occurred(); let msg_events = nodes[0].node.get_and_clear_pending_msg_events(); assert_eq!(msg_events.len(), 3); + chans_disabled = [short_id_1, short_id_2, short_id_3].iter().map(|a| *a).collect(); for e in msg_events { match e { MessageSendEvent::BroadcastChannelUpdate { ref msg } => { assert_eq!(msg.contents.flags & (1<<1), 0); // The "channel disabled" bit should be off - let short_id = msg.contents.short_channel_id; - // Check generated channel_update match list in PendingChannelUpdate - if short_id != short_id_1 && short_id != short_id_2 && short_id != short_id_3 { + // Check that each channel gets updated exactly once + if !chans_disabled.remove(&msg.contents.short_channel_id) { panic!("Generated ChannelUpdate for wrong chan!"); } },