Skip to content

Commit

Permalink
test: ensure addrman test is finite
Browse files Browse the repository at this point in the history
Add a counter to ensure that the error case is bounded rather than leading to a
CI timeout
  • Loading branch information
amitiuttarwar authored and janus committed Sep 5, 2023
1 parent f16b8e1 commit bec52d0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/test/addrman_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,9 @@ BOOST_AUTO_TEST_CASE(addrman_select_by_network)
// ensure that both new and tried table are selected from
bool new_selected{false};
bool tried_selected{false};
int counter = 256;

while (!new_selected || !tried_selected) {
while (--counter > 0 && (!new_selected || !tried_selected)) {
const CAddress selected{addrman->Select(/*new_only=*/false, NET_I2P).first};
BOOST_REQUIRE(selected == i2p_addr || selected == i2p_addr2);
if (selected == i2p_addr) {
Expand All @@ -249,6 +250,9 @@ BOOST_AUTO_TEST_CASE(addrman_select_by_network)
new_selected = true;
}
}

BOOST_CHECK(new_selected);
BOOST_CHECK(tried_selected);
}

BOOST_AUTO_TEST_CASE(addrman_select_special)
Expand Down

0 comments on commit bec52d0

Please sign in to comment.