6
6
7
7
Connect to a single node.
8
8
Generate 2 blocks (save the coinbases for later).
9
- Generate 427 more blocks.
10
- [Policy/Consensus] Check that NULLDUMMY compliant transactions are accepted in the 430th block .
9
+ Generate COINBASE_MATURITY (CB) more blocks to ensure the coinbases are mature .
10
+ [Policy/Consensus] Check that NULLDUMMY compliant transactions are accepted in block CB + 3 .
11
11
[Policy] Check that non-NULLDUMMY transactions are rejected before activation.
12
- [Consensus] Check that the new NULLDUMMY rules are not enforced on the 431st block .
13
- [Policy/Consensus] Check that the new NULLDUMMY rules are enforced on the 432nd block .
12
+ [Consensus] Check that the new NULLDUMMY rules are not enforced on block CB + 4 .
13
+ [Policy/Consensus] Check that the new NULLDUMMY rules are enforced on block CB + 5 .
14
14
"""
15
15
import time
16
16
20
20
from test_framework .test_framework import BitcoinTestFramework
21
21
from test_framework .util import assert_equal , assert_raises_rpc_error
22
22
23
+ COINBASE_MATURITY = 427
23
24
NULLDUMMY_ERROR = "non-mandatory-script-verify-flag (Dummy CHECKMULTISIG argument must be zero)"
24
25
25
26
def trueDummy (tx ):
@@ -43,7 +44,7 @@ def set_test_params(self):
43
44
# This script tests NULLDUMMY activation, which is part of the 'segwit' deployment, so we go through
44
45
# normal segwit activation here (and don't use the default always-on behaviour).
45
46
self .extra_args = [[
46
- '-segwitheight=432 ' ,
47
+ f '-segwitheight={ COINBASE_MATURITY + 5 } ' ,
47
48
'-addresstype=legacy' ,
48
49
]] * 2
49
50
@@ -64,16 +65,16 @@ def run_test(self):
64
65
wmulti .importaddress (self .ms_address )
65
66
wmulti .importaddress (self .wit_ms_address )
66
67
67
- self .coinbase_blocks = self .nodes [0 ].generate (2 ) # Block 2
68
+ self .coinbase_blocks = self .nodes [0 ].generate (2 ) # block height = 2
68
69
coinbase_txid = []
69
70
for i in self .coinbase_blocks :
70
71
coinbase_txid .append (self .nodes [0 ].getblock (i )['tx' ][0 ])
71
- self .nodes [0 ].generate (427 ) # Block 429
72
+ self .nodes [0 ].generate (COINBASE_MATURITY ) # block height = COINBASE_MATURITY + 2
72
73
self .lastblockhash = self .nodes [0 ].getbestblockhash ()
73
- self .lastblockheight = 429
74
- self .lastblocktime = int (time .time ()) + 429
74
+ self .lastblockheight = COINBASE_MATURITY + 2
75
+ self .lastblocktime = int (time .time ()) + self . lastblockheight
75
76
76
- self .log .info ("Test 1: NULLDUMMY compliant base transactions should be accepted to mempool and mined before activation [430 ]" )
77
+ self .log .info (f "Test 1: NULLDUMMY compliant base transactions should be accepted to mempool and mined before activation [{ COINBASE_MATURITY + 3 } ]" )
77
78
test1txs = [create_transaction (self .nodes [0 ], coinbase_txid [0 ], self .ms_address , amount = 49 )]
78
79
txid1 = self .nodes [0 ].sendrawtransaction (test1txs [0 ].serialize_with_witness ().hex (), 0 )
79
80
test1txs .append (create_transaction (self .nodes [0 ], txid1 , self .ms_address , amount = 48 ))
@@ -87,7 +88,7 @@ def run_test(self):
87
88
trueDummy (test2tx )
88
89
assert_raises_rpc_error (- 26 , NULLDUMMY_ERROR , self .nodes [0 ].sendrawtransaction , test2tx .serialize_with_witness ().hex (), 0 )
89
90
90
- self .log .info ("Test 3: Non-NULLDUMMY base transactions should be accepted in a block before activation [431 ]" )
91
+ self .log .info (f "Test 3: Non-NULLDUMMY base transactions should be accepted in a block before activation [{ COINBASE_MATURITY + 4 } ]" )
91
92
self .block_submit (self .nodes [0 ], [test2tx ], False , True )
92
93
93
94
self .log .info ("Test 4: Non-NULLDUMMY base multisig transaction is invalid after activation" )
@@ -104,7 +105,7 @@ def run_test(self):
104
105
assert_raises_rpc_error (- 26 , NULLDUMMY_ERROR , self .nodes [0 ].sendrawtransaction , test5tx .serialize_with_witness ().hex (), 0 )
105
106
self .block_submit (self .nodes [0 ], [test5tx ], True )
106
107
107
- self .log .info ("Test 6: NULLDUMMY compliant base/witness transactions should be accepted to mempool and in block after activation [432 ]" )
108
+ self .log .info (f "Test 6: NULLDUMMY compliant base/witness transactions should be accepted to mempool and in block after activation [{ COINBASE_MATURITY + 5 } ]" )
108
109
for i in test6txs :
109
110
self .nodes [0 ].sendrawtransaction (i .serialize_with_witness ().hex (), 0 )
110
111
self .block_submit (self .nodes [0 ], test6txs , True , True )
@@ -130,5 +131,6 @@ def block_submit(self, node, txs, witness=False, accept=False):
130
131
else :
131
132
assert_equal (node .getbestblockhash (), self .lastblockhash )
132
133
134
+
133
135
if __name__ == '__main__' :
134
136
NULLDUMMYTest ().main ()
0 commit comments