From 69eae7115deea1c883ebcb016f2a9247074dacae Mon Sep 17 00:00:00 2001 From: tdb3 <106488469+tdb3@users.noreply.github.com> Date: Sat, 21 Sep 2024 09:53:52 -0400 Subject: [PATCH] test: simplify timewarp boundary check in mining_basic Removes extraneous wall time check since time just beyond timewarp boundary is checked. --- test/functional/mining_basic.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/test/functional/mining_basic.py b/test/functional/mining_basic.py index aca71933ec..2639374003 100755 --- a/test/functional/mining_basic.py +++ b/test/functional/mining_basic.py @@ -144,10 +144,11 @@ class MiningTest(BitcoinTestFramework): tmpl = node.getblocktemplate(NORMAL_GBT_REQUEST_PARAMS) assert_greater_than_or_equal(tmpl['curtime'], t + MAX_FUTURE_BLOCK_TIME - MAX_TIMEWARP) + self.log.info("Test timewarp protection boundary") block = CBlock() block.nVersion = tmpl["version"] block.hashPrevBlock = int(tmpl["previousblockhash"], 16) - block.nTime = tmpl["curtime"] + block.nTime = t + MAX_FUTURE_BLOCK_TIME - MAX_TIMEWARP block.nBits = int(tmpl["bits"], 16) block.nNonce = 0 block.vtx = [create_coinbase(height=int(tmpl["height"]))] @@ -155,11 +156,6 @@ class MiningTest(BitcoinTestFramework): assert_template(node, block, None) bad_block = copy.deepcopy(block) - bad_block.nTime = t - bad_block.solve() - assert_raises_rpc_error(-25, 'time-timewarp-attack', lambda: node.submitheader(hexdata=CBlockHeader(bad_block).serialize().hex())) - - self.log.info("Test timewarp protection boundary") bad_block.nTime = t + MAX_FUTURE_BLOCK_TIME - MAX_TIMEWARP - 1 bad_block.solve() assert_raises_rpc_error(-25, 'time-timewarp-attack', lambda: node.submitheader(hexdata=CBlockHeader(bad_block).serialize().hex()))