2424from test_framework .messages import CTransaction
2525from test_framework .script import CScript
2626from test_framework .test_framework import BitcoinTestFramework
27- from test_framework .util import assert_equal , assert_raises_rpc_error
27+ from test_framework .util import (
28+ assert_equal ,
29+ assert_raises_rpc_error ,
30+ )
2831
2932NULLDUMMY_ERROR = "non-mandatory-script-verify-flag (Dummy CHECKMULTISIG argument must be zero)"
3033
@@ -86,36 +89,36 @@ def run_test(self):
8689 txid2 = self .nodes [0 ].sendrawtransaction (test1txs [1 ].serialize_with_witness ().hex (), 0 )
8790 test1txs .append (create_transaction (self .nodes [0 ], coinbase_txid [1 ], self .wit_ms_address , amount = 49 ))
8891 txid3 = self .nodes [0 ].sendrawtransaction (test1txs [2 ].serialize_with_witness ().hex (), 0 )
89- self .block_submit (self .nodes [0 ], test1txs , False , True )
92+ self .block_submit (self .nodes [0 ], test1txs , accept = True )
9093
9194 self .log .info ("Test 2: Non-NULLDUMMY base multisig transaction should not be accepted to mempool before activation" )
9295 test2tx = create_transaction (self .nodes [0 ], txid2 , self .ms_address , amount = 47 )
9396 trueDummy (test2tx )
9497 assert_raises_rpc_error (- 26 , NULLDUMMY_ERROR , self .nodes [0 ].sendrawtransaction , test2tx .serialize_with_witness ().hex (), 0 )
9598
9699 self .log .info (f"Test 3: Non-NULLDUMMY base transactions should be accepted in a block before activation [{ COINBASE_MATURITY + 4 } ]" )
97- self .block_submit (self .nodes [0 ], [test2tx ], False , True )
100+ self .block_submit (self .nodes [0 ], [test2tx ], accept = True )
98101
99102 self .log .info ("Test 4: Non-NULLDUMMY base multisig transaction is invalid after activation" )
100103 test4tx = create_transaction (self .nodes [0 ], test2tx .hash , self .address , amount = 46 )
101104 test6txs = [CTransaction (test4tx )]
102105 trueDummy (test4tx )
103106 assert_raises_rpc_error (- 26 , NULLDUMMY_ERROR , self .nodes [0 ].sendrawtransaction , test4tx .serialize_with_witness ().hex (), 0 )
104- self .block_submit (self .nodes [0 ], [test4tx ])
107+ self .block_submit (self .nodes [0 ], [test4tx ], accept = False )
105108
106109 self .log .info ("Test 5: Non-NULLDUMMY P2WSH multisig transaction invalid after activation" )
107110 test5tx = create_transaction (self .nodes [0 ], txid3 , self .wit_address , amount = 48 )
108111 test6txs .append (CTransaction (test5tx ))
109112 test5tx .wit .vtxinwit [0 ].scriptWitness .stack [0 ] = b'\x01 '
110113 assert_raises_rpc_error (- 26 , NULLDUMMY_ERROR , self .nodes [0 ].sendrawtransaction , test5tx .serialize_with_witness ().hex (), 0 )
111- self .block_submit (self .nodes [0 ], [test5tx ], True )
114+ self .block_submit (self .nodes [0 ], [test5tx ], with_witness = True , accept = False )
112115
113116 self .log .info (f"Test 6: NULLDUMMY compliant base/witness transactions should be accepted to mempool and in block after activation [{ COINBASE_MATURITY + 5 } ]" )
114117 for i in test6txs :
115118 self .nodes [0 ].sendrawtransaction (i .serialize_with_witness ().hex (), 0 )
116- self .block_submit (self .nodes [0 ], test6txs , True , True )
119+ self .block_submit (self .nodes [0 ], test6txs , with_witness = True , accept = True )
117120
118- def block_submit (self , node , txs , witness = False , accept = False ):
121+ def block_submit (self , node , txs , * , with_witness = False , accept ):
119122 tmpl = node .getblocktemplate (NORMAL_GBT_REQUEST_PARAMS )
120123 assert_equal (tmpl ['previousblockhash' ], self .lastblockhash )
121124 assert_equal (tmpl ['height' ], self .lastblockheight + 1 )
@@ -124,11 +127,12 @@ def block_submit(self, node, txs, witness=False, accept=False):
124127 tx .rehash ()
125128 block .vtx .append (tx )
126129 block .hashMerkleRoot = block .calc_merkle_root ()
127- witness and add_witness_commitment (block )
130+ if with_witness :
131+ add_witness_commitment (block )
128132 block .rehash ()
129133 block .solve ()
130134 assert_equal (None if accept else 'block-validation-failed' , node .submitblock (block .serialize ().hex ()))
131- if ( accept ) :
135+ if accept :
132136 assert_equal (node .getbestblockhash (), block .hash )
133137 self .lastblockhash = block .hash
134138 self .lastblocktime += 1
0 commit comments