From 4be81e9746e9e18923386d6f4945a33885fd98a7 Mon Sep 17 00:00:00 2001 From: Greg Sanders Date: Mon, 30 Jun 2025 17:00:24 -0400 Subject: [PATCH] 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. --- test/functional/feature_taproot.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/functional/feature_taproot.py b/test/functional/feature_taproot.py index 04c2c951ca..bb07dea985 100755 --- a/test/functional/feature_taproot.py +++ b/test/functional/feature_taproot.py @@ -642,6 +642,9 @@ SIG_ADD_ZERO = {"failure": {"sign": zero_appender(default_sign)}} DUST_LIMIT = 600 MIN_FEE = 50000 +TX_MAX_STANDARD_VERSION = 3 +TX_STANDARD_VERSIONS = [1, 2, TX_MAX_STANDARD_VERSION] + # === Actual test cases === @@ -1443,7 +1446,7 @@ class TaprootTest(BitcoinTestFramework): while left: # Construct CTransaction with random version, nLocktime tx = CTransaction() - tx.version = random.choice([1, 2, random.getrandbits(32)]) + tx.version = random.choice(TX_STANDARD_VERSIONS + [0, TX_MAX_STANDARD_VERSION + 1, random.getrandbits(32)]) min_sequence = (tx.version != 1 and tx.version != 0) * 0x80000000 # The minimum sequence number to disable relative locktime if random.choice([True, False]): tx.nLockTime = random.randrange(LOCKTIME_THRESHOLD, self.lastblocktime - 7200) # all absolute locktimes in the past @@ -1535,8 +1538,7 @@ class TaprootTest(BitcoinTestFramework): is_standard_tx = ( fail_input is None # Must be valid to be standard and (all(utxo.spender.is_standard for utxo in input_utxos)) # All inputs must be standard - and tx.version >= 1 # The tx version must be standard - and tx.version <= 2) + and tx.version in TX_STANDARD_VERSIONS) # The tx version must be standard msg = ','.join(utxo.spender.comment + ("*" if n == fail_input else "") for n, utxo in enumerate(input_utxos)) if is_standard_tx: node.sendrawtransaction(tx.serialize().hex(), 0)