test: addrman: check isTerrible when time is more than 10min in the future
What changed, and why it matters
This commit only adds a new test case to Bitcoin Core's address manager test suite. It verifies that an address whose timestamp is set more than 10 minutes in the future is correctly classified as 'terrible' (low quality) and filtered out of normal peer address results. There is no change to production code, no bug fix, and no security patch.
No action required; this is a test-only change. Reviewers may optionally confirm the existing IsTerrible implementation correctly handles future timestamps as the test intends.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies src/test/addrman_tests.cpp in the getaddr_unfiltered test. It adds a fourth test address (addr4) with nTime set to Now
Changed components
src/test/addrman_tests.cppInspect captured patch +7 / −1
diff --git a/src/test/addrman_tests.cpp b/src/test/addrman_tests.cpp
index ddb1d5b4..310dc709 100644
--- a/src/test/addrman_tests.cpp
+++ b/src/test/addrman_tests.cpp
@@ -459,10 +459,16 @@ BOOST_AUTO_TEST_CASE(getaddr_unfiltered)
addrman->Attempt(addr3, /*fCountFailure=*/true, /*time=*/Now<NodeSeconds>() - 61s);
}
+ // Set time more than 10 minutes in the future (flying DeLorean), so this
+ // addr should be isTerrible = true
+ CAddress addr4 = CAddress(ResolveService("250.252.2.4", 9997), NODE_NONE);
+ addr4.nTime = Now<NodeSeconds>() + 11min;
+ BOOST_CHECK(addrman->Add({addr4}, source));
+
// 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 all addrs
- BOOST_CHECK_EQUAL(addrman->GetAddr(/*max_addresses=*/0, /*max_pct=*/0, /*network=*/std::nullopt, /*filtered=*/false).size(), 3U);
+ BOOST_CHECK_EQUAL(addrman->GetAddr(/*max_addresses=*/0, /*max_pct=*/0, /*network=*/std::nullopt, /*filtered=*/false).size(), 4U);
}
BOOST_AUTO_TEST_CASE(caddrinfo_get_tried_bucket_legacy)
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.