@@ -24,10 +24,6 @@ def __init__(self):
24
24
self .setup_clean_chain = True
25
25
self .num_nodes = 3
26
26
27
- self .utxo = []
28
- self .address = ["" ,"" ]
29
- self .txouts = gen_return_txouts ()
30
-
31
27
def setup_network (self ):
32
28
self .nodes = []
33
29
self .is_network_split = False
@@ -40,12 +36,6 @@ def setup_network(self):
40
36
self .nodes .append (start_node (2 , self .options .tmpdir , ["-debug" ,"-maxreceivebuffer=20000" ,"-prune=550" ], timewait = 900 ))
41
37
self .prunedir = self .options .tmpdir + "/node2/regtest/blocks/"
42
38
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
-
49
39
connect_nodes (self .nodes [0 ], 1 )
50
40
connect_nodes (self .nodes [1 ], 2 )
51
41
connect_nodes (self .nodes [2 ], 0 )
@@ -58,7 +48,7 @@ def create_big_chain(self):
58
48
self .nodes [0 ].generate (150 )
59
49
# Then mine enough full blocks to create more than 550MiB of data
60
50
for i in range (645 ):
61
- self . mine_full_block (self .nodes [ 0 ], self . address [0 ])
51
+ mine_large_block (self .nodes [0 ])
62
52
63
53
sync_blocks (self .nodes [0 :3 ])
64
54
@@ -70,7 +60,7 @@ def test_height_min(self):
70
60
print ("Mining 25 more blocks should cause the first block file to be pruned" )
71
61
# Pruning doesn't run until we're allocating another chunk, 20 full blocks past the height cutoff will ensure this
72
62
for i in range (25 ):
73
- self . mine_full_block (self .nodes [ 0 ], self . address [0 ])
63
+ mine_large_block (self .nodes [0 ])
74
64
75
65
waitstart = time .time ()
76
66
while os .path .isfile (self .prunedir + "blk00000.dat" ):
@@ -95,17 +85,15 @@ def create_chain_with_staleblocks(self):
95
85
stop_node (self .nodes [0 ],0 )
96
86
self .nodes [0 ]= start_node (0 , self .options .tmpdir , ["-debug" ,"-maxreceivebuffer=20000" ,"-blockmaxsize=999000" , "-checkblocks=5" ], timewait = 900 )
97
87
# Mine 24 blocks in node 1
98
- self .utxo = self .nodes [1 ].listunspent ()
99
88
for i in range (24 ):
100
89
if j == 0 :
101
- self . mine_full_block (self .nodes [ 1 ], self . address [1 ])
90
+ mine_large_block (self .nodes [1 ])
102
91
else :
103
92
self .nodes [1 ].generate (1 ) #tx's already in mempool from previous disconnects
104
93
105
94
# Reorg back with 25 block chain from node 0
106
- self .utxo = self .nodes [0 ].listunspent ()
107
95
for i in range (25 ):
108
- self . mine_full_block (self .nodes [ 0 ], self . address [0 ])
96
+ mine_large_block (self .nodes [0 ])
109
97
110
98
# Create connections in the order so both nodes can see the reorg at the same time
111
99
connect_nodes (self .nodes [1 ], 0 )
@@ -217,31 +205,6 @@ def reorg_back(self):
217
205
# Verify we can now have the data for a block previously pruned
218
206
assert (self .nodes [2 ].getblock (self .forkhash )["height" ] == self .forkheight )
219
207
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
-
245
208
246
209
def run_test (self ):
247
210
print ("Warning! This test requires 4GB of disk space and takes over 30 mins (up to 2 hours)" )
0 commit comments