0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-07 10:27:47 -05:00

Compare commits

...

3 commits

Author SHA1 Message Date
tdb3
50b104ea31
Merge 4631aeb59a into 8fa10edcd1 2025-01-31 02:36:59 +01:00
tdb3
4631aeb59a
test: reuse block in timewarp check 2024-09-21 10:43:20 -04:00
tdb3
69eae7115d
test: simplify timewarp boundary check in mining_basic
Removes extraneous wall time check since time
just beyond timewarp boundary is checked.
2024-09-21 09:53:52 -04:00

View file

@ -154,10 +154,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"]))]
@ -165,18 +166,12 @@ 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()))
bad_block.nTime = t + MAX_FUTURE_BLOCK_TIME - MAX_TIMEWARP
bad_block.solve()
node.submitheader(hexdata=CBlockHeader(bad_block).serialize().hex())
block.solve()
node.submitheader(hexdata=CBlockHeader(block).serialize().hex())
def test_pruning(self):
self.log.info("Test that submitblock stores previously pruned block")