In commit "rpc: Enable wallet import on pruned nodes and add test" (f42c077a8f948f5c93b68eb1b7fa246b4f6475ef)
This new create_large_block seems very inflexible and also has a misleading name. Would drop it and instead just add a new option to create_coinbase like:
diff --git a/test/functional/feature_pruning.py b/test/functional/feature_pruning.py
index 8d72d11baf5..d14970c9463 100755
--- a/test/functional/feature_pruning.py
+++ b/test/functional/feature_pruning.py
@@ -10,7 +10,8 @@ This test takes 30 mins or more (up to 2 hours)
"""
import os
-from test_framework.blocktools import create_large_block
+from test_framework.blocktools import create_block
+from test_framework.blocktools import create_coinbase
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
@@ -47,7 +48,7 @@ def mine_large_blocks(node, n):
previousblockhash = int(best_block["hash"], 16)
for _ in range(n):
- block = create_large_block(hashprev=previousblockhash, height=height, ntime=mine_large_blocks.nTime, scriptPubKey=scriptPubKey)
+ block = create_block(hashprev=previousblockhash, ntime=mine_large_blocks.nTime, coinbase=create_coinbase(height, script_pubkey=scriptPubKey))
block.solve()
# Submit to the node
diff --git a/test/functional/test_framework/blocktools.py b/test/functional/test_framework/blocktools.py
index 5916ffc2b17..77653df96e9 100644
--- a/test/functional/test_framework/blocktools.py
+++ b/test/functional/test_framework/blocktools.py
@@ -87,13 +87,6 @@ def create_block(hashprev=None, coinbase=None, ntime=None, *, version=None, tmpl
block.calc_sha256()
return block
-def create_large_block(hashprev, ntime, height, scriptPubKey):
- coinbase_tx = create_coinbase(height)
- coinbase_tx.vout[0].scriptPubKey = scriptPubKey
- coinbase_tx.rehash()
-
- return create_block(coinbase=coinbase_tx, ntime=ntime, hashprev=hashprev)
-
def get_witness_script(witness_root, witness_nonce):
witness_commitment = uint256_from_str(hash256(ser_uint256(witness_root) + ser_uint256(witness_nonce)))
output_data = WITNESS_COMMITMENT_HEADER + ser_uint256(witness_commitment)
@@ -127,7 +120,7 @@ def script_BIP34_coinbase_height(height):
return CScript([CScriptNum(height)])
-def create_coinbase(height, pubkey=None, extra_output_script=None, fees=0, nValue=50):
+def create_coinbase(height, pubkey=None, *, script_pubkey=None, extra_output_script=None, fees=0, nValue=50):
"""Create a coinbase transaction.
If pubkey is passed in, the coinbase output will be a P2PK output;
@@ -145,6 +138,8 @@ def create_coinbase(height, pubkey=None, extra_output_script=None, fees=0, nValu
coinbaseoutput.nValue += fees
if pubkey is not None:
coinbaseoutput.scriptPubKey = key_to_p2pk_script(pubkey)
+ elif script_pubkey is not None:
+ coinbaseoutput.scriptPubKey = script_pubkey
else:
coinbaseoutput.scriptPubKey = CScript([OP_TRUE])
coinbase.vout = [coinbaseoutput]
diff --git a/test/functional/wallet_pruning.py b/test/functional/wallet_pruning.py
index 9b8160a4490..e42994422e0 100755
--- a/test/functional/wallet_pruning.py
+++ b/test/functional/wallet_pruning.py
@@ -7,7 +7,8 @@
import os
from test_framework.util import assert_raises_rpc_error
-from test_framework.blocktools import create_large_block
+from test_framework.blocktools import create_block
+from test_framework.blocktools import create_coinbase
from test_framework.test_framework import BitcoinTestFramework
from test_framework.script import (
@@ -26,7 +27,7 @@ class WalletPruningTest(BitcoinTestFramework):
self.nTime = max(self.nTime, int(best_block["time"])) + 1
previousblockhash = int(best_block["hash"], 16)
for _ in range(n):
- block = create_large_block(hashprev=previousblockhash, height=height, ntime=self.nTime, scriptPubKey=self.scriptPubKey)
+ block = create_block(hashprev=previousblockhash, ntime=self.nTime, coinbase=create_coinbase(height, script_pubkey=self.scriptPubKey))
block.solve()
# Submit to the node