Skip to content

Commit

Permalink
test: addrman: tried 3 times and never a success so isTerrible=true
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoerg committed Nov 19, 2024
1 parent ccc2d3a commit 1807df3
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/test/addrman_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<NodeSeconds>();
addrman->Good(addr3, /*time=*/Now<NodeSeconds>());
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<NodeSeconds>() - 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)
Expand Down

0 comments on commit 1807df3

Please sign in to comment.