Skip to content

Commit fa23105

Browse files
author
MarcoFalke
committed
qa: Cache only chain and wallet for regtest datadir
1 parent 791c3ea commit fa23105

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

test/functional/test_framework/test_framework.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
check_json_precision,
2525
connect_nodes_bi,
2626
disconnect_nodes,
27+
get_datadir_path,
2728
initialize_datadir,
28-
log_filename,
2929
p2p_port,
3030
set_node_times,
3131
sync_blocks,
@@ -382,7 +382,7 @@ def _initialize_chain(self):
382382
assert self.num_nodes <= MAX_NODES
383383
create_cache = False
384384
for i in range(MAX_NODES):
385-
if not os.path.isdir(os.path.join(self.options.cachedir, 'node' + str(i))):
385+
if not os.path.isdir(get_datadir_path(self.options.cachedir, i)):
386386
create_cache = True
387387
break
388388

@@ -391,8 +391,8 @@ def _initialize_chain(self):
391391

392392
# find and delete old cache directories if any exist
393393
for i in range(MAX_NODES):
394-
if os.path.isdir(os.path.join(self.options.cachedir, "node" + str(i))):
395-
shutil.rmtree(os.path.join(self.options.cachedir, "node" + str(i)))
394+
if os.path.isdir(get_datadir_path(self.options.cachedir, i)):
395+
shutil.rmtree(get_datadir_path(self.options.cachedir, i))
396396

397397
# Create cache directories, run bitcoinds:
398398
for i in range(MAX_NODES):
@@ -430,15 +430,18 @@ def _initialize_chain(self):
430430
self.stop_nodes()
431431
self.nodes = []
432432
self.disable_mocktime()
433+
434+
def cache_path(n, *paths):
435+
return os.path.join(get_datadir_path(self.options.cachedir, n), "regtest", *paths)
436+
433437
for i in range(MAX_NODES):
434-
os.remove(log_filename(self.options.cachedir, i, "debug.log"))
435-
os.remove(log_filename(self.options.cachedir, i, "wallets/db.log"))
436-
os.remove(log_filename(self.options.cachedir, i, "peers.dat"))
437-
os.remove(log_filename(self.options.cachedir, i, "fee_estimates.dat"))
438+
for entry in os.listdir(cache_path(i)):
439+
if entry not in ['wallets', 'chainstate', 'blocks']:
440+
os.remove(cache_path(i, entry))
438441

439442
for i in range(self.num_nodes):
440-
from_dir = os.path.join(self.options.cachedir, "node" + str(i))
441-
to_dir = os.path.join(self.options.tmpdir, "node" + str(i))
443+
from_dir = get_datadir_path(self.options.cachedir, i)
444+
to_dir = get_datadir_path(self.options.tmpdir, i)
442445
shutil.copytree(from_dir, to_dir)
443446
initialize_datadir(self.options.tmpdir, i) # Overwrite port/rpcport in bitcoin.conf
444447

test/functional/test_framework/util.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,6 @@ def get_auth_cookie(datadir):
328328
raise ValueError("No RPC credentials")
329329
return user, password
330330

331-
def log_filename(dirname, n_node, logname):
332-
return os.path.join(dirname, "node" + str(n_node), "regtest", logname)
333-
334331
def get_bip9_status(node, key):
335332
info = node.getblockchaininfo()
336333
return info['bip9_softforks'][key]

0 commit comments

Comments
 (0)