Merge bitcoin/bitcoin#36748: test: Small test sync fixups
What changed, and why it matters
This commit only changes Bitcoin Core's internal test scripts. It simplifies how tests create transactions and blocks, and removes a couple of unnecessary synchronization steps. There is no change to the actual Bitcoin node software that users run, so it cannot affect live networks, wallets, or funds.
No security action needed. Treat as ordinary test maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The merge commit updates three functional test files: feature_io_errors.py, p2p_segwit.py, and rpc_rawtransaction.py. It replaces manual two-step self-transfers with wallet.send_self_transfer_chain, removes redundant self.sync_blocks() calls, and switches one test from manually creating/solving a block template to using generateblock(…, submit=False). These are refactorings inside the test framework only; no consensus, networking, RPC, or wallet production code is modified.
Changed components
test/functional/feature_io_errors.pytest/functional/p2p_segwit.pytest/functional/rpc_rawtransaction.pyInspect captured patch +4 / −13
### test/functional/feature_io_errors.py
@@ -24,12 +24,10 @@ def set_test_params(self):
def test_blk_dat_io_error(self):
node = self.nodes[0]
self.restart_node(0, ["-txindex", "-rest"])
- self.wait_until(lambda: node.getindexinfo()["txindex"]["synced"])
wallet = MiniWallet(node)
- tx = wallet.send_self_transfer(from_node=node)
+ tx, tx2 = wallet.send_self_transfer_chain(from_node=node, chain_length=2)
txid = tx["txid"]
- tx2 = wallet.send_self_transfer(from_node=node, utxo_to_spend=tx["new_utxo"])
self.generate(node, 1)
psbt = node.createpsbt(inputs=[{"txid": txid, "vout": 0}], outputs=[])
### test/functional/p2p_segwit.py
@@ -1340,7 +1340,6 @@ def test_segwit_versions(self):
for i in range(NUM_SEGWIT_VERSIONS):
self.utxo.append(UTXO(tx.txid_int, i, split_value))
- self.sync_blocks()
temp_utxo = []
tx = CTransaction()
witness_script = CScript([OP_TRUE])
@@ -1848,7 +1847,6 @@ def test_non_standard_witness(self):
self.generate(self.nodes[0], 1) # Mine and clean up the mempool of non-standard node
# Valid but non-standard transactions in a block should be accepted by standard node
- self.sync_blocks()
assert_equal(len(self.nodes[0].getrawmempool()), 0)
assert_equal(len(self.nodes[1].getrawmempool()), 0)
### test/functional/rpc_rawtransaction.py
@@ -16,10 +16,6 @@
from decimal import Decimal
from itertools import product
-from test_framework.blocktools import (
- NORMAL_GBT_REQUEST_PARAMS,
- create_block,
-)
from test_framework.messages import (
MAX_BIP125_RBF_SEQUENCE,
COIN,
@@ -98,11 +94,10 @@ def run_test(self):
def test_getrawtransaction_block_data_errors(self):
node = self.nodes[0]
self.log.info("Test getrawtransaction with a header-only block")
- block = create_block(tmpl=node.getblocktemplate(NORMAL_GBT_REQUEST_PARAMS))
- block.solve()
- node.submitheader(block.serialize()[:80].hex())
+ block = self.generateblock(node, output="raw(55)", transactions=[], submit=False)
+ node.submitheader(block["hex"][:160])
- assert_raises_rpc_error(-1, "Block not available (not fully downloaded)", node.getrawtransaction, txid="a" * 64, blockhash=block.hash_hex)
+ assert_raises_rpc_error(-1, "Block not available (not fully downloaded)", node.getrawtransaction, txid="a" * 64, blockhash=block["hash"])
self.log.info("Test getrawtransaction when block data cannot be read")
blk_dat = node.blocks_path / "blk00000.dat"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.