@@ -103,7 +103,7 @@ def create_chain_with_staleblocks(self):
103
103
# Disconnect node 0 so it can mine a longer reorg chain without knowing about node 1's soon-to-be-stale chain
104
104
# Node 2 stays connected, so it hears about the stale blocks and then reorg's when node0 reconnects
105
105
# Stopping node 0 also clears its mempool, so it doesn't have node1's transactions to accidentally mine
106
- stop_node ( self .nodes [ 0 ], 0 )
106
+ self .stop_node ( 0 )
107
107
self .nodes [0 ]= start_node (0 , self .options .tmpdir , ["-debug" ,"-maxreceivebuffer=20000" ,"-blockmaxsize=999000" , "-checkblocks=5" ], timewait = 900 )
108
108
# Mine 24 blocks in node 1
109
109
for i in range (24 ):
@@ -128,7 +128,7 @@ def reorg_test(self):
128
128
# This will cause Node 2 to do a reorg requiring 288 blocks of undo data to the reorg_test chain
129
129
# Reboot node 1 to clear its mempool (hopefully make the invalidate faster)
130
130
# Lower the block max size so we don't keep mining all our big mempool transactions (from disconnected blocks)
131
- stop_node ( self .nodes [ 1 ], 1 )
131
+ self .stop_node ( 1 )
132
132
self .nodes [1 ]= start_node (1 , self .options .tmpdir , ["-debug" ,"-maxreceivebuffer=20000" ,"-blockmaxsize=5000" , "-checkblocks=5" , "-disablesafemode" ], timewait = 900 )
133
133
134
134
height = self .nodes [1 ].getblockcount ()
@@ -151,7 +151,7 @@ def reorg_test(self):
151
151
print ("New best height" , self .nodes [1 ].getblockcount ())
152
152
153
153
# Reboot node1 to clear those giant tx's from mempool
154
- stop_node ( self .nodes [ 1 ], 1 )
154
+ self .stop_node ( 1 )
155
155
self .nodes [1 ]= start_node (1 , self .options .tmpdir , ["-debug" ,"-maxreceivebuffer=20000" ,"-blockmaxsize=5000" , "-checkblocks=5" , "-disablesafemode" ], timewait = 900 )
156
156
157
157
print ("Generating new longer chain of 300 more blocks" )
@@ -231,7 +231,7 @@ def manual_test(self, node_number, use_timestamp):
231
231
node = self .nodes [node_number ] = start_node (node_number , self .options .tmpdir , ["-debug=0" ], timewait = 900 )
232
232
assert_equal (node .getblockcount (), 995 )
233
233
assert_raises_message (JSONRPCException , "not in prune mode" , node .pruneblockchain , 500 )
234
- stop_node (node , node_number )
234
+ self . stop_node (node_number )
235
235
236
236
# now re-start in manual pruning mode
237
237
node = self .nodes [node_number ] = start_node (node_number , self .options .tmpdir , ["-debug=0" ,"-prune=1" ], timewait = 900 )
@@ -266,25 +266,21 @@ def has_block(index):
266
266
267
267
# mine 6 blocks so we are at height 1001 (i.e., above PruneAfterHeight)
268
268
node .generate (6 )
269
+ assert_equal (node .getblockchaininfo ()["blocks" ], 1001 )
269
270
270
- # negative and zero inputs should raise an exception
271
- try :
272
- node .pruneblockchain (- 10 )
273
- raise AssertionError ("pruneblockchain(-10) should have failed." )
274
- except :
275
- pass
276
-
277
- try :
278
- node .pruneblockchain (0 )
279
- raise AssertionError ("pruneblockchain(0) should have failed." )
280
- except :
281
- pass
271
+ # negative heights should raise an exception
272
+ assert_raises_message (JSONRPCException , "Negative" , node .pruneblockchain , - 10 )
282
273
283
274
# height=100 too low to prune first block file so this is a no-op
284
275
prune (100 )
285
276
if not has_block (0 ):
286
277
raise AssertionError ("blk00000.dat is missing when should still be there" )
287
278
279
+ # Does nothing
280
+ node .pruneblockchain (height (0 ))
281
+ if not has_block (0 ):
282
+ raise AssertionError ("blk00000.dat is missing when should still be there" )
283
+
288
284
# height=500 should prune first file
289
285
prune (500 )
290
286
if has_block (0 ):
@@ -311,7 +307,7 @@ def has_block(index):
311
307
raise AssertionError ("blk00003.dat is still there, should be pruned by now" )
312
308
313
309
# stop node, start back up with auto-prune at 550MB, make sure still runs
314
- stop_node (node , node_number )
310
+ self . stop_node (node_number )
315
311
self .nodes [node_number ] = start_node (node_number , self .options .tmpdir , ["-debug=0" ,"-prune=550" ], timewait = 900 )
316
312
317
313
print ("Success" )
@@ -320,7 +316,7 @@ def wallet_test(self):
320
316
# check that the pruning node's wallet is still in good shape
321
317
print ("Stop and start pruning node to trigger wallet rescan" )
322
318
try :
323
- stop_node ( self .nodes [ 2 ], 2 )
319
+ self .stop_node ( 2 )
324
320
start_node (2 , self .options .tmpdir , ["-debug=1" ,"-prune=550" ])
325
321
print ("Success" )
326
322
except Exception as detail :
@@ -333,7 +329,7 @@ def wallet_test(self):
333
329
nds = [self .nodes [0 ], self .nodes [5 ]]
334
330
sync_blocks (nds , wait = 5 , timeout = 300 )
335
331
try :
336
- stop_node ( self .nodes [ 5 ], 5 ) #stop and start to trigger rescan
332
+ self .stop_node ( 5 ) #stop and start to trigger rescan
337
333
start_node (5 , self .options .tmpdir , ["-debug=1" ,"-prune=550" ])
338
334
print ("Success" )
339
335
except Exception as detail :
@@ -353,8 +349,8 @@ def run_test(self):
353
349
# N0=N1=N2 **...*(995)
354
350
355
351
# stop manual-pruning node with 995 blocks
356
- stop_node ( self .nodes [ 3 ], 3 )
357
- stop_node ( self .nodes [ 4 ], 4 )
352
+ self .stop_node ( 3 )
353
+ self .stop_node ( 4 )
358
354
359
355
print ("Check that we haven't started pruning yet because we're below PruneAfterHeight" )
360
356
self .test_height_min ()
0 commit comments