mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 10:43:19 -03:00
test: introduce TestNode.debug_log_bytes
This commit is contained in:
parent
587cbca826
commit
a2fb62b632
1 changed files with 6 additions and 3 deletions
|
@ -389,14 +389,17 @@ class TestNode():
|
||||||
def debug_log_path(self) -> Path:
|
def debug_log_path(self) -> Path:
|
||||||
return self.chain_path / 'debug.log'
|
return self.chain_path / 'debug.log'
|
||||||
|
|
||||||
|
def debug_log_bytes(self) -> int:
|
||||||
|
with open(self.debug_log_path, encoding='utf-8') as dl:
|
||||||
|
dl.seek(0, 2)
|
||||||
|
return dl.tell()
|
||||||
|
|
||||||
@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
|
||||||
with open(self.debug_log_path, encoding='utf-8') as dl:
|
prev_size = self.debug_log_bytes()
|
||||||
dl.seek(0, 2)
|
|
||||||
prev_size = dl.tell()
|
|
||||||
|
|
||||||
yield
|
yield
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue