From 10580f55aa64a94dac47a0a90756b3499a742e39 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Mon, 25 Oct 2021 21:51:08 +0000 Subject: [PATCH] Correct send-bounding logic in `TestRoutingMessageHandler` The `cmp::min` appeared to confused `end` for a count. --- lightning/src/util/test_utils.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lightning/src/util/test_utils.rs b/lightning/src/util/test_utils.rs index 15eaa7d46..501afe8b7 100644 --- a/lightning/src/util/test_utils.rs +++ b/lightning/src/util/test_utils.rs @@ -311,7 +311,6 @@ fn get_dummy_channel_update(short_chan_id: u64) -> msgs::ChannelUpdate { pub struct TestRoutingMessageHandler { pub chan_upds_recvd: AtomicUsize, pub chan_anns_recvd: AtomicUsize, - pub chan_anns_sent: AtomicUsize, pub request_full_sync: AtomicBool, } @@ -320,7 +319,6 @@ impl TestRoutingMessageHandler { TestRoutingMessageHandler { chan_upds_recvd: AtomicUsize::new(0), chan_anns_recvd: AtomicUsize::new(0), - chan_anns_sent: AtomicUsize::new(0), request_full_sync: AtomicBool::new(false), } } @@ -339,8 +337,8 @@ impl msgs::RoutingMessageHandler for TestRoutingMessageHandler { } fn get_next_channel_announcements(&self, starting_point: u64, batch_amount: u8) -> Vec<(msgs::ChannelAnnouncement, Option, Option)> { let mut chan_anns = Vec::new(); - const TOTAL_UPDS: u64 = 100; - let end: u64 = cmp::min(starting_point + batch_amount as u64, TOTAL_UPDS - self.chan_anns_sent.load(Ordering::Acquire) as u64); + const TOTAL_UPDS: u64 = 50; + let end: u64 = cmp::min(starting_point + batch_amount as u64, TOTAL_UPDS); for i in starting_point..end { let chan_upd_1 = get_dummy_channel_update(i); let chan_upd_2 = get_dummy_channel_update(i); @@ -349,7 +347,6 @@ impl msgs::RoutingMessageHandler for TestRoutingMessageHandler { chan_anns.push((chan_ann, Some(chan_upd_1), Some(chan_upd_2))); } - self.chan_anns_sent.fetch_add(chan_anns.len(), Ordering::AcqRel); chan_anns } -- 2.39.5