Skip to content

Commit 79a4533

Browse files
committed
Remove need for additional create_block arg by extracting the block height directly from coinbase
1 parent 0927346 commit 79a4533

18 files changed

+49
-43
lines changed

test/functional/example_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def run_test(self):
166166
# Use the mininode and blocktools functionality to manually build a block
167167
# Calling the generate() rpc is easier, but this allows us to exactly
168168
# control the blocks and transactions.
169-
block = create_block(self.tip, create_coinbase(height+1), height+1, self.block_time)
169+
block = create_block(self.tip, create_coinbase(height+1), self.block_time)
170170
block.solve()
171171
block_message = msg_block(block)
172172
# Send message is used to send a P2P message to the node over our P2PInterface

test/functional/feature_assumevalid.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def run_test(self):
110110

111111
# Create the first block with a coinbase output to our key
112112
height = self.nodes[0].getblockcount() + 1
113-
block = create_block(self.tip, create_coinbase(height, coinbase_pubkey), height, self.block_time)
113+
block = create_block(self.tip, create_coinbase(height, coinbase_pubkey), self.block_time)
114114
self.blocks.append(block)
115115
self.block_time += 1
116116
block.solve()
@@ -121,7 +121,7 @@ def run_test(self):
121121

122122
# Bury the block 100 deep so the coinbase output is spendable
123123
for i in range(100):
124-
block = create_block(self.tip, create_coinbase(height), height, self.block_time)
124+
block = create_block(self.tip, create_coinbase(height), self.block_time)
125125
block.solve()
126126
self.blocks.append(block)
127127
self.tip = block.sha256
@@ -134,7 +134,7 @@ def run_test(self):
134134
tx.vout.append(CTxOut(49 * 100000000, CScript([OP_TRUE])))
135135
tx.calc_sha256()
136136

137-
block102 = create_block(self.tip, create_coinbase(height), height, self.block_time)
137+
block102 = create_block(self.tip, create_coinbase(height), self.block_time)
138138
self.block_time += 1
139139
block102.vtx.extend([tx])
140140
block102.hashMerkleRoot = block102.calc_merkle_root()
@@ -147,7 +147,7 @@ def run_test(self):
147147

148148
# Bury the assumed valid block 2100 deep
149149
for i in range(2100):
150-
block = create_block(self.tip, create_coinbase(height), height, self.block_time)
150+
block = create_block(self.tip, create_coinbase(height), self.block_time)
151151
block.nVersion = 4
152152
block.solve()
153153
self.blocks.append(block)

test/functional/feature_bip68_sequence.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ def test_nonzero_locks(orig_tx, node, relayfee, use_height_lock):
306306
tip = int(self.nodes[0].getblockhash(self.nodes[0].getblockcount()-1), 16)
307307
height = self.nodes[0].getblockcount()
308308
for i in range(2):
309-
block = create_block(tip, create_coinbase(height), height, cur_time)
309+
block = create_block(tip, create_coinbase(height), cur_time)
310310
block.nVersion = 3
311311
block.rehash()
312312
block.solve()
@@ -361,7 +361,7 @@ def test_bip68_not_consensus(self):
361361

362362
# make a block that violates bip68; ensure that the tip updates
363363
tip = int(self.nodes[0].getbestblockhash(), 16)
364-
block = create_block(tip, create_coinbase(self.nodes[0].getblockcount()+1), self.nodes[0].getblockcount()+1)
364+
block = create_block(tip, create_coinbase(self.nodes[0].getblockcount()+1))
365365
block.nVersion = 3
366366
block.vtx.extend([tx1, tx2, tx3])
367367
block.hashMerkleRoot = block.calc_merkle_root()

test/functional/feature_block.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,11 +1245,11 @@ def next_block(self, number, spend=None, additional_coinbase_value=0, script=CSc
12451245
coinbase.vout[0].nValue += additional_coinbase_value
12461246
coinbase.rehash()
12471247
if spend is None:
1248-
block = create_block(base_block_hash, coinbase, height, block_time)
1248+
block = create_block(base_block_hash, coinbase, block_time)
12491249
else:
12501250
coinbase.vout[0].nValue += spend.vout[0].nValue - 1 # all but one satoshi to fees
12511251
coinbase.rehash()
1252-
block = create_block(base_block_hash, coinbase, height, block_time)
1252+
block = create_block(base_block_hash, coinbase, block_time)
12531253
tx = self.create_tx(spend, 0, 1, script) # spend 1 satoshi
12541254
self.sign_tx(tx, spend)
12551255
self.add_transactions_to_block(block, [tx])

test/functional/feature_cltv.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def run_test(self):
7373

7474
tip = self.nodes[0].getbestblockhash()
7575
block_time = self.nodes[0].getblockheader(tip)['mediantime'] + 1
76-
block = create_block(int(tip, 16), create_coinbase(CLTV_HEIGHT - 1), CLTV_HEIGHT-1, block_time)
76+
block = create_block(int(tip, 16), create_coinbase(CLTV_HEIGHT - 1), block_time)
7777
block.nVersion = 3
7878
block.vtx.append(spendtx)
7979
block.hashMerkleRoot = block.calc_merkle_root()
@@ -85,7 +85,7 @@ def run_test(self):
8585
self.log.info("Test that blocks must now be at least version 4")
8686
tip = block.sha256
8787
block_time += 1
88-
block = create_block(tip, create_coinbase(CLTV_HEIGHT), CLTV_HEIGHT, block_time)
88+
block = create_block(tip, create_coinbase(CLTV_HEIGHT), block_time)
8989
block.nVersion = 3
9090
block.solve()
9191
self.nodes[0].p2p.send_and_ping(msg_block(block))

test/functional/feature_csv_activation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def generate_blocks(self, number, version, test_blocks=None):
157157
return test_blocks
158158

159159
def create_test_block(self, txs, version=536870912):
160-
block = create_block(self.tip, create_coinbase(self.tipheight + 1), self.tipheight + 1, self.last_block_time + 600)
160+
block = create_block(self.tip, create_coinbase(self.tipheight + 1), self.last_block_time + 600)
161161
block.nVersion = version
162162
block.vtx.extend(txs)
163163
block.hashMerkleRoot = block.calc_merkle_root()

test/functional/feature_nulldummy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def run_test(self):
9898

9999

100100
def block_submit(self, node, txs, witness = False, accept = False):
101-
block = create_block(self.tip, create_coinbase(self.lastblockheight + 1), self.lastblockheight + 1, self.lastblocktime + 1)
101+
block = create_block(self.tip, create_coinbase(self.lastblockheight + 1), self.lastblocktime + 1)
102102
block.nVersion = 4
103103
for tx in txs:
104104
tx.rehash()

test/functional/feature_versionbits_warning.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def send_blocks_with_version(self, peer, numblocks, version):
4747
tip = int(tip, 16)
4848

4949
for _ in range(numblocks):
50-
block = create_block(tip, create_coinbase(height + 1), height+1, block_time)
50+
block = create_block(tip, create_coinbase(height + 1), block_time)
5151
block.nVersion = version
5252
block.solve()
5353
peer.send_message(msg_block(block))

test/functional/p2p_compactblocks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def build_block_on_tip(self, node, segwit=False):
106106
height = node.getblockcount()
107107
tip = node.getbestblockhash()
108108
mtp = node.getblockheader(tip)['mediantime']
109-
block = create_block(int(tip, 16), create_coinbase(height + 1), height+1, mtp + 1)
109+
block = create_block(int(tip, 16), create_coinbase(height + 1), mtp + 1)
110110
block.nVersion = 4
111111
if segwit:
112112
add_witness_commitment(block)

test/functional/p2p_fingerprint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def build_chain(self, nblocks, prev_hash, prev_height, prev_median_time):
3636
for _ in range(nblocks):
3737
coinbase = create_coinbase(prev_height + 1)
3838
block_time = prev_median_time + 1
39-
block = create_block(int(prev_hash, 16), coinbase, prev_height + 1, block_time)
39+
block = create_block(int(prev_hash, 16), coinbase, block_time)
4040
block.solve()
4141

4242
blocks.append(block)

0 commit comments

Comments
 (0)