Skip to content

Commit fa9aced

Browse files
author
MarcoFalke
committed
test: Check that reindex with prune wipes blk files
1 parent fa9593e commit fa9aced

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

test/functional/feature_remove_pruned_files_on_startup.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
# Copyright (c) 2022-present The Bitcoin Core developers
33
# Distributed under the MIT software license, see the accompanying
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5-
"""Test removing undeleted pruned blk files on startup."""
5+
"""Tests around pruning rev and blk files on startup."""
66

77
import platform
88
from test_framework.test_framework import BitcoinTestFramework
9+
from test_framework.util import assert_equal
910

1011

1112
class FeatureRemovePrunedFilesOnStartupTest(BitcoinTestFramework):
@@ -50,6 +51,22 @@ def run_test(self):
5051
assert not blk0.exists()
5152
assert not rev1.exists()
5253

54+
self.log.info("Check that a reindex will wipe all files")
55+
56+
def ls_files():
57+
ls = [
58+
entry.name
59+
for entry in self.nodes[0].blocks_path.iterdir()
60+
if entry.is_file() and any(map(entry.name.startswith, ["rev", "blk"]))
61+
]
62+
return sorted(ls)
63+
64+
assert_equal(len(ls_files()), 4)
65+
self.restart_node(0, extra_args=self.extra_args[0] + ["-reindex"])
66+
assert_equal(self.nodes[0].getblockcount(), 0)
67+
self.stop_node(0) # Stop node to flush the two newly created files
68+
assert_equal(ls_files(), ["blk00000.dat", "rev00000.dat"])
69+
5370

5471
if __name__ == '__main__':
5572
FeatureRemovePrunedFilesOnStartupTest(__file__).main()

0 commit comments

Comments
 (0)