Skip to content

Commit 7fa9b58

Browse files
committed
Merge bitcoin/bitcoin#32841: feature_taproot: sample tx version border values more
4be81e9 feature_taproot: sample tx version border values more (Greg Sanders) Pull request description: Currently if the version 3 is selected for an otherwise standard spender, the test will fail. It's unlikely but possible, so change the test to update expectations and sample more aggressively on border values to instigate failures much quicker in the future if another version is made standard. ACKs for top commit: maflcko: lgtm ACK 4be81e9 darosior: ACK 4be81e9 Tree-SHA512: 53267a201aaa495bea9d624930a19e40af3633427b6715965f43b9e1a060b2c9f19c8b10c8168778349fa50715e44cb8e5e9d2ce477d5f324ca8ed28ff7996cd
2 parents fa33592 + 4be81e9 commit 7fa9b58

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

test/functional/feature_taproot.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,9 @@ def byte_popper(expr):
642642
DUST_LIMIT = 600
643643
MIN_FEE = 50000
644644

645+
TX_MAX_STANDARD_VERSION = 3
646+
TX_STANDARD_VERSIONS = [1, 2, TX_MAX_STANDARD_VERSION]
647+
645648
# === Actual test cases ===
646649

647650

@@ -1443,7 +1446,7 @@ def test_spenders(self, node, spenders, input_counts):
14431446
while left:
14441447
# Construct CTransaction with random version, nLocktime
14451448
tx = CTransaction()
1446-
tx.version = random.choice([1, 2, random.getrandbits(32)])
1449+
tx.version = random.choice(TX_STANDARD_VERSIONS + [0, TX_MAX_STANDARD_VERSION + 1, random.getrandbits(32)])
14471450
min_sequence = (tx.version != 1 and tx.version != 0) * 0x80000000 # The minimum sequence number to disable relative locktime
14481451
if random.choice([True, False]):
14491452
tx.nLockTime = random.randrange(LOCKTIME_THRESHOLD, self.lastblocktime - 7200) # all absolute locktimes in the past
@@ -1535,8 +1538,7 @@ def test_spenders(self, node, spenders, input_counts):
15351538
is_standard_tx = (
15361539
fail_input is None # Must be valid to be standard
15371540
and (all(utxo.spender.is_standard for utxo in input_utxos)) # All inputs must be standard
1538-
and tx.version >= 1 # The tx version must be standard
1539-
and tx.version <= 2)
1541+
and tx.version in TX_STANDARD_VERSIONS) # The tx version must be standard
15401542
msg = ','.join(utxo.spender.comment + ("*" if n == fail_input else "") for n, utxo in enumerate(input_utxos))
15411543
if is_standard_tx:
15421544
node.sendrawtransaction(tx.serialize().hex(), 0)

0 commit comments

Comments
 (0)