Simplify+expand per-channel check in test_announce_disable_channels 2021-05-fix-disabled-announcements
authorMatt Corallo <git@bluematt.me>
Thu, 13 May 2021 15:41:05 +0000 (15:41 +0000)
committerMatt Corallo <git@bluematt.me>
Fri, 14 May 2021 23:20:27 +0000 (23:20 +0000)
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!");
                                }
                        },