@@ -198,7 +198,7 @@ def set_test_params(self):
198
198
self .num_nodes = 2
199
199
# This test tests SegWit both pre and post-activation, so use the normal BIP9 activation.
200
200
self .extra_args = [
201
- [
"-acceptnonstdtxn=1" ,
f"-testactivationheight=segwit@{ SEGWIT_HEIGHT } " ,
"[email protected] " ],
201
+ [
"-acceptnonstdtxn=1" ,
f"-testactivationheight=segwit@{ SEGWIT_HEIGHT } " ,
"[email protected] " , "-par=1" ],
202
202
["-acceptnonstdtxn=0" , f"-testactivationheight=segwit@{ SEGWIT_HEIGHT } " ],
203
203
]
204
204
self .supports_cli = False
@@ -509,8 +509,8 @@ def test_v0_outputs_arent_spendable(self):
509
509
# 'block-validation-failed' (if script check threads > 1) or
510
510
# 'non-mandatory-script-verify-flag (Witness program was passed an
511
511
# empty witness)' (otherwise).
512
- # TODO: support multiple acceptable reject reasons.
513
- test_witness_block ( self . nodes [ 0 ], self . test_node , block , accepted = False , with_witness = False )
512
+ test_witness_block ( self . nodes [ 0 ], self . test_node , block , accepted = False , with_witness = False ,
513
+ reason = 'non-mandatory-script-verify-flag (Witness program was passed an empty witness)' )
514
514
515
515
self .utxo .pop (0 )
516
516
self .utxo .append (UTXO (txid , 2 , value ))
@@ -993,7 +993,8 @@ def test_extra_witness_data(self):
993
993
self .update_witness_block_with_transactions (block , [tx ])
994
994
995
995
# Extra witness data should not be allowed.
996
- test_witness_block (self .nodes [0 ], self .test_node , block , accepted = False )
996
+ test_witness_block (self .nodes [0 ], self .test_node , block , accepted = False ,
997
+ reason = 'non-mandatory-script-verify-flag (Witness provided for non-witness script)' )
997
998
998
999
# Try extra signature data. Ok if we're not spending a witness output.
999
1000
block .vtx [1 ].wit .vtxinwit = []
@@ -1018,7 +1019,8 @@ def test_extra_witness_data(self):
1018
1019
self .update_witness_block_with_transactions (block , [tx2 ])
1019
1020
1020
1021
# This has extra witness data, so it should fail.
1021
- test_witness_block (self .nodes [0 ], self .test_node , block , accepted = False )
1022
+ test_witness_block (self .nodes [0 ], self .test_node , block , accepted = False ,
1023
+ reason = 'non-mandatory-script-verify-flag (Stack size must be exactly one after execution)' )
1022
1024
1023
1025
# Now get rid of the extra witness, but add extra scriptSig data
1024
1026
tx2 .vin [0 ].scriptSig = CScript ([OP_TRUE ])
@@ -1030,7 +1032,8 @@ def test_extra_witness_data(self):
1030
1032
block .solve ()
1031
1033
1032
1034
# This has extra signature data for a witness input, so it should fail.
1033
- test_witness_block (self .nodes [0 ], self .test_node , block , accepted = False )
1035
+ test_witness_block (self .nodes [0 ], self .test_node , block , accepted = False ,
1036
+ reason = 'non-mandatory-script-verify-flag (Witness requires empty scriptSig)' )
1034
1037
1035
1038
# Now get rid of the extra scriptsig on the witness input, and verify
1036
1039
# success (even with extra scriptsig data in the non-witness input)
@@ -1068,7 +1071,8 @@ def test_max_witness_push_length(self):
1068
1071
tx2 .rehash ()
1069
1072
1070
1073
self .update_witness_block_with_transactions (block , [tx , tx2 ])
1071
- test_witness_block (self .nodes [0 ], self .test_node , block , accepted = False )
1074
+ test_witness_block (self .nodes [0 ], self .test_node , block , accepted = False ,
1075
+ reason = 'non-mandatory-script-verify-flag (Push value size limit exceeded)' )
1072
1076
1073
1077
# Now reduce the length of the stack element
1074
1078
tx2 .wit .vtxinwit [0 ].scriptWitness .stack [0 ] = b'a' * (MAX_SCRIPT_ELEMENT_SIZE )
@@ -1108,7 +1112,8 @@ def test_max_witness_script_length(self):
1108
1112
1109
1113
self .update_witness_block_with_transactions (block , [tx , tx2 ])
1110
1114
1111
- test_witness_block (self .nodes [0 ], self .test_node , block , accepted = False )
1115
+ test_witness_block (self .nodes [0 ], self .test_node , block , accepted = False ,
1116
+ reason = 'non-mandatory-script-verify-flag (Script is too big)' )
1112
1117
1113
1118
# Try again with one less byte in the witness script
1114
1119
witness_script = CScript ([b'a' * MAX_SCRIPT_ELEMENT_SIZE ] * 19 + [OP_DROP ] * 62 + [OP_TRUE ])
@@ -1188,6 +1193,8 @@ def serialize_with_witness(self):
1188
1193
1189
1194
block .vtx = [block .vtx [0 ]]
1190
1195
self .update_witness_block_with_transactions (block , [tx2 ])
1196
+ # This block doesn't result in a specific reject reason, but an iostream exception:
1197
+ # "Exception 'CDataStream::read(): end of data: unspecified iostream_category error' (...) caught"
1191
1198
test_witness_block (self .nodes [0 ], self .test_node , block , accepted = False )
1192
1199
1193
1200
# Now make one of the intermediate witnesses be incorrect
@@ -1197,7 +1204,8 @@ def serialize_with_witness(self):
1197
1204
1198
1205
block .vtx = [block .vtx [0 ]]
1199
1206
self .update_witness_block_with_transactions (block , [tx2 ])
1200
- test_witness_block (self .nodes [0 ], self .test_node , block , accepted = False )
1207
+ test_witness_block (self .nodes [0 ], self .test_node , block , accepted = False ,
1208
+ reason = 'non-mandatory-script-verify-flag (Operation not valid with the current stack size)' )
1201
1209
1202
1210
# Fix the broken witness and the block should be accepted.
1203
1211
tx2 .wit .vtxinwit [5 ].scriptWitness .stack = [b'a' , witness_script ]
@@ -1568,13 +1576,17 @@ def test_signature_version_1(self):
1568
1576
# Too-large input value
1569
1577
sign_p2pk_witness_input (witness_script , tx , 0 , hashtype , prev_utxo .nValue + 1 , key )
1570
1578
self .update_witness_block_with_transactions (block , [tx ])
1571
- test_witness_block (self .nodes [0 ], self .test_node , block , accepted = False )
1579
+ test_witness_block (self .nodes [0 ], self .test_node , block , accepted = False ,
1580
+ reason = 'non-mandatory-script-verify-flag (Script evaluated without error '
1581
+ 'but finished with a false/empty top stack element' )
1572
1582
1573
1583
# Too-small input value
1574
1584
sign_p2pk_witness_input (witness_script , tx , 0 , hashtype , prev_utxo .nValue - 1 , key )
1575
1585
block .vtx .pop () # remove last tx
1576
1586
self .update_witness_block_with_transactions (block , [tx ])
1577
- test_witness_block (self .nodes [0 ], self .test_node , block , accepted = False )
1587
+ test_witness_block (self .nodes [0 ], self .test_node , block , accepted = False ,
1588
+ reason = 'non-mandatory-script-verify-flag (Script evaluated without error '
1589
+ 'but finished with a false/empty top stack element' )
1578
1590
1579
1591
# Now try correct value
1580
1592
sign_p2pk_witness_input (witness_script , tx , 0 , hashtype , prev_utxo .nValue , key )
@@ -1676,7 +1688,8 @@ def test_signature_version_1(self):
1676
1688
tx2 .vin [0 ].scriptSig = CScript ([signature , pubkey ])
1677
1689
block = self .build_next_block ()
1678
1690
self .update_witness_block_with_transactions (block , [tx , tx2 ])
1679
- test_witness_block (self .nodes [0 ], self .test_node , block , accepted = False )
1691
+ test_witness_block (self .nodes [0 ], self .test_node , block , accepted = False ,
1692
+ reason = 'non-mandatory-script-verify-flag (Witness requires empty scriptSig)' )
1680
1693
1681
1694
# Move the signature to the witness.
1682
1695
block .vtx .pop ()
0 commit comments