From 7505afc78e931d1ca425af4d0b27418877f94b75 Mon Sep 17 00:00:00 2001 From: Daira-Emma Hopwood Date: Fri, 4 Oct 2024 17:50:45 +0100 Subject: [PATCH] Miner tests: correct a comment, and add another similar comment where it applies. Doc-only. Signed-off-by: Daira-Emma Hopwood --- src/test/miner_tests.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp index e73714b784..a575b493f9 100644 --- a/src/test/miner_tests.cpp +++ b/src/test/miner_tests.cpp @@ -375,8 +375,9 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) auto nTime = pblocktemplate->block.nTime; delete pblocktemplate; - // Set the clock to be just ahead of the last "mined" block, to ensure we satisfy the - // future timestamp soft fork rule. + // Set the clock to the timestamp of the last "mined" block, to ensure we satisfy the + // future timestamp soft fork rule. We use a fixed clock here because the time should + // not advance from `nTime` for the calls to `CreateNewBlock`. FixedClock::SetGlobal(); FixedClock::Instance()->Set(std::chrono::seconds(nTime)); @@ -406,6 +407,9 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) BOOST_CHECK_EQUAL(pblocktemplate->block.nTime, minTime); delete pblocktemplate; + // Set the clock back to the timestamp of the last "mined" block (and allow it to advance + // from that point), to ensure we satisfy both the rule that it is after the MTP, and the + // future timestamp soft fork rule. auto curTime = GetTime(); OffsetClock::SetGlobal(); OffsetClock::Instance()->Set(std::chrono::seconds(-curTime + nTime));