@@ -148,7 +148,7 @@ def test_invalid_command_line_options(self):
148
148
def test_height_min (self ):
149
149
assert os .path .isfile (os .path .join (self .prunedir , "blk00000.dat" )), "blk00000.dat is missing, pruning too early"
150
150
self .log .info ("Success" )
151
- self .log .info ("Though we're already using more than 550MiB, current usage: %d" % calc_usage (self .prunedir ))
151
+ self .log .info (f "Though we're already using more than 550MiB, current usage: { calc_usage (self .prunedir )} " )
152
152
self .log .info ("Mining 25 more blocks should cause the first block file to be pruned" )
153
153
# Pruning doesn't run until we're allocating another chunk, 20 full blocks past the height cutoff will ensure this
154
154
mine_large_blocks (self .nodes [0 ], 25 )
@@ -158,7 +158,7 @@ def test_height_min(self):
158
158
159
159
self .log .info ("Success" )
160
160
usage = calc_usage (self .prunedir )
161
- self .log .info ("Usage should be below target: %d" % usage )
161
+ self .log .info (f "Usage should be below target: { usage } " )
162
162
assert_greater_than (550 , usage )
163
163
164
164
def create_chain_with_staleblocks (self ):
@@ -181,18 +181,18 @@ def create_chain_with_staleblocks(self):
181
181
self .connect_nodes (0 , 2 )
182
182
self .sync_blocks (self .nodes [0 :3 ])
183
183
184
- self .log .info ("Usage can be over target because of high stale rate: %d" % calc_usage (self .prunedir ))
184
+ self .log .info (f "Usage can be over target because of high stale rate: { calc_usage (self .prunedir )} " )
185
185
186
186
def reorg_test (self ):
187
187
# Node 1 will mine a 300 block chain starting 287 blocks back from Node 0 and Node 2's tip
188
188
# This will cause Node 2 to do a reorg requiring 288 blocks of undo data to the reorg_test chain
189
189
190
190
height = self .nodes [1 ].getblockcount ()
191
- self .log .info ("Current block height: %d" % height )
191
+ self .log .info (f "Current block height: { height } " )
192
192
193
193
self .forkheight = height - 287
194
194
self .forkhash = self .nodes [1 ].getblockhash (self .forkheight )
195
- self .log .info ("Invalidating block %s at height %d" % ( self .forkhash , self . forkheight ) )
195
+ self .log .info (f "Invalidating block { self . forkhash } at height { self .forkheight } " )
196
196
self .nodes [1 ].invalidateblock (self .forkhash )
197
197
198
198
# We've now switched to our previously mined-24 block fork on node 1, but that's not what we want
@@ -204,7 +204,7 @@ def reorg_test(self):
204
204
curhash = self .nodes [1 ].getblockhash (self .forkheight - 1 )
205
205
206
206
assert self .nodes [1 ].getblockcount () == self .forkheight - 1
207
- self .log .info ("New best height: %d" % self .nodes [1 ].getblockcount ())
207
+ self .log .info (f "New best height: { self .nodes [1 ].getblockcount ()} " )
208
208
209
209
# Disconnect node1 and generate the new chain
210
210
self .disconnect_nodes (0 , 1 )
@@ -218,24 +218,24 @@ def reorg_test(self):
218
218
self .connect_nodes (1 , 2 )
219
219
self .sync_blocks (self .nodes [0 :3 ], timeout = 120 )
220
220
221
- self .log .info ("Verify height on node 2: %d" % self .nodes [2 ].getblockcount ())
222
- self .log .info ("Usage possibly still high because of stale blocks in block files: %d" % calc_usage (self .prunedir ))
221
+ self .log .info (f "Verify height on node 2: { self .nodes [2 ].getblockcount ()} " )
222
+ self .log .info (f "Usage possibly still high because of stale blocks in block files: { calc_usage (self .prunedir )} " )
223
223
224
224
self .log .info ("Mine 220 more large blocks so we have requisite history" )
225
225
226
226
mine_large_blocks (self .nodes [0 ], 220 )
227
227
self .sync_blocks (self .nodes [0 :3 ], timeout = 120 )
228
228
229
229
usage = calc_usage (self .prunedir )
230
- self .log .info ("Usage should be below target: %d" % usage )
230
+ self .log .info (f "Usage should be below target: { usage } " )
231
231
assert_greater_than (550 , usage )
232
232
233
233
def reorg_back (self ):
234
234
# Verify that a block on the old main chain fork has been pruned away
235
235
assert_raises_rpc_error (- 1 , "Block not available (pruned data)" , self .nodes [2 ].getblock , self .forkhash )
236
236
with self .nodes [2 ].assert_debug_log (expected_msgs = ['block verification stopping at height' , '(pruning, no data)' ]):
237
237
self .nodes [2 ].verifychain (checklevel = 4 , nblocks = 0 )
238
- self .log .info ("Will need to redownload block %d" % self .forkheight )
238
+ self .log .info (f "Will need to redownload block { self .forkheight } " )
239
239
240
240
# Verify that we have enough history to reorg back to the fork point
241
241
# Although this is more than 288 blocks, because this chain was written more recently
@@ -259,7 +259,7 @@ def reorg_back(self):
259
259
# At this point node 2 is within 288 blocks of the fork point so it will preserve its ability to reorg
260
260
if self .nodes [2 ].getblockcount () < self .mainchainheight :
261
261
blocks_to_mine = first_reorg_height + 1 - self .mainchainheight
262
- self .log .info ("Rewind node 0 to prev main chain to mine longer chain to trigger redownload. Blocks needed: %d" % blocks_to_mine )
262
+ self .log .info (f "Rewind node 0 to prev main chain to mine longer chain to trigger redownload. Blocks needed: { blocks_to_mine } " )
263
263
self .nodes [0 ].invalidateblock (curchainhash )
264
264
assert_equal (self .nodes [0 ].getblockcount (), self .mainchainheight )
265
265
assert_equal (self .nodes [0 ].getbestblockhash (), self .mainchainhash2 )
@@ -296,7 +296,7 @@ def prune(index):
296
296
assert_equal (ret , node .getblockchaininfo ()['pruneheight' ])
297
297
298
298
def has_block (index ):
299
- return os .path .isfile (os .path .join (self .nodes [node_number ].datadir , self .chain , "blocks" , "blk{:05}.dat" . format ( index ) ))
299
+ return os .path .isfile (os .path .join (self .nodes [node_number ].datadir , self .chain , "blocks" , f "blk{ index :05} .dat" ))
300
300
301
301
# should not prune because chain tip of node 3 (995) < PruneAfterHeight (1000)
302
302
assert_raises_rpc_error (- 1 , "Blockchain is too short for pruning" , node .pruneblockchain , height (500 ))
0 commit comments