Simplify+expand per-channel check in test_announce_disable_channels
[rust-lightning] / lightning / src / ln / functional_tests.rs
index 8b3301600257431608e2f324d68fcacc36c81638..10270e68a92ad3a4c45e1a4ca4104ae7b18b00b0 100644 (file)
@@ -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<u64> = [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!");
                                }
                        },