test: Enter mocktime before peer creation in block_relay_only_eviction
What changed, and why it matters
This is a minor internal test-only change in Bitcoin Core. It moves a mock clock setup earlier in a unit test so that simulated connection times are recorded consistently. There is no change to production code, no user-facing effect, and no security vulnerability.
No action required. This is a test-only refactor with no security relevance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies src/test/denialofservice_tests.cpp in the block_relay_only_eviction test. It hoists the NodeClockContext instantiation above peer creation so that peer m_connected timestamps are captured under mock time, making the subsequent MINIMUM_CONNECT_TIME eviction check deterministic. This is a test refactor prerequisite for a later change to NodeClockContext’s default constructor. No production networking, consensus, or validation code is altered.
Changed components
src/test/denialofservice_tests.cppInspect captured patch +1 / −1
diff --git a/src/test/denialofservice_tests.cpp b/src/test/denialofservice_tests.cpp
index 9709eacd..13b32b4f 100644
--- a/src/test/denialofservice_tests.cpp
+++ b/src/test/denialofservice_tests.cpp
@@ -243,6 +243,7 @@ BOOST_FIXTURE_TEST_CASE(stale_tip_peer_management, OutboundTest)
BOOST_FIXTURE_TEST_CASE(block_relay_only_eviction, OutboundTest)
{
NodeId id{0};
+ NodeClockContext clock_ctx{};
auto connman = std::make_unique<ConnmanTestMsg>(0x1337, 0x1337, *m_node.addrman, *m_node.netgroupman, Params());
auto peerLogic = PeerManager::make(*connman, *m_node.addrman, nullptr, *m_node.chainman, *m_node.mempool, *m_node.warnings, {});
@@ -274,7 +275,6 @@ BOOST_FIXTURE_TEST_CASE(block_relay_only_eviction, OutboundTest)
}
BOOST_CHECK(vNodes.back()->fDisconnect == false);
- NodeClockContext clock_ctx{};
clock_ctx += MINIMUM_CONNECT_TIME;
peerLogic->CheckForStaleTipAndEvictPeers();
for (int i = 0; i < max_outbound_block_relay; ++i) {
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.