Skip to content

Commit 25dbe4b

Browse files
committed
Merge bitcoin/bitcoin#33533: test: addrman: check isTerrible when time is more than 10min in the future
8e47ed6 test: addrman: check isTerrible when time is more than 10min in the future (brunoerg) Pull request description: This PR adds test coverage to kill the following mutant (https://corecheck.dev/mutation/src/addrman.cpp#L76): ```diff diff --git a/src/addrman.cpp b/src/addrman.cpp index 9c3a24d..0ffd349315 100644 --- a/src/addrman.cpp +++ b/src/addrman.cpp @@ -73,7 +73,7 @@ bool AddrInfo::IsTerrible(NodeSeconds now) const } if (nTime > now + 10min) { // came in a flying DeLorean - return true; + return false; } ``` When the `nTime` is set 10 minutes in the future the addr should be marked as terrible. ACKs for top commit: Crypt-iQ: crACK 8e47ed6 danielabrozzoni: tACK 8e47ed6 marcofleon: Nice, code review ACK 8e47ed6 Tree-SHA512: b53b3aa234a73ec7808cb1555916ac64dd707f230ec290a1712493ece8e274a060e16d862b31df0f744804ebd3c0c2825c49becb7d3040cc358e48c4002524cb
2 parents cfb0d74 + 8e47ed6 commit 25dbe4b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/test/addrman_tests.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,10 +459,16 @@ BOOST_AUTO_TEST_CASE(getaddr_unfiltered)
459459
addrman->Attempt(addr3, /*fCountFailure=*/true, /*time=*/Now<NodeSeconds>() - 61s);
460460
}
461461

462+
// Set time more than 10 minutes in the future (flying DeLorean), so this
463+
// addr should be isTerrible = true
464+
CAddress addr4 = CAddress(ResolveService("250.252.2.4", 9997), NODE_NONE);
465+
addr4.nTime = Now<NodeSeconds>() + 11min;
466+
BOOST_CHECK(addrman->Add({addr4}, source));
467+
462468
// GetAddr filtered by quality (i.e. not IsTerrible) should only return addr1
463469
BOOST_CHECK_EQUAL(addrman->GetAddr(/*max_addresses=*/0, /*max_pct=*/0, /*network=*/std::nullopt).size(), 1U);
464470
// 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);
471+
BOOST_CHECK_EQUAL(addrman->GetAddr(/*max_addresses=*/0, /*max_pct=*/0, /*network=*/std::nullopt, /*filtered=*/false).size(), 4U);
466472
}
467473

468474
BOOST_AUTO_TEST_CASE(caddrinfo_get_tried_bucket_legacy)

0 commit comments

Comments
 (0)