Skip to content

Commit 23f8561

Browse files
committed
test: add node.chain_path and node.debug_log_path
To allow easier access to the node's datadir and debug logs.
1 parent 02ccf10 commit 23f8561

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

test/functional/test_framework/test_node.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import collections
2121
import shlex
2222
import sys
23+
from pathlib import Path
2324

2425
from .authproxy import JSONRPCException
2526
from .descriptors import descsum_create
@@ -368,21 +369,28 @@ def is_node_stopped(self):
368369
def wait_until_stopped(self, timeout=BITCOIND_PROC_WAIT_TIMEOUT):
369370
wait_until_helper(self.is_node_stopped, timeout=timeout, timeout_factor=self.timeout_factor)
370371

372+
@property
373+
def chain_path(self) -> Path:
374+
return Path(self.datadir) / self.chain
375+
376+
@property
377+
def debug_log_path(self) -> Path:
378+
return self.chain_path / 'debug.log'
379+
371380
@contextlib.contextmanager
372381
def assert_debug_log(self, expected_msgs, unexpected_msgs=None, timeout=2):
373382
if unexpected_msgs is None:
374383
unexpected_msgs = []
375384
time_end = time.time() + timeout * self.timeout_factor
376-
debug_log = os.path.join(self.datadir, self.chain, 'debug.log')
377-
with open(debug_log, encoding='utf-8') as dl:
385+
with open(self.debug_log_path, encoding='utf-8') as dl:
378386
dl.seek(0, 2)
379387
prev_size = dl.tell()
380388

381389
yield
382390

383391
while True:
384392
found = True
385-
with open(debug_log, encoding='utf-8') as dl:
393+
with open(self.debug_log_path, encoding='utf-8') as dl:
386394
dl.seek(prev_size)
387395
log = dl.read()
388396
print_log = " - " + "\n - ".join(log.splitlines())

0 commit comments

Comments
 (0)