Skip to content

Commit 7ac281c

Browse files
committed
qa: Add missing coverage of corrupt indexes
1 parent a9a2b66 commit 7ac281c

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

test/functional/feature_init.py

+17-7
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def check_clean_start():
8787
lines_to_terminate_after.append(b'Verifying wallet')
8888

8989
for terminate_line in lines_to_terminate_after:
90-
self.log.info(f"Starting node and will exit after line {terminate_line}")
90+
self.log.info(f"Starting node and will terminate after line {terminate_line}")
9191
with node.busy_wait_for_debug_log([terminate_line]):
9292
node.start(extra_args=['-txindex=1', '-blockfilterindex=1', '-coinstatsindex=1'])
9393
self.log.debug("Terminating node after terminate line was found")
@@ -102,12 +102,22 @@ def check_clean_start():
102102
'blocks/index/*.ldb': 'Error opening block database.',
103103
'chainstate/*.ldb': 'Error opening coins database.',
104104
'blocks/blk*.dat': 'Error loading block database.',
105+
'indexes/txindex/MANIFEST*': 'LevelDB error: Corruption: CURRENT points to a non-existent file',
106+
# Removing these files does not result in a startup error:
107+
# 'indexes/blockfilter/basic/*.dat', 'indexes/blockfilter/basic/db/*.*', 'indexes/coinstats/db/*.*',
108+
# 'indexes/txindex/*.log', 'indexes/txindex/CURRENT', 'indexes/txindex/LOCK'
105109
}
106110

107111
files_to_perturb = {
108112
'blocks/index/*.ldb': 'Error loading block database.',
109113
'chainstate/*.ldb': 'Error opening coins database.',
110114
'blocks/blk*.dat': 'Corrupted block database detected.',
115+
'indexes/blockfilter/basic/db/*.*': 'LevelDB error: Corruption',
116+
'indexes/coinstats/db/*.*': 'LevelDB error: Corruption',
117+
'indexes/txindex/*.log': 'LevelDB error: Corruption',
118+
'indexes/txindex/CURRENT': 'LevelDB error: Corruption',
119+
# Perturbing these files does not result in a startup error:
120+
# 'indexes/blockfilter/basic/*.dat', 'indexes/txindex/MANIFEST*', 'indexes/txindex/LOCK'
111121
}
112122

113123
for file_patt, err_fragment in files_to_delete.items():
@@ -129,9 +139,10 @@ def check_clean_start():
129139
self.stop_node(0)
130140

131141
self.log.info("Test startup errors after perturbing certain essential files")
142+
dirs = ["blocks", "chainstate", "indexes"]
132143
for file_patt, err_fragment in files_to_perturb.items():
133-
shutil.copytree(node.chain_path / "blocks", node.chain_path / "blocks_bak")
134-
shutil.copytree(node.chain_path / "chainstate", node.chain_path / "chainstate_bak")
144+
for dir in dirs:
145+
shutil.copytree(node.chain_path / dir, node.chain_path / f"{dir}_bak")
135146
target_files = list(node.chain_path.glob(file_patt))
136147

137148
for target_file in target_files:
@@ -145,10 +156,9 @@ def check_clean_start():
145156

146157
start_expecting_error(err_fragment)
147158

148-
shutil.rmtree(node.chain_path / "blocks")
149-
shutil.rmtree(node.chain_path / "chainstate")
150-
shutil.move(node.chain_path / "blocks_bak", node.chain_path / "blocks")
151-
shutil.move(node.chain_path / "chainstate_bak", node.chain_path / "chainstate")
159+
for dir in dirs:
160+
shutil.rmtree(node.chain_path / dir)
161+
shutil.move(node.chain_path / f"{dir}_bak", node.chain_path / dir)
152162

153163
def init_pid_test(self):
154164
BITCOIN_PID_FILENAME_CUSTOM = "my_fancy_bitcoin_pid_file.foobar"

0 commit comments

Comments
 (0)