Skip to content

Commit 9ccf843

Browse files
DashCoreAutoGuixfanquake
authored andcommitted
Merge bitcoin#26259: test: Test year 2106 block timestamps
Co-authored-by: fanquake <[email protected]>
1 parent 2d27f12 commit 9ccf843

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

test/functional/mining_basic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def assert_submitblock(block, result_str_1, result_str_2=None):
179179

180180
self.log.info("getblocktemplate: Test bad timestamps")
181181
bad_block = copy.deepcopy(block)
182-
bad_block.nTime = 2**31 - 1
182+
bad_block.nTime = 2**32 - 1
183183
assert_template(node, bad_block, 'time-too-new')
184184
assert_submitblock(bad_block, 'time-too-new', 'time-too-new')
185185
bad_block.nTime = 0

test/functional/rpc_blockchain.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ def run_test(self):
9292
self._test_stopatheight()
9393
self._test_waitforblockheight()
9494
self._test_getblock()
95+
self._test_y2106()
9596
assert self.nodes[0].verifychain(4, 0)
9697

9798
def mine_chain(self):
@@ -247,6 +248,14 @@ def _test_getblockchaininfo(self):
247248
'active': False},
248249
})
249250

251+
def _test_y2106(self):
252+
self.log.info("Check that block timestamps work until year 2106")
253+
self.generate(self.nodes[0], 8)[-1]
254+
time_2106 = 2**32 - 1
255+
self.nodes[0].setmocktime(time_2106)
256+
last = self.generate(self.nodes[0], 6)[-1]
257+
assert_equal(self.nodes[0].getblockheader(last)["mediantime"], time_2106)
258+
250259
def _test_getchaintxstats(self):
251260
self.log.info("Test getchaintxstats")
252261

0 commit comments

Comments
 (0)