From ee36d647c79418d83a474033fdca56a7bae4ba71 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Thu, 13 May 2021 15:41:05 +0000 Subject: [PATCH] Simplify+expand per-channel check in test_announce_disable_channels --- lightning/src/ln/functional_tests.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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!"); } }, -- 2.39.5