@@ -518,9 +518,9 @@ def add_spender(spenders, *args, **kwargs):
518
518
def random_checksig_style (pubkey ):
519
519
"""Creates a random CHECKSIG* tapscript that would succeed with only the valid signature on witness stack."""
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
+ 200100 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 ().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
0 commit comments