Skip to content

Commit

Permalink
Merge pull request zcash#6964 from daira/mining-test-comment-offbyone
Browse files Browse the repository at this point in the history
Miner tests: correct a comment, and add another similar comment where it applies
  • Loading branch information
str4d authored Oct 24, 2024
2 parents 7fbb055 + 7505afc commit 99ad6fd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/test/miner_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 99ad6fd

Please sign in to comment.