mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-11 21:20:39 +02:00
Merge bitcoin/bitcoin#36065: test: refactor: Remove confusing ignore_errors=True
fa7be0a8dftest: refactor: Remove confusing ignore_errors=True (MarcoFalke) Pull request description: There is an unexplained `ignore_errors=True` in the internal `_initialize_chain` helper: ```py shutil.rmtree(cache_path('fees'), ignore_errors=True) ``` This is fine, because no error should happen. But it is a bit confusing, because an ignored error may lead to a later error anyway. Fix that by failing early instead. Also, re-write the simple block to `pathlib`. ACKs for top commit: willcl-ark: ACKfa7be0a8dfTree-SHA512: c533a8aebd92f3f1054563f20af438165632c98f7a2f189f3306420780468b143c24001f794a79ddfc0527c9605a4cfe59949648a9a7f41bbe138128b09f0a6e
This commit is contained in:
@@ -961,14 +961,13 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||
self.stop_nodes()
|
||||
self.nodes = []
|
||||
|
||||
def cache_path(*paths):
|
||||
return os.path.join(cache_node_dir, self.chain, *paths)
|
||||
cache_path = cache_node_dir / self.chain
|
||||
|
||||
os.rmdir(cache_path('wallets')) # Remove empty wallets dir
|
||||
shutil.rmtree(cache_path('fees'), ignore_errors=True)
|
||||
for entry in os.listdir(cache_path()):
|
||||
if entry not in ['chainstate', 'blocks', 'indexes']: # Only indexes, chainstate and blocks folders
|
||||
os.remove(cache_path(entry))
|
||||
(cache_path / "wallets").rmdir() # Do not cache empty wallets dir
|
||||
shutil.rmtree(cache_path / "fees") # Do not cache fees dat files
|
||||
for entry in cache_path.iterdir():
|
||||
if entry.name not in ["chainstate", "blocks", "indexes"]: # Only keep indexes, chainstate and blocks folders
|
||||
entry.unlink()
|
||||
|
||||
for i in range(self.num_nodes):
|
||||
self.log.debug("Copy cache directory {} to node {}".format(cache_node_dir, i))
|
||||
|
||||
Reference in New Issue
Block a user