@@ -448,10 +448,21 @@ BOOST_AUTO_TEST_CASE(getaddr_unfiltered)
448448 CNetAddr source = ResolveIP (" 250.1.2.1" );
449449 BOOST_CHECK (addrman->Add ({addr1, addr2}, source));
450450
451- // Filtered GetAddr should only return addr1
451+ // Set time on this addr so isTerrible = false
452+ CAddress addr3 = CAddress (ResolveService (" 250.251.2.3" , 9998 ), NODE_NONE);
453+ addr3.nTime = Now<NodeSeconds>();
454+ addrman->Good (addr3, /* time=*/ Now<NodeSeconds>());
455+ BOOST_CHECK (addrman->Add ({addr3}, source));
456+ // The time is set, but after ADDRMAN_RETRIES unsuccessful attempts not
457+ // retried in the last minute, this addr should be isTerrible = true
458+ for (size_t i = 0 ; i < 3 ; ++i) {
459+ addrman->Attempt (addr3, /* fCountFailure=*/ true , /* time=*/ Now<NodeSeconds>() - 61s);
460+ }
461+
462+ // GetAddr filtered by quality (i.e. not IsTerrible) should only return addr1
452463 BOOST_CHECK_EQUAL (addrman->GetAddr (/* max_addresses=*/ 0 , /* max_pct=*/ 0 , /* network=*/ std::nullopt ).size (), 1U );
453- // Unfiltered GetAddr should return addr1 and addr2
454- BOOST_CHECK_EQUAL (addrman->GetAddr (/* max_addresses=*/ 0 , /* max_pct=*/ 0 , /* network=*/ std::nullopt , /* filtered=*/ false ).size (), 2U );
464+ // Unfiltered GetAddr should return all addrs
465+ BOOST_CHECK_EQUAL (addrman->GetAddr (/* max_addresses=*/ 0 , /* max_pct=*/ 0 , /* network=*/ std::nullopt , /* filtered=*/ false ).size (), 3U );
455466}
456467
457468BOOST_AUTO_TEST_CASE (caddrinfo_get_tried_bucket_legacy)
0 commit comments