diff --git a/src/test/addrman_tests.cpp b/src/test/addrman_tests.cpp index c4f58ebecf863..ddb1d5b43f306 100644 --- a/src/test/addrman_tests.cpp +++ b/src/test/addrman_tests.cpp @@ -448,10 +448,21 @@ BOOST_AUTO_TEST_CASE(getaddr_unfiltered) CNetAddr source = ResolveIP("250.1.2.1"); BOOST_CHECK(addrman->Add({addr1, addr2}, source)); - // Filtered GetAddr should only return addr1 + // Set time on this addr so isTerrible = false + CAddress addr3 = CAddress(ResolveService("250.251.2.3", 9998), NODE_NONE); + addr3.nTime = Now(); + addrman->Good(addr3, /*time=*/Now()); + BOOST_CHECK(addrman->Add({addr3}, source)); + // The time is set, but after ADDRMAN_RETRIES unsuccessful attempts not + // retried in the last minute, this addr should be isTerrible = true + for (size_t i = 0; i < 3; ++i) { + addrman->Attempt(addr3, /*fCountFailure=*/true, /*time=*/Now() - 61s); + } + + // GetAddr filtered by quality (i.e. not IsTerrible) should only return addr1 BOOST_CHECK_EQUAL(addrman->GetAddr(/*max_addresses=*/0, /*max_pct=*/0, /*network=*/std::nullopt).size(), 1U); - // Unfiltered GetAddr should return addr1 and addr2 - BOOST_CHECK_EQUAL(addrman->GetAddr(/*max_addresses=*/0, /*max_pct=*/0, /*network=*/std::nullopt, /*filtered=*/false).size(), 2U); + // Unfiltered GetAddr should return all addrs + BOOST_CHECK_EQUAL(addrman->GetAddr(/*max_addresses=*/0, /*max_pct=*/0, /*network=*/std::nullopt, /*filtered=*/false).size(), 3U); } BOOST_AUTO_TEST_CASE(caddrinfo_get_tried_bucket_legacy)