test: Prevent loop from running out of utxos in bip68 test
What changed, and why it matters
This is a minor fix to a Bitcoin Core functional test, not to the main Bitcoin software. It moves an 'import random' statement to the top of the test file and changes one test helper to use a wallet-provided output script instead of a hardcoded one. There is no security issue in the production code and no vulnerability being patched.
No action required. This is a test-only maintenance change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies test/functional/feature_bip68_sequence.py only. It relocates ‘import random’ from inside a while loop to the module-level imports and replaces SCRIPT_W0_SH_OP_TRUE with self.wallet.get_output_script() when constructing a test transaction output. These are test-harness cleanups intended to prevent the test from running out of UTXOs and to use the wallet’s standard output script. No consensus, networking, or wallet runtime code is changed.
Changed components
test/functional/feature_bip68_sequence.pyInspect captured patch +2 / −2
diff --git a/test/functional/feature_bip68_sequence.py b/test/functional/feature_bip68_sequence.py
index 1bbc4b4a..86777795 100755
--- a/test/functional/feature_bip68_sequence.py
+++ b/test/functional/feature_bip68_sequence.py
@@ -4,6 +4,7 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test BIP68 implementation."""
+import random
import time
from test_framework.blocktools import (
@@ -130,7 +131,6 @@ class BIP68Test(BitcoinTestFramework):
# transactions.
max_outputs = 50
while len(self.wallet.get_utxos(include_immature_coinbase=False, mark_as_spent=False)) < 200:
- import random
num_outputs = random.randint(1, max_outputs)
self.wallet.send_self_transfer_multi(from_node=self.nodes[0], num_outputs=num_outputs)
self.generate(self.wallet, 1)
@@ -197,7 +197,7 @@ class BIP68Test(BitcoinTestFramework):
value += utxos[j]["value"]*COIN
# Overestimate the size of the tx - signatures should be less than 120 bytes, and leave 50 for the output
tx_size = len(tx.serialize().hex())//2 + 120*num_inputs + 50
- tx.vout.append(CTxOut(int(value - self.relayfee * tx_size * COIN / 1000), SCRIPT_W0_SH_OP_TRUE))
+ tx.vout.append(CTxOut(int(value - self.relayfee * tx_size * COIN / 1000), self.wallet.get_output_script()))
self.wallet.sign_tx(tx=tx)
if (using_sequence_locks and not should_pass):
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.