@@ -87,7 +87,7 @@ def check_clean_start():
87
87
lines_to_terminate_after .append (b'Verifying wallet' )
88
88
89
89
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 } " )
91
91
with node .busy_wait_for_debug_log ([terminate_line ]):
92
92
node .start (extra_args = ['-txindex=1' , '-blockfilterindex=1' , '-coinstatsindex=1' ])
93
93
self .log .debug ("Terminating node after terminate line was found" )
@@ -102,12 +102,22 @@ def check_clean_start():
102
102
'blocks/index/*.ldb' : 'Error opening block database.' ,
103
103
'chainstate/*.ldb' : 'Error opening coins database.' ,
104
104
'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'
105
109
}
106
110
107
111
files_to_perturb = {
108
112
'blocks/index/*.ldb' : 'Error loading block database.' ,
109
113
'chainstate/*.ldb' : 'Error opening coins database.' ,
110
114
'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'
111
121
}
112
122
113
123
for file_patt , err_fragment in files_to_delete .items ():
@@ -129,9 +139,10 @@ def check_clean_start():
129
139
self .stop_node (0 )
130
140
131
141
self .log .info ("Test startup errors after perturbing certain essential files" )
142
+ dirs = ["blocks" , "chainstate" , "indexes" ]
132
143
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 " )
135
146
target_files = list (node .chain_path .glob (file_patt ))
136
147
137
148
for target_file in target_files :
@@ -145,10 +156,9 @@ def check_clean_start():
145
156
146
157
start_expecting_error (err_fragment )
147
158
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 )
152
162
153
163
def init_pid_test (self ):
154
164
BITCOIN_PID_FILENAME_CUSTOM = "my_fancy_bitcoin_pid_file.foobar"
0 commit comments