@@ -24,10 +24,6 @@ def __init__(self):
2424 self .setup_clean_chain = True
2525 self .num_nodes = 3
2626
27- self .utxo = []
28- self .address = ["" ,"" ]
29- self .txouts = gen_return_txouts ()
30-
3127 def setup_network (self ):
3228 self .nodes = []
3329 self .is_network_split = False
@@ -40,12 +36,6 @@ def setup_network(self):
4036 self .nodes .append (start_node (2 , self .options .tmpdir , ["-debug" ,"-maxreceivebuffer=20000" ,"-prune=550" ], timewait = 900 ))
4137 self .prunedir = self .options .tmpdir + "/node2/regtest/blocks/"
4238
43- self .address [0 ] = self .nodes [0 ].getnewaddress ()
44- self .address [1 ] = self .nodes [1 ].getnewaddress ()
45-
46- # Determine default relay fee
47- self .relayfee = self .nodes [0 ].getnetworkinfo ()["relayfee" ]
48-
4939 connect_nodes (self .nodes [0 ], 1 )
5040 connect_nodes (self .nodes [1 ], 2 )
5141 connect_nodes (self .nodes [2 ], 0 )
@@ -58,7 +48,7 @@ def create_big_chain(self):
5848 self .nodes [0 ].generate (150 )
5949 # Then mine enough full blocks to create more than 550MiB of data
6050 for i in range (645 ):
61- self . mine_full_block (self .nodes [ 0 ], self . address [0 ])
51+ mine_large_block (self .nodes [0 ])
6252
6353 sync_blocks (self .nodes [0 :3 ])
6454
@@ -70,7 +60,7 @@ def test_height_min(self):
7060 print ("Mining 25 more blocks should cause the first block file to be pruned" )
7161 # Pruning doesn't run until we're allocating another chunk, 20 full blocks past the height cutoff will ensure this
7262 for i in range (25 ):
73- self . mine_full_block (self .nodes [ 0 ], self . address [0 ])
63+ mine_large_block (self .nodes [0 ])
7464
7565 waitstart = time .time ()
7666 while os .path .isfile (self .prunedir + "blk00000.dat" ):
@@ -95,17 +85,15 @@ def create_chain_with_staleblocks(self):
9585 stop_node (self .nodes [0 ],0 )
9686 self .nodes [0 ]= start_node (0 , self .options .tmpdir , ["-debug" ,"-maxreceivebuffer=20000" ,"-blockmaxsize=999000" , "-checkblocks=5" ], timewait = 900 )
9787 # Mine 24 blocks in node 1
98- self .utxo = self .nodes [1 ].listunspent ()
9988 for i in range (24 ):
10089 if j == 0 :
101- self . mine_full_block (self .nodes [ 1 ], self . address [1 ])
90+ mine_large_block (self .nodes [1 ])
10291 else :
10392 self .nodes [1 ].generate (1 ) #tx's already in mempool from previous disconnects
10493
10594 # Reorg back with 25 block chain from node 0
106- self .utxo = self .nodes [0 ].listunspent ()
10795 for i in range (25 ):
108- self . mine_full_block (self .nodes [ 0 ], self . address [0 ])
96+ mine_large_block (self .nodes [0 ])
10997
11098 # Create connections in the order so both nodes can see the reorg at the same time
11199 connect_nodes (self .nodes [1 ], 0 )
@@ -217,31 +205,6 @@ def reorg_back(self):
217205 # Verify we can now have the data for a block previously pruned
218206 assert (self .nodes [2 ].getblock (self .forkhash )["height" ] == self .forkheight )
219207
220- def mine_full_block (self , node , address ):
221- # Want to create a full block
222- # We'll generate a 66k transaction below, and 14 of them is close to the 1MB block limit
223- for j in range (14 ):
224- if len (self .utxo ) < 14 :
225- self .utxo = node .listunspent ()
226- inputs = []
227- outputs = {}
228- t = self .utxo .pop ()
229- inputs .append ({ "txid" : t ["txid" ], "vout" : t ["vout" ]})
230- remchange = t ["amount" ] - 100 * self .relayfee # Fee must be above min relay rate for 66kb tx
231- outputs [address ]= remchange
232- # Create a basic transaction that will send change back to ourself after account for a fee
233- # And then insert the 128 generated transaction outs in the middle rawtx[92] is where the #
234- # of txouts is stored and is the only thing we overwrite from the original transaction
235- rawtx = node .createrawtransaction (inputs , outputs )
236- newtx = rawtx [0 :92 ]
237- newtx = newtx + self .txouts
238- newtx = newtx + rawtx [94 :]
239- # Appears to be ever so slightly faster to sign with SIGHASH_NONE
240- signresult = node .signrawtransaction (newtx ,None ,None ,"NONE" )
241- txid = node .sendrawtransaction (signresult ["hex" ], True )
242- # Mine a full sized block which will be these transactions we just created
243- node .generate (1 )
244-
245208
246209 def run_test (self ):
247210 print ("Warning! This test requires 4GB of disk space and takes over 30 mins (up to 2 hours)" )
0 commit comments