mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-31 08:13:52 +02:00
scripted-diff: Use new create_block height option
-BEGIN VERIFY SCRIPT-
# Replace single-arg create_coinbase calls ...
# ... followed by ntime arg
sed --in-place --regexp-extended 's/create_block\((.+), create_coinbase\(([^,]+)\), /create_block(\1, height=\2, ntime=/g' $( git grep -l 'create_block(' )
# ... not followed by any other args
sed --in-place --regexp-extended 's/create_block\((.+), create_coinbase\(([^,]+)\)\)/create_block(\1, height=\2)/g' $( git grep -l 'create_block(' )
-END VERIFY SCRIPT-
This commit is contained in:
@@ -92,7 +92,7 @@ class AcceptBlockTest(BitcoinTestFramework):
|
||||
blocks_h2 = [] # the height 2 blocks on each node's chain
|
||||
block_time = int(time.time()) + 1
|
||||
for i in range(2):
|
||||
blocks_h2.append(create_block(tips[i], create_coinbase(2), block_time))
|
||||
blocks_h2.append(create_block(tips[i], height=2, ntime=block_time))
|
||||
blocks_h2[i].solve()
|
||||
block_time += 1
|
||||
test_node.send_and_ping(msg_block(blocks_h2[0]))
|
||||
@@ -108,7 +108,7 @@ class AcceptBlockTest(BitcoinTestFramework):
|
||||
self.log.info("First height 2 block accepted by node0; correctly rejected by node1")
|
||||
|
||||
# 3. Send another block that builds on genesis.
|
||||
block_h1f = create_block(int("0x" + self.nodes[0].getblockhash(0), 0), create_coinbase(1), block_time)
|
||||
block_h1f = create_block(int("0x" + self.nodes[0].getblockhash(0), 0), height=1, ntime=block_time)
|
||||
block_time += 1
|
||||
block_h1f.solve()
|
||||
test_node.send_and_ping(msg_block(block_h1f))
|
||||
@@ -122,7 +122,7 @@ class AcceptBlockTest(BitcoinTestFramework):
|
||||
assert_raises_rpc_error(-1, "Block not available (not fully downloaded)", self.nodes[0].getblock, block_h1f.hash_hex)
|
||||
|
||||
# 4. Send another two block that build on the fork.
|
||||
block_h2f = create_block(block_h1f.hash_int, create_coinbase(2), block_time)
|
||||
block_h2f = create_block(block_h1f.hash_int, height=2, ntime=block_time)
|
||||
block_time += 1
|
||||
block_h2f.solve()
|
||||
test_node.send_and_ping(msg_block(block_h2f))
|
||||
@@ -141,7 +141,7 @@ class AcceptBlockTest(BitcoinTestFramework):
|
||||
self.log.info("Second height 2 block accepted, but not reorg'ed to")
|
||||
|
||||
# 4b. Now send another block that builds on the forking chain.
|
||||
block_h3 = create_block(block_h2f.hash_int, create_coinbase(3), block_h2f.nTime+1)
|
||||
block_h3 = create_block(block_h2f.hash_int, height=3, ntime=block_h2f.nTime+1)
|
||||
block_h3.solve()
|
||||
test_node.send_and_ping(msg_block(block_h3))
|
||||
|
||||
@@ -164,7 +164,7 @@ class AcceptBlockTest(BitcoinTestFramework):
|
||||
tip = block_h3
|
||||
all_blocks = []
|
||||
for i in range(288):
|
||||
next_block = create_block(tip.hash_int, create_coinbase(i + 4), tip.nTime+1)
|
||||
next_block = create_block(tip.hash_int, height=i + 4, ntime=tip.nTime+1)
|
||||
next_block.solve()
|
||||
all_blocks.append(next_block)
|
||||
tip = next_block
|
||||
@@ -235,15 +235,15 @@ class AcceptBlockTest(BitcoinTestFramework):
|
||||
|
||||
# 8. Create a chain which is invalid at a height longer than the
|
||||
# current chain, but which has more blocks on top of that
|
||||
block_289f = create_block(all_blocks[284].hash_int, create_coinbase(289), all_blocks[284].nTime+1)
|
||||
block_289f = create_block(all_blocks[284].hash_int, height=289, ntime=all_blocks[284].nTime+1)
|
||||
block_289f.solve()
|
||||
block_290f = create_block(block_289f.hash_int, create_coinbase(290), block_289f.nTime+1)
|
||||
block_290f = create_block(block_289f.hash_int, height=290, ntime=block_289f.nTime+1)
|
||||
block_290f.solve()
|
||||
# block_291 spends a coinbase below maturity!
|
||||
tx_to_add = create_tx_with_script(block_290f.vtx[0], 0, script_sig=b"42", amount=1)
|
||||
block_291 = create_block(block_290f.hash_int, create_coinbase(291), block_290f.nTime+1, txlist=[tx_to_add])
|
||||
block_291 = create_block(block_290f.hash_int, height=291, ntime=block_290f.nTime+1, txlist=[tx_to_add])
|
||||
block_291.solve()
|
||||
block_292 = create_block(block_291.hash_int, create_coinbase(292), block_291.nTime+1)
|
||||
block_292 = create_block(block_291.hash_int, height=292, ntime=block_291.nTime+1)
|
||||
block_292.solve()
|
||||
|
||||
# Now send all the headers on the chain and enough blocks to trigger reorg
|
||||
@@ -283,7 +283,7 @@ class AcceptBlockTest(BitcoinTestFramework):
|
||||
assert_equal(self.nodes[0].getblock(block_291.hash_hex)["confirmations"], -1)
|
||||
|
||||
# Now send a new header on the invalid chain, indicating we're forked off, and expect to get disconnected
|
||||
block_293 = create_block(block_292.hash_int, create_coinbase(293), block_292.nTime+1)
|
||||
block_293 = create_block(block_292.hash_int, height=293, ntime=block_292.nTime+1)
|
||||
block_293.solve()
|
||||
headers_message = msg_headers()
|
||||
headers_message.headers.append(CBlockHeader(block_293))
|
||||
|
||||
Reference in New Issue
Block a user