diff --git a/test/functional/interface_ipc_mining.py b/test/functional/interface_ipc_mining.py index 31ccec63fa8..1400a914e4b 100755 --- a/test/functional/interface_ipc_mining.py +++ b/test/functional/interface_ipc_mining.py @@ -7,7 +7,7 @@ import asyncio import time from contextlib import AsyncExitStack from io import BytesIO -from test_framework.blocktools import NULL_OUTPOINT +from test_framework.blocktools import NULL_OUTPOINT, script_BIP34_coinbase_height from test_framework.messages import ( MAX_BLOCK_WEIGHT, CBlockHeader, @@ -20,10 +20,6 @@ from test_framework.messages import ( from_hex, msg_headers, ) -from test_framework.script import ( - CScript, - CScriptNum, -) from test_framework.test_framework import BitcoinTestFramework from test_framework.util import ( assert_equal, @@ -79,8 +75,8 @@ class IPCMiningTest(BitcoinTestFramework): # Verify there's no dummy extraNonce in the coinbase scriptSig current_block_height = self.nodes[0].getchaintips()[0]["height"] - expected_scriptsig = CScript([CScriptNum(current_block_height + 1)]) - assert_equal(coinbase_res.scriptSigPrefix.hex(), expected_scriptsig.hex()) + bip34_prefix = script_BIP34_coinbase_height(current_block_height + 1, padding=False) + assert_equal(coinbase_res.scriptSigPrefix, bip34_prefix) # Typically a mining pool appends its name and an extraNonce coinbase_tx.vin[0].scriptSig = coinbase_res.scriptSigPrefix diff --git a/test/functional/test_framework/blocktools.py b/test/functional/test_framework/blocktools.py index 0a393d89024..529f07cd3c7 100644 --- a/test/functional/test_framework/blocktools.py +++ b/test/functional/test_framework/blocktools.py @@ -161,11 +161,13 @@ def add_witness_commitment(block, nonce=0): block.hashMerkleRoot = block.calc_merkle_root() -def script_BIP34_coinbase_height(height): +def script_BIP34_coinbase_height(height, *, padding=True): if height <= 16: res = CScriptOp.encode_op_n(height) - # Append dummy extraNonce to increase scriptSig size to 2 (see bad-cb-length consensus rule) - return CScript([res, OP_0]) + if padding: + # Append dummy extraNonce to increase scriptSig size to 2 (see bad-cb-length consensus rule) + return CScript([res, OP_0]) + return CScript([res]) return CScript([CScriptNum(height)])