mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-14 11:26:09 -05:00
Merge 4631aeb59a
into 85f96b01b7
This commit is contained in:
commit
754b0bea9f
1 changed files with 4 additions and 9 deletions
|
@ -156,10 +156,11 @@ class MiningTest(BitcoinTestFramework):
|
||||||
# mintime and curtime should match
|
# mintime and curtime should match
|
||||||
assert_equal(tmpl['mintime'], tmpl['curtime'])
|
assert_equal(tmpl['mintime'], tmpl['curtime'])
|
||||||
|
|
||||||
|
self.log.info("Test timewarp protection boundary")
|
||||||
block = CBlock()
|
block = CBlock()
|
||||||
block.nVersion = tmpl["version"]
|
block.nVersion = tmpl["version"]
|
||||||
block.hashPrevBlock = int(tmpl["previousblockhash"], 16)
|
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.nBits = int(tmpl["bits"], 16)
|
||||||
block.nNonce = 0
|
block.nNonce = 0
|
||||||
block.vtx = [create_coinbase(height=int(tmpl["height"]))]
|
block.vtx = [create_coinbase(height=int(tmpl["height"]))]
|
||||||
|
@ -167,18 +168,12 @@ class MiningTest(BitcoinTestFramework):
|
||||||
assert_template(node, block, None)
|
assert_template(node, block, None)
|
||||||
|
|
||||||
bad_block = copy.deepcopy(block)
|
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.nTime = t + MAX_FUTURE_BLOCK_TIME - MAX_TIMEWARP - 1
|
||||||
bad_block.solve()
|
bad_block.solve()
|
||||||
assert_raises_rpc_error(-25, 'time-timewarp-attack', lambda: node.submitheader(hexdata=CBlockHeader(bad_block).serialize().hex()))
|
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
|
block.solve()
|
||||||
bad_block.solve()
|
node.submitheader(hexdata=CBlockHeader(block).serialize().hex())
|
||||||
node.submitheader(hexdata=CBlockHeader(bad_block).serialize().hex())
|
|
||||||
|
|
||||||
def test_pruning(self):
|
def test_pruning(self):
|
||||||
self.log.info("Test that submitblock stores previously pruned block")
|
self.log.info("Test that submitblock stores previously pruned block")
|
||||||
|
|
Loading…
Add table
Reference in a new issue