v29.4-roots.1 · Commit 7: [PATCH 07/13] 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. Before is on the left; after is on the right. Unified view fits narrow screens more easily.
test/functional/feature_taproot.py
CHANGED
|
@@ -116,6 +116,9 @@ import hashlib
|
|
| 116 |
import os
|
| 117 |
import random
|
| 118 |
|
|
|
|
|
|
|
|
|
|
| 119 |
# Whether or not to output generated test vectors, in JSON format.
|
| 120 |
GEN_TEST_VECTORS = False
|
| 121 |
|
|
@@ -766,7 +769,7 @@ def spenders_taproot_active():
|
|
| 766 |
scripts = [
|
| 767 |
("pk_codesep", CScript(random_checksig_style(pubs[1]) + bytes([OP_CODESEPARATOR]))), # codesep after checksig
|
| 768 |
("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
|
| 770 |
# Note that the first data push in the "branched_codesep" script has the purpose of
|
| 771 |
# randomizing the sighash, both by varying script size and content. In order to
|
| 772 |
# avoid MINIMALDATA script verification errors caused by not-minimal-encoded data
|
|
@@ -1072,7 +1075,7 @@ def spenders_taproot_active():
|
|
| 1072 |
# Test that an input stack size of 1000 elements is permitted, but 1001 isn't.
|
| 1073 |
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 |
# 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)
|
| 1076 |
# Test that 999-of-999 multisig works (but 1000-of-1000 triggers stack size limits)
|
| 1077 |
add_spender(spenders, "tapscript/bigmulti", leaf="t33", **common, inputs=big_spend_inputs, num=999, failure={"leaf": "t34", "num": 1000}, **ERR_STACK_SIZE)
|
| 1078 |
# Test that the CLEANSTACK rule is consensus critical in tapscript
|
|
@@ -1377,6 +1380,7 @@ class TaprootTest(BitcoinTestFramework):
|
|
| 1377 |
def set_test_params(self):
|
| 1378 |
self.num_nodes = 1
|
| 1379 |
self.setup_clean_chain = True
|
|
|
|
| 1380 |
|
| 1381 |
def block_submit(self, node, txs, msg, err_msg, cb_pubkey=None, fees=0, sigops_weight=0, witness=False, accept=False):
|
| 1382 |
|
|
@@ -1595,6 +1599,8 @@ class TaprootTest(BitcoinTestFramework):
|
|
| 1595 |
and (all(utxo.spender.is_standard for utxo in input_utxos)) # All inputs must be standard
|
| 1596 |
and tx.version in TX_STANDARD_VERSIONS # The tx version must be standard
|
| 1597 |
and not (tx.version == 3 and tx.get_vsize() > TRUC_MAX_VSIZE) # Topological standardness rules must be followed
|
|
|
|
|
|
|
| 1598 |
)
|
| 1599 |
tx.rehash()
|
| 1600 |
msg = ','.join(utxo.spender.comment + ("*" if n == fail_input else "") for n, utxo in enumerate(input_utxos))
|
|
|
|
| 116 |
import os
|
| 117 |
import random
|
| 118 |
|
| 119 |
+
# Keep in sync with DEFAULT_SCRIPT_SIZE_POLICY_LIMIT in src/policy/policy.h.
|
| 120 |
+
ROOTS_DEFAULT_MAX_SCRIPT_SIZE = 1650
|
| 121 |
+
|
| 122 |
# Whether or not to output generated test vectors, in JSON format.
|
| 123 |
GEN_TEST_VECTORS = False
|
| 124 |
|
|
|
|
| 769 |
scripts = [
|
| 770 |
("pk_codesep", CScript(random_checksig_style(pubs[1]) + bytes([OP_CODESEPARATOR]))), # codesep after checksig
|
| 771 |
("codesep_pk", CScript(bytes([OP_CODESEPARATOR]) + random_checksig_style(pubs[1]))), # codesep before checksig
|
| 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
|
| 773 |
# Note that the first data push in the "branched_codesep" script has the purpose of
|
| 774 |
# randomizing the sighash, both by varying script size and content. In order to
|
| 775 |
# avoid MINIMALDATA script verification errors caused by not-minimal-encoded data
|
|
|
|
| 1075 |
# Test that an input stack size of 1000 elements is permitted, but 1001 isn't.
|
| 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)
|
| 1077 |
# Test that pushing a MAX_SCRIPT_ELEMENT_SIZE byte stack element is valid, but one longer is not.
|
| 1078 |
+
add_spender(spenders, "tapscript/pushmaxlimit", standard=False, leaf="t25", **common, **SINGLE_SIG, failure={"leaf": "t26"}, **ERR_PUSH_LIMIT)
|
| 1079 |
# Test that 999-of-999 multisig works (but 1000-of-1000 triggers stack size limits)
|
| 1080 |
add_spender(spenders, "tapscript/bigmulti", leaf="t33", **common, inputs=big_spend_inputs, num=999, failure={"leaf": "t34", "num": 1000}, **ERR_STACK_SIZE)
|
| 1081 |
# Test that the CLEANSTACK rule is consensus critical in tapscript
|
|
|
|
| 1380 |
def set_test_params(self):
|
| 1381 |
self.num_nodes = 1
|
| 1382 |
self.setup_clean_chain = True
|
| 1383 |
+
self.extra_args = [["-acceptnonstddatacarrier=1"]]
|
| 1384 |
|
| 1385 |
def block_submit(self, node, txs, msg, err_msg, cb_pubkey=None, fees=0, sigops_weight=0, witness=False, accept=False):
|
| 1386 |
|
|
|
|
| 1599 |
and (all(utxo.spender.is_standard for utxo in input_utxos)) # All inputs must be standard
|
| 1600 |
and tx.version in TX_STANDARD_VERSIONS # The tx version must be standard
|
| 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)
|
| 1604 |
)
|
| 1605 |
tx.rehash()
|
| 1606 |
msg = ','.join(utxo.spender.comment + ("*" if n == fail_input else "") for n, utxo in enumerate(input_utxos))
|