v29.4-roots.2 · Commit 7: [PATCH 07/21] release: establish Roots maintenance and assurance
test/functional/feature_taproot.py
Before: test/functional/feature_taproot.py · After: test/functional/feature_taproot.py
File metadata
index 198bec7df5306b4c8ab634542670ebeb8d79ae4c..dd68e43008e17b82c18c99fd67b948210de9f552 100755
Download original patch · Release notes
Diff rows 1–40 of 40. Line numbers refer to the original before/after files.
+ Added− RemovedUnmarked lines are context.
Scroll the code area horizontally to read long lines. The two line-number columns refer to before and after.
test/functional/feature_taproot.py
CHANGED
|
@@ -116,6 +116,9 @@ import hashlib
|
|
|
116
116
|
import os
|
|
117
117
|
import random
|
|
118
118
|
|
|
119
|
+
# Keep in sync with DEFAULT_SCRIPT_SIZE_POLICY_LIMIT in src/policy/policy.h.
|
|
120
|
+
ROOTS_DEFAULT_MAX_SCRIPT_SIZE = 1650
|
|
121
|
+
|
|
119
122
|
# Whether or not to output generated test vectors, in JSON format.
|
|
120
123
|
GEN_TEST_VECTORS = False
|
|
121
124
|
|
|
@@ -766,7 +769,7 @@ def spenders_taproot_active():
|
|
|
766
769
|
scripts = [
|
|
767
770
|
("pk_codesep", CScript(random_checksig_style(pubs[1]) + bytes([OP_CODESEPARATOR]))), # codesep after checksig
|
|
768
771
|
("codesep_pk", CScript(bytes([OP_CODESEPARATOR]) + random_checksig_style(pubs[1]))), # codesep before checksig
|
|
769
|
-
("branched_codesep", CScript([random.randbytes(random.randrange(2, 511)), OP_DROP, OP_IF, OP_CODESEPARATOR, pubs[0], OP_ELSE, OP_CODESEPARATOR, pubs[1], OP_ENDIF, OP_CHECKSIG])), # branch dependent codesep
|
|
772
|
+
("branched_codesep", CScript([random.randbytes(random.randrange(2, 75)), OP_DROP, OP_IF, OP_CODESEPARATOR, pubs[0], OP_ELSE, OP_CODESEPARATOR, pubs[1], OP_ENDIF, OP_CHECKSIG])), # branch dependent codesep
|
|
770
773
|
# Note that the first data push in the "branched_codesep" script has the purpose of
|
|
771
774
|
# randomizing the sighash, both by varying script size and content. In order to
|
|
772
775
|
# avoid MINIMALDATA script verification errors caused by not-minimal-encoded data
|
|
@@ -1072,7 +1075,7 @@ def spenders_taproot_active():
|
|
|
1072
1075
|
# Test that an input stack size of 1000 elements is permitted, but 1001 isn't.
|
|
1073
1076
|
add_spender(spenders, "tapscript/1000inputs", leaf="t23", **common, inputs=[getter("sign")] + [b'' for _ in range(999)], failure={"leaf": "t24", "inputs": [getter("sign")] + [b'' for _ in range(1000)]}, **ERR_STACK_SIZE)
|
|
1074
1077
|
# Test that pushing a MAX_SCRIPT_ELEMENT_SIZE byte stack element is valid, but one longer is not.
|
|
1075
|
-
add_spender(spenders, "tapscript/pushmaxlimit", leaf="t25", **common, **SINGLE_SIG, failure={"leaf": "t26"}, **ERR_PUSH_LIMIT)
|
|
1078
|
+
add_spender(spenders, "tapscript/pushmaxlimit", standard=False, leaf="t25", **common, **SINGLE_SIG, failure={"leaf": "t26"}, **ERR_PUSH_LIMIT)
|
|
1076
1079
|
# Test that 999-of-999 multisig works (but 1000-of-1000 triggers stack size limits)
|
|
1077
1080
|
add_spender(spenders, "tapscript/bigmulti", leaf="t33", **common, inputs=big_spend_inputs, num=999, failure={"leaf": "t34", "num": 1000}, **ERR_STACK_SIZE)
|
|
1078
1081
|
# Test that the CLEANSTACK rule is consensus critical in tapscript
|
|
@@ -1377,6 +1380,7 @@ class TaprootTest(BitcoinTestFramework):
|
|
|
1377
1380
|
def set_test_params(self):
|
|
1378
1381
|
self.num_nodes = 1
|
|
1379
1382
|
self.setup_clean_chain = True
|
|
1383
|
+
self.extra_args = [["-acceptnonstddatacarrier=1"]]
|
|
1380
1384
|
|
|
1381
1385
|
def block_submit(self, node, txs, msg, err_msg, cb_pubkey=None, fees=0, sigops_weight=0, witness=False, accept=False):
|
|
1382
1386
|
|
|
@@ -1595,6 +1599,8 @@ class TaprootTest(BitcoinTestFramework):
|
|
|
1595
1599
|
and (all(utxo.spender.is_standard for utxo in input_utxos)) # All inputs must be standard
|
|
1596
1600
|
and tx.version in TX_STANDARD_VERSIONS # The tx version must be standard
|
|
1597
1601
|
and not (tx.version == 3 and tx.get_vsize() > TRUC_MAX_VSIZE) # Topological standardness rules must be followed
|
|
1602
|
+
# Roots applies -maxscriptsize to each serialized witness stack.
|
|
1603
|
+
and all(len(txin_witness.serialize()) <= ROOTS_DEFAULT_MAX_SCRIPT_SIZE for txin_witness in tx.wit.vtxinwit)
|
|
1598
1604
|
)
|
|
1599
1605
|
tx.rehash()
|
|
1600
1606
|
msg = ','.join(utxo.spender.comment + ("*" if n == fail_input else "") for n, utxo in enumerate(input_utxos))
|