mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-27 22:34:18 +02:00
test: misc interface_ipc_mining.py improvements
- clarify run_ipc_option_override_test description: https://github.com/bitcoin/bitcoin/pull/33965#discussion_r2784515535 - trailing comma after includes: https://github.com/bitcoin/bitcoin/pull/34452#discussion_r2775183035 - include order: https://github.com/bitcoin/bitcoin/pull/34452#discussion_r2774730966 - reuse the shared miniwallet in the low block height test: https://github.com/bitcoin/bitcoin/pull/34860#discussion_r3255163123
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user