Skip to content

Commit 9f3690b

Browse files
instagibbsfanquake
authored andcommitted
feature_taproot: sample tx version border values more
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. Github-Pull: #32841 Rebased-From: 4be81e9
1 parent 8a4a938 commit 9f3690b

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
@@ -641,6 +641,9 @@ def byte_popper(expr):
641641
DUST_LIMIT = 600
642642
MIN_FEE = 50000
643643

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

646649

@@ -1409,7 +1412,7 @@ def test_spenders(self, node, spenders, input_counts):
14091412
while left:
14101413
# Construct CTransaction with random version, nLocktime
14111414
tx = CTransaction()
1412-
tx.version = random.choice([1, 2, random.getrandbits(32)])
1415+
tx.version = random.choice(TX_STANDARD_VERSIONS + [0, TX_MAX_STANDARD_VERSION + 1, random.getrandbits(32)])
14131416
min_sequence = (tx.version != 1 and tx.version != 0) * 0x80000000 # The minimum sequence number to disable relative locktime
14141417
if random.choice([True, False]):
14151418
tx.nLockTime = random.randrange(LOCKTIME_THRESHOLD, self.lastblocktime - 7200) # all absolute locktimes in the past
@@ -1501,8 +1504,7 @@ def test_spenders(self, node, spenders, input_counts):
15011504
is_standard_tx = (
15021505
fail_input is None # Must be valid to be standard
15031506
and (all(utxo.spender.is_standard for utxo in input_utxos)) # All inputs must be standard
1504-
and tx.version >= 1 # The tx version must be standard
1505-
and tx.version <= 2)
1507+
and tx.version in TX_STANDARD_VERSIONS) # The tx version must be standard
15061508
tx.rehash()
15071509
msg = ','.join(utxo.spender.comment + ("*" if n == fail_input else "") for n, utxo in enumerate(input_utxos))
15081510
if is_standard_tx:

0 commit comments

Comments
 (0)