@@ -518,9 +518,9 @@ def random_checksig_style(pubkey):
518
518
"""Creates a random CHECKSIG* tapscript that would succeed with only the valid signature on witness stack."""
519
519
return bytes (CScript ([pubkey , OP_CHECKSIG ]))
520
520
opcode = random .choice ([OP_CHECKSIG , OP_CHECKSIGVERIFY , OP_CHECKSIGADD ])
521
- if ( opcode == OP_CHECKSIGVERIFY ) :
521
+ if opcode == OP_CHECKSIGVERIFY :
522
522
ret = CScript ([pubkey , opcode , OP_1 ])
523
- elif ( opcode == OP_CHECKSIGADD ) :
523
+ elif opcode == OP_CHECKSIGADD :
524
524
num = random .choice ([0 , 0x7fffffff , - 0x7fffffff ])
525
525
ret = CScript ([num , pubkey , opcode , num + 1 , OP_EQUAL ])
526
526
else :
@@ -1189,19 +1189,36 @@ def dump_witness(wit):
1189
1189
# Data type to keep track of UTXOs, where they were created, and how to spend them.
1190
1190
UTXOData = namedtuple ('UTXOData' , 'outpoint,output,spender' )
1191
1191
1192
+
1192
1193
class TaprootTest (BitcoinTestFramework ):
1193
1194
def add_options (self , parser ):
1194
1195
parser .add_argument ("--dumptests" , dest = "dump_tests" , default = False , action = "store_true" ,
1195
1196
help = "Dump generated test cases to directory set by TEST_DUMP_DIR environment variable" )
1197
+ parser .add_argument ("--previous_release" , dest = "previous_release" , default = False , action = "store_true" ,
1198
+ help = "Use a previous release as taproot-inactive node" )
1196
1199
1197
1200
def skip_test_if_missing_module (self ):
1198
1201
self .skip_if_no_wallet ()
1202
+ if self .options .previous_release :
1203
+ self .skip_if_no_previous_releases ()
1199
1204
1200
1205
def set_test_params (self ):
1201
1206
self .num_nodes = 2
1202
1207
self .setup_clean_chain = True
1203
1208
# Node 0 has Taproot inactive, Node 1 active.
1204
- self .extra_args = [["-par=1" , "-vbparams=taproot:1:1" ], ["-par=1" ]]
1209
+ self .extra_args = [["-par=1" ], ["-par=1" ]]
1210
+ if self .options .previous_release :
1211
+ self .wallet_names = [None , self .default_wallet_name ]
1212
+ else :
1213
+ self .extra_args [0 ].append ("-vbparams=taproot:1:1" )
1214
+
1215
+ def setup_nodes (self ):
1216
+ self .add_nodes (self .num_nodes , self .extra_args , versions = [
1217
+ 170200 if self .options .previous_release else None ,
1218
+ None ,
1219
+ ])
1220
+ self .start_nodes ()
1221
+ self .import_deterministic_coinbase_privkeys ()
1205
1222
1206
1223
def block_submit (self , node , txs , msg , err_msg , cb_pubkey = None , fees = 0 , sigops_weight = 0 , witness = False , accept = False ):
1207
1224
@@ -1223,7 +1240,7 @@ def block_submit(self, node, txs, msg, err_msg, cb_pubkey=None, fees=0, sigops_w
1223
1240
block_response = node .submitblock (block .serialize (True ).hex ())
1224
1241
if err_msg is not None :
1225
1242
assert block_response is not None and err_msg in block_response , "Missing error message '%s' from block response '%s': %s" % (err_msg , "(None)" if block_response is None else block_response , msg )
1226
- if ( accept ) :
1243
+ if accept :
1227
1244
assert node .getbestblockhash () == block .hash , "Failed to accept: %s (response: %s)" % (msg , block_response )
1228
1245
self .tip = block .sha256
1229
1246
self .lastblockhash = block .hash
@@ -1422,10 +1439,10 @@ def test_spenders(self, node, spenders, input_counts):
1422
1439
tx .rehash ()
1423
1440
msg = ',' .join (utxo .spender .comment + ("*" if n == fail_input else "" ) for n , utxo in enumerate (input_utxos ))
1424
1441
if is_standard_tx :
1425
- node .sendrawtransaction (tx .serialize ().hex (), 0 )
1442
+ node .sendrawtransaction (tx .serialize ().hex (), True if node . version else 0 )
1426
1443
assert node .getmempoolentry (tx .hash ) is not None , "Failed to accept into mempool: " + msg
1427
1444
else :
1428
- assert_raises_rpc_error (- 26 , None , node .sendrawtransaction , tx .serialize ().hex (), 0 )
1445
+ assert_raises_rpc_error (- 26 , None , node .sendrawtransaction , tx .serialize ().hex (), True if node . version else 0 )
1429
1446
# Submit in a block
1430
1447
self .block_submit (node , [tx ], msg , witness = True , accept = fail_input is None , cb_pubkey = cb_pubkey , fees = fee , sigops_weight = sigops_weight , err_msg = expected_fail_msg )
1431
1448
0 commit comments