Skip to content

Commit

Permalink
Merge #26259: test: Test year 2106 block timestamps
Browse files Browse the repository at this point in the history
fafc96a test: Test year 2106 block timestamps (MacroFake)

Pull request description:

  Alternative to #21362 that closes #21356

ACKs for top commit:
  Sjors:
    utACK fafc96a

Tree-SHA512: 196d98f42d6f7f0222312b7bd1c68b3bd30cb6f0cbaccb900cfc5fcc689494adb2a7d7d6023c1ff1e8cf871047ec37eeca41386e31029d99cabf9343b4fd2a03
  • Loading branch information
fanquake committed Oct 21, 2022
2 parents 085f839 + fafc96a commit 6da4564
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion test/functional/mining_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def assert_submitblock(block, result_str_1, result_str_2=None):

self.log.info("getblocktemplate: Test bad timestamps")
bad_block = copy.deepcopy(block)
bad_block.nTime = 2**31 - 1
bad_block.nTime = 2**32 - 1
assert_template(node, bad_block, 'time-too-new')
assert_submitblock(bad_block, 'time-too-new', 'time-too-new')
bad_block.nTime = 0
Expand Down
9 changes: 9 additions & 0 deletions test/functional/rpc_blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def run_test(self):
self._test_waitforblockheight()
self._test_getblock()
self._test_getdeploymentinfo()
self._test_y2106()
assert self.nodes[0].verifychain(4, 0)

def mine_chain(self):
Expand Down Expand Up @@ -255,6 +256,14 @@ def _test_getdeploymentinfo(self):
# calling with an explicit hash works
self.check_signalling_deploymentinfo_result(self.nodes[0].getdeploymentinfo(gbci207["bestblockhash"]), gbci207["blocks"], gbci207["bestblockhash"], "started")

def _test_y2106(self):
self.log.info("Check that block timestamps work until year 2106")
self.generate(self.nodes[0], 8)[-1]
time_2106 = 2**32 - 1
self.nodes[0].setmocktime(time_2106)
last = self.generate(self.nodes[0], 6)[-1]
assert_equal(self.nodes[0].getblockheader(last)["mediantime"], time_2106)

def _test_getchaintxstats(self):
self.log.info("Test getchaintxstats")

Expand Down

0 comments on commit 6da4564

Please sign in to comment.