Skip to content

Commit ea4c9fd

Browse files
committed
test: Cover eviction by timeout in addrman_evictionworks
1 parent 4f1bb46 commit ea4c9fd

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/test/addrman_tests.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,8 @@ BOOST_AUTO_TEST_CASE(addrman_evictionworks)
823823
// Should swap 36 for 19.
824824
addrman->ResolveCollisions();
825825
BOOST_CHECK(addrman->SelectTriedCollision().first.ToString() == "[::]:0");
826+
AddressPosition addr_pos{addrman->FindAddressEntry(CAddress(addr, NODE_NONE)).value()};
827+
BOOST_CHECK(addr_pos.tried);
826828

827829
// If 36 was swapped for 19, then adding 36 to tried should fail because we
828830
// are attempting to add a duplicate.
@@ -837,8 +839,15 @@ BOOST_AUTO_TEST_CASE(addrman_evictionworks)
837839
BOOST_CHECK(!addrman->Good(addr19));
838840
BOOST_CHECK_EQUAL(addrman->SelectTriedCollision().first.ToString(), "250.1.1.36:0");
839841

842+
// Eviction is also successful if too much time has passed since last try
843+
SetMockTime(GetTime() + 4 * 60 *60);
840844
addrman->ResolveCollisions();
841845
BOOST_CHECK(addrman->SelectTriedCollision().first.ToString() == "[::]:0");
846+
//Now 19 is in tried again, and 36 back to new
847+
AddressPosition addr_pos19{addrman->FindAddressEntry(CAddress(addr19, NODE_NONE)).value()};
848+
BOOST_CHECK(addr_pos19.tried);
849+
AddressPosition addr_pos36{addrman->FindAddressEntry(CAddress(addr, NODE_NONE)).value()};
850+
BOOST_CHECK(!addr_pos36.tried);
842851
}
843852

844853
static CDataStream AddrmanToStream(const AddrMan& addrman)

0 commit comments

Comments
 (0)