Skip to content

Commit f961c47

Browse files
committed
refactor: check Good() in tried_collisions test
Rather than try to infer a collision by checking `AddrMan::size`, check whether or not moving to the tried table was successful by checking the output from `AddrMan::Good`
1 parent 207f1c8 commit f961c47

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/test/addrman_tests.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -276,24 +276,24 @@ BOOST_AUTO_TEST_CASE(addrman_tried_collisions)
276276

277277
BOOST_CHECK_EQUAL(addrman.size(), num_addrs);
278278

279-
while (num_addrs < 64) { // Magic number! 250.1.1.1 - 250.1.1.64 do not collide with deterministic key = 1
279+
while (num_addrs < 35) { // Magic number! 250.1.1.1 - 250.1.1.35 do not collide in tried with deterministic key = 1
280280
CService addr = ResolveService("250.1.1." + ToString(++num_addrs));
281281
BOOST_CHECK(addrman.Add({CAddress(addr, NODE_NONE)}, source));
282-
addrman.Good(CAddress(addr, NODE_NONE));
283282

284-
// Test: No collision in tried table yet.
285-
BOOST_CHECK_EQUAL(addrman.size(), num_addrs);
283+
// Test: Add to tried without collision
284+
BOOST_CHECK(addrman.Good(CAddress(addr, NODE_NONE)));
285+
286286
}
287287

288-
// Test: tried table collision!
288+
// Test: Unable to add to tried table due to collision!
289289
CService addr1 = ResolveService("250.1.1." + ToString(++num_addrs));
290-
uint32_t collisions{1};
291-
BOOST_CHECK(!addrman.Add({CAddress(addr1, NODE_NONE)}, source));
292-
BOOST_CHECK_EQUAL(addrman.size(), num_addrs - collisions);
290+
BOOST_CHECK(addrman.Add({CAddress(addr1, NODE_NONE)}, source));
291+
BOOST_CHECK(!addrman.Good(CAddress(addr1, NODE_NONE)));
293292

293+
// Test: Add the next address to tried without collision
294294
CService addr2 = ResolveService("250.1.1." + ToString(++num_addrs));
295295
BOOST_CHECK(addrman.Add({CAddress(addr2, NODE_NONE)}, source));
296-
BOOST_CHECK_EQUAL(addrman.size(), num_addrs - collisions);
296+
BOOST_CHECK(addrman.Good(CAddress(addr2, NODE_NONE)));
297297
}
298298

299299
BOOST_AUTO_TEST_CASE(addrman_find)

0 commit comments

Comments
 (0)