Skip to content

Commit 6651d77

Browse files
committed
test: use f-strings in feature_pruning.py
1 parent 961f581 commit 6651d77

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

test/functional/feature_pruning.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def test_invalid_command_line_options(self):
148148
def test_height_min(self):
149149
assert os.path.isfile(os.path.join(self.prunedir, "blk00000.dat")), "blk00000.dat is missing, pruning too early"
150150
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)}")
152152
self.log.info("Mining 25 more blocks should cause the first block file to be pruned")
153153
# Pruning doesn't run until we're allocating another chunk, 20 full blocks past the height cutoff will ensure this
154154
mine_large_blocks(self.nodes[0], 25)
@@ -158,7 +158,7 @@ def test_height_min(self):
158158

159159
self.log.info("Success")
160160
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}")
162162
assert_greater_than(550, usage)
163163

164164
def create_chain_with_staleblocks(self):
@@ -181,18 +181,18 @@ def create_chain_with_staleblocks(self):
181181
self.connect_nodes(0, 2)
182182
self.sync_blocks(self.nodes[0:3])
183183

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)}")
185185

186186
def reorg_test(self):
187187
# Node 1 will mine a 300 block chain starting 287 blocks back from Node 0 and Node 2's tip
188188
# This will cause Node 2 to do a reorg requiring 288 blocks of undo data to the reorg_test chain
189189

190190
height = self.nodes[1].getblockcount()
191-
self.log.info("Current block height: %d" % height)
191+
self.log.info(f"Current block height: {height}")
192192

193193
self.forkheight = height - 287
194194
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}")
196196
self.nodes[1].invalidateblock(self.forkhash)
197197

198198
# 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):
204204
curhash = self.nodes[1].getblockhash(self.forkheight - 1)
205205

206206
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()}")
208208

209209
# Disconnect node1 and generate the new chain
210210
self.disconnect_nodes(0, 1)
@@ -218,24 +218,24 @@ def reorg_test(self):
218218
self.connect_nodes(1, 2)
219219
self.sync_blocks(self.nodes[0:3], timeout=120)
220220

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)}")
223223

224224
self.log.info("Mine 220 more large blocks so we have requisite history")
225225

226226
mine_large_blocks(self.nodes[0], 220)
227227
self.sync_blocks(self.nodes[0:3], timeout=120)
228228

229229
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}")
231231
assert_greater_than(550, usage)
232232

233233
def reorg_back(self):
234234
# Verify that a block on the old main chain fork has been pruned away
235235
assert_raises_rpc_error(-1, "Block not available (pruned data)", self.nodes[2].getblock, self.forkhash)
236236
with self.nodes[2].assert_debug_log(expected_msgs=['block verification stopping at height', '(pruning, no data)']):
237237
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}")
239239

240240
# Verify that we have enough history to reorg back to the fork point
241241
# Although this is more than 288 blocks, because this chain was written more recently
@@ -259,7 +259,7 @@ def reorg_back(self):
259259
# At this point node 2 is within 288 blocks of the fork point so it will preserve its ability to reorg
260260
if self.nodes[2].getblockcount() < self.mainchainheight:
261261
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}")
263263
self.nodes[0].invalidateblock(curchainhash)
264264
assert_equal(self.nodes[0].getblockcount(), self.mainchainheight)
265265
assert_equal(self.nodes[0].getbestblockhash(), self.mainchainhash2)
@@ -296,7 +296,7 @@ def prune(index):
296296
assert_equal(ret, node.getblockchaininfo()['pruneheight'])
297297

298298
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"))
300300

301301
# should not prune because chain tip of node 3 (995) < PruneAfterHeight (1000)
302302
assert_raises_rpc_error(-1, "Blockchain is too short for pruning", node.pruneblockchain, height(500))

0 commit comments

Comments
 (0)