mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-04 13:55:23 -05:00
test: add node.chain_path and node.debug_log_path
To allow easier access to the node's datadir and debug logs.
This commit is contained in:
parent
02ccf1086e
commit
23f85616a8
1 changed files with 11 additions and 3 deletions
|
@ -20,6 +20,7 @@ import urllib.parse
|
||||||
import collections
|
import collections
|
||||||
import shlex
|
import shlex
|
||||||
import sys
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from .authproxy import JSONRPCException
|
from .authproxy import JSONRPCException
|
||||||
from .descriptors import descsum_create
|
from .descriptors import descsum_create
|
||||||
|
@ -368,13 +369,20 @@ class TestNode():
|
||||||
def wait_until_stopped(self, timeout=BITCOIND_PROC_WAIT_TIMEOUT):
|
def wait_until_stopped(self, timeout=BITCOIND_PROC_WAIT_TIMEOUT):
|
||||||
wait_until_helper(self.is_node_stopped, timeout=timeout, timeout_factor=self.timeout_factor)
|
wait_until_helper(self.is_node_stopped, timeout=timeout, timeout_factor=self.timeout_factor)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def chain_path(self) -> Path:
|
||||||
|
return Path(self.datadir) / self.chain
|
||||||
|
|
||||||
|
@property
|
||||||
|
def debug_log_path(self) -> Path:
|
||||||
|
return self.chain_path / 'debug.log'
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def assert_debug_log(self, expected_msgs, unexpected_msgs=None, timeout=2):
|
def assert_debug_log(self, expected_msgs, unexpected_msgs=None, timeout=2):
|
||||||
if unexpected_msgs is None:
|
if unexpected_msgs is None:
|
||||||
unexpected_msgs = []
|
unexpected_msgs = []
|
||||||
time_end = time.time() + timeout * self.timeout_factor
|
time_end = time.time() + timeout * self.timeout_factor
|
||||||
debug_log = os.path.join(self.datadir, self.chain, 'debug.log')
|
with open(self.debug_log_path, encoding='utf-8') as dl:
|
||||||
with open(debug_log, encoding='utf-8') as dl:
|
|
||||||
dl.seek(0, 2)
|
dl.seek(0, 2)
|
||||||
prev_size = dl.tell()
|
prev_size = dl.tell()
|
||||||
|
|
||||||
|
@ -382,7 +390,7 @@ class TestNode():
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
found = True
|
found = True
|
||||||
with open(debug_log, encoding='utf-8') as dl:
|
with open(self.debug_log_path, encoding='utf-8') as dl:
|
||||||
dl.seek(prev_size)
|
dl.seek(prev_size)
|
||||||
log = dl.read()
|
log = dl.read()
|
||||||
print_log = " - " + "\n - ".join(log.splitlines())
|
print_log = " - " + "\n - ".join(log.splitlines())
|
||||||
|
|
Loading…
Add table
Reference in a new issue