test: misc interface_ipc_mining.py improvements
What changed, and why it matters
This is a minor cleanup of a single Bitcoin Core test file. It reorders Python imports, adds a trailing comma, improves a code comment, and reuses an existing test wallet object instead of creating a new one. There is no change to production code and no security relevance.
No security action needed. This is a routine test-maintenance commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies only test/functional/interface_ipc_mining.py. Changes are stylistic/refactoring: import ordering and trailing comma in two import blocks, a clarified docstring/comment for run_ipc_option_override_test, and replacing a locally created MiniWallet with self.miniwallet in the low-block-height test. No consensus, networking, wallet, or IPC production logic is altered.
Changed components
test/functional/interface_ipc_mining.pyInspect captured patch +12 / −13
diff --git a/test/functional/interface_ipc_mining.py b/test/functional/interface_ipc_mining.py
index 2740662f..389b7f13 100755
--- a/test/functional/interface_ipc_mining.py
+++ b/test/functional/interface_ipc_mining.py
@@ -9,35 +9,35 @@ from contextlib import AsyncExitStack
from io import BytesIO
from test_framework.blocktools import NULL_OUTPOINT, script_BIP34_coinbase_height
from test_framework.messages import (
- MAX_BLOCK_WEIGHT,
CBlockHeader,
+ COIN,
CTransaction,
CTxIn,
- CTxOut,
CTxInWitness,
- ser_uint256,
- COIN,
+ CTxOut,
+ MAX_BLOCK_WEIGHT,
from_hex,
msg_headers,
+ ser_uint256,
)
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
assert_greater_than_or_equal,
- assert_not_equal
+ assert_not_equal,
)
from test_framework.wallet import MiniWallet
from test_framework.p2p import P2PInterface
from test_framework.ipc_util import (
+ assert_capnp_failed,
destroying,
- mining_create_block_template,
load_capnp_modules,
+ make_mining_ctx,
+ mining_create_block_template,
mining_get_block,
mining_get_coinbase_tx,
mining_wait_next_template,
wait_and_do,
- make_mining_ctx,
- assert_capnp_failed
)
# Test may be skipped and not have capnp installed
@@ -291,8 +291,9 @@ class IPCMiningTest(BitcoinTestFramework):
def run_ipc_option_override_test(self):
self.log.info("Running IPC option override test")
- # Set an absurd reserved weight. `-blockreservedweight` is RPC-only, so
- # with this setting RPC templates would be empty. IPC clients set
+ # Confirm that BlockCreateOptions.blockReservedWeight takes precedence
+ # over -blockreservedweight. Set an absurdly high -blockreservedweight
+ # value that would result in empty blocks to verify this. IPC clients set
# blockReservedWeight per template request and are unaffected; later in
# the test the IPC template includes a mempool transaction.
self.restart_node(0, extra_args=[f"-blockreservedweight={MAX_BLOCK_WEIGHT}"])
@@ -421,8 +422,6 @@ class IPCMiningTest(BitcoinTestFramework):
node.wait_for_rpc_connection()
assert_equal(node.getblockcount(), 0)
- miniwallet = MiniWallet(node)
-
async def async_routine():
ctx, mining = await make_mining_ctx(self)
opts = self.capnp_modules['mining'].BlockCreateOptions()
@@ -437,7 +436,7 @@ class IPCMiningTest(BitcoinTestFramework):
block = await mining_get_block(template, ctx)
# Heights <= 16 need extra nonce padding.
extra_nonce = b'\xaa\xbb\xcc\xdd' if height <= 16 else b""
- coinbase = await self.build_coinbase_test(template, ctx, miniwallet, extra_nonce=extra_nonce)
+ coinbase = await self.build_coinbase_test(template, ctx, self.miniwallet, extra_nonce=extra_nonce)
block.vtx[0] = coinbase
block.hashMerkleRoot = block.calc_merkle_root()
block.solve()
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.