File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -375,8 +375,9 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
375
375
auto nTime = pblocktemplate->block.nTime;
376
376
delete pblocktemplate;
377
377
378
- // Set the clock to be just ahead of the last "mined" block, to ensure we satisfy the
379
- // future timestamp soft fork rule.
378
+ // Set the clock to the timestamp of the last "mined" block, to ensure we satisfy the
379
+ // future timestamp soft fork rule. We use a fixed clock here because the time should
380
+ // not advance from `nTime` for the calls to `CreateNewBlock`.
380
381
FixedClock::SetGlobal();
381
382
FixedClock::Instance()->Set(std::chrono::seconds(nTime));
382
383
@@ -406,6 +407,9 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
406
407
BOOST_CHECK_EQUAL(pblocktemplate->block.nTime, minTime);
407
408
delete pblocktemplate;
408
409
410
+ // Set the clock back to the timestamp of the last "mined" block (and allow it to advance
411
+ // from that point), to ensure we satisfy both the rule that it is after the MTP, and the
412
+ // future timestamp soft fork rule.
409
413
auto curTime = GetTime();
410
414
OffsetClock::SetGlobal();
411
415
OffsetClock::Instance()->Set(std::chrono::seconds(-curTime + nTime));
You can’t perform that action at this time.
0 commit comments