Skip to content

Commit fb3dcf0

Browse files
committed
test fix: Fix TestRoutingMessageHandler get_next_channel_announcements()
introduced: 3e0aed2 The existing implementation of the TestRoutingMessageHandler test stub had two bugs: * Conditions where the range end point would be less than the range start point resulting in pushed values when they weren't expected * Test stub did not return TOTAL_UPDS total updates. Instead it returned half of them due to the calculation of the range.
1 parent 62820fe commit fb3dcf0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lightning/src/util/test_utils.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -613,11 +613,11 @@ impl msgs::RoutingMessageHandler for TestRoutingMessageHandler {
613613
Err(msgs::LightningError { err: "".to_owned(), action: msgs::ErrorAction::IgnoreError })
614614
}
615615
fn handle_htlc_fail_channel_update(&self, _update: &msgs::HTLCFailChannelUpdate) {}
616-
fn get_next_channel_announcements(&self, starting_point: u64, batch_amount: u8) -> Vec<(msgs::ChannelAnnouncement, Option<msgs::ChannelUpdate>, Option<msgs::ChannelUpdate>)> {
616+
fn get_next_channel_announcements(&self, _starting_point: u64, batch_amount: u8) -> Vec<(msgs::ChannelAnnouncement, Option<msgs::ChannelUpdate>, Option<msgs::ChannelUpdate>)> {
617617
let mut chan_anns = Vec::new();
618-
const TOTAL_UPDS: u64 = 100;
619-
let end: u64 = cmp::min(starting_point + batch_amount as u64, TOTAL_UPDS - self.chan_anns_sent.load(Ordering::Acquire) as u64);
620-
for i in starting_point..end {
618+
const TOTAL_UPDS: u64 = 50;
619+
let items_to_send = cmp::min(batch_amount as u64, TOTAL_UPDS - self.chan_anns_sent.load(Ordering::Acquire) as u64);
620+
for i in 0..items_to_send {
621621
let chan_upd_1 = get_dummy_channel_update(i);
622622
let chan_upd_2 = get_dummy_channel_update(i);
623623
let chan_ann = get_dummy_channel_announcement(i);

0 commit comments

Comments
 (0)