66
77from test_framework .blocktools import create_block , create_coinbase
88from test_framework .messages import COIN , COutPoint , CTransaction , CTxIn , CTxOut , FromHex , ToHex
9- from test_framework .script import CScript
109from test_framework .test_framework import BitcoinTestFramework
11- from test_framework .util import assert_equal , assert_greater_than , assert_raises_rpc_error , get_bip9_status , satoshi_round
10+ from test_framework .util import (
11+ assert_equal ,
12+ assert_greater_than ,
13+ assert_raises_rpc_error ,
14+ get_bip9_status ,
15+ satoshi_round
16+ )
17+ from test_framework .script_util import DUMMY_P2SH_SCRIPT
1218
1319SEQUENCE_LOCKTIME_DISABLE_FLAG = (1 << 31 )
1420SEQUENCE_LOCKTIME_TYPE_FLAG = (1 << 22 ) # this means use time (0 means height)
@@ -76,7 +82,7 @@ def test_disable_flag(self):
7682 # input to mature.
7783 sequence_value = SEQUENCE_LOCKTIME_DISABLE_FLAG | 1
7884 tx1 .vin = [CTxIn (COutPoint (int (utxo ["txid" ], 16 ), utxo ["vout" ]), nSequence = sequence_value )]
79- tx1 .vout = [CTxOut (value , CScript ([ b'a' ]) )]
85+ tx1 .vout = [CTxOut (value , DUMMY_P2SH_SCRIPT )]
8086
8187 tx1_signed = self .nodes [0 ].signrawtransactionwithwallet (ToHex (tx1 ))["hex" ]
8288 tx1_id = self .nodes [0 ].sendrawtransaction (tx1_signed )
@@ -88,7 +94,7 @@ def test_disable_flag(self):
8894 tx2 .nVersion = 2
8995 sequence_value = sequence_value & 0x7fffffff
9096 tx2 .vin = [CTxIn (COutPoint (tx1_id , 0 ), nSequence = sequence_value )]
91- tx2 .vout = [CTxOut (int (value - self .relayfee * COIN ), CScript ([ b'a' * 35 ]) )]
97+ tx2 .vout = [CTxOut (int (value - self .relayfee * COIN ), DUMMY_P2SH_SCRIPT )]
9298 tx2 .rehash ()
9399
94100 assert_raises_rpc_error (- 26 , NOT_FINAL_ERROR , self .nodes [0 ].sendrawtransaction , ToHex (tx2 ))
@@ -183,7 +189,7 @@ def test_sequence_lock_confirmed_inputs(self):
183189 value += utxos [j ]["amount" ]* COIN
184190 # Overestimate the size of the tx - signatures should be less than 120 bytes, and leave 50 for the output
185191 tx_size = len (ToHex (tx ))// 2 + 120 * num_inputs + 50
186- tx .vout .append (CTxOut (int (value - self .relayfee * tx_size * COIN / 1000 ), CScript ([ b'a' ]) ))
192+ tx .vout .append (CTxOut (int (value - self .relayfee * tx_size * COIN / 1000 ), DUMMY_P2SH_SCRIPT ))
187193 rawtx = self .nodes [0 ].signrawtransactionwithwallet (ToHex (tx ))["hex" ]
188194
189195 if (using_sequence_locks and not should_pass ):
@@ -212,7 +218,7 @@ def test_sequence_lock_unconfirmed_inputs(self):
212218 tx2 = CTransaction ()
213219 tx2 .nVersion = 2
214220 tx2 .vin = [CTxIn (COutPoint (tx1 .sha256 , 0 ), nSequence = 0 )]
215- tx2 .vout = [CTxOut (int (tx1 .vout [0 ].nValue - self .relayfee * COIN ), CScript ([ b'a' ]) )]
221+ tx2 .vout = [CTxOut (int (tx1 .vout [0 ].nValue - self .relayfee * COIN ), DUMMY_P2SH_SCRIPT )]
216222 tx2_raw = self .nodes [0 ].signrawtransactionwithwallet (ToHex (tx2 ))["hex" ]
217223 tx2 = FromHex (tx2 , tx2_raw )
218224 tx2 .rehash ()
@@ -230,7 +236,7 @@ def test_nonzero_locks(orig_tx, node, relayfee, use_height_lock):
230236 tx = CTransaction ()
231237 tx .nVersion = 2
232238 tx .vin = [CTxIn (COutPoint (orig_tx .sha256 , 0 ), nSequence = sequence_value )]
233- tx .vout = [CTxOut (int (orig_tx .vout [0 ].nValue - relayfee * COIN ), CScript ([ b'a' * 35 ]) )]
239+ tx .vout = [CTxOut (int (orig_tx .vout [0 ].nValue - relayfee * COIN ), DUMMY_P2SH_SCRIPT )]
234240 tx .rehash ()
235241
236242 if (orig_tx .hash in node .getrawmempool ()):
@@ -343,7 +349,7 @@ def test_bip68_not_consensus(self):
343349 tx2 = CTransaction ()
344350 tx2 .nVersion = 1
345351 tx2 .vin = [CTxIn (COutPoint (tx1 .sha256 , 0 ), nSequence = 0 )]
346- tx2 .vout = [CTxOut (int (tx1 .vout [0 ].nValue - self .relayfee * COIN ), CScript ([ b'a' ]) )]
352+ tx2 .vout = [CTxOut (int (tx1 .vout [0 ].nValue - self .relayfee * COIN ), DUMMY_P2SH_SCRIPT )]
347353
348354 # sign tx2
349355 tx2_raw = self .nodes [0 ].signrawtransactionwithwallet (ToHex (tx2 ))["hex" ]
@@ -358,7 +364,7 @@ def test_bip68_not_consensus(self):
358364 tx3 = CTransaction ()
359365 tx3 .nVersion = 2
360366 tx3 .vin = [CTxIn (COutPoint (tx2 .sha256 , 0 ), nSequence = sequence_value )]
361- tx3 .vout = [CTxOut (int (tx2 .vout [0 ].nValue - self .relayfee * COIN ), CScript ([ b'a' * 35 ]) )]
367+ tx3 .vout = [CTxOut (int (tx2 .vout [0 ].nValue - self .relayfee * COIN ), DUMMY_P2SH_SCRIPT )]
362368 tx3 .rehash ()
363369
364370 assert_raises_rpc_error (- 26 , NOT_FINAL_ERROR , self .nodes [0 ].sendrawtransaction , ToHex (tx3 ))
0 commit comments