Skip to content

Commit fa63326

Browse files
author
MarcoFalke
committed
test: Fix debug_log_size helper
debug_log_bytes returned "an opaque number when in text mode" (https://docs.python.org/3/tutorial/inputoutput.html#methods-of-file-objects), not the number of bytes. Fix this by using binary mode or text mode (with the same encoding) consistently when opening the file for ftell() and read().
1 parent 24d5cf9 commit fa63326

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

test/functional/test_framework/test_node.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -424,8 +424,8 @@ def debug_log_path(self) -> Path:
424424
def wallets_path(self) -> Path:
425425
return self.chain_path / "wallets"
426426

427-
def debug_log_bytes(self) -> int:
428-
with open(self.debug_log_path, encoding='utf-8') as dl:
427+
def debug_log_size(self, **kwargs) -> int:
428+
with open(self.debug_log_path, **kwargs) as dl:
429429
dl.seek(0, 2)
430430
return dl.tell()
431431

@@ -434,7 +434,7 @@ def assert_debug_log(self, expected_msgs, unexpected_msgs=None, timeout=2):
434434
if unexpected_msgs is None:
435435
unexpected_msgs = []
436436
time_end = time.time() + timeout * self.timeout_factor
437-
prev_size = self.debug_log_bytes()
437+
prev_size = self.debug_log_size(encoding="utf-8") # Must use same encoding that is used to read() below
438438

439439
yield
440440

@@ -465,7 +465,7 @@ def wait_for_debug_log(self, expected_msgs, timeout=60):
465465
the number of log lines we encountered when matching
466466
"""
467467
time_end = time.time() + timeout * self.timeout_factor
468-
prev_size = self.debug_log_bytes()
468+
prev_size = self.debug_log_size(mode="rb") # Must use same mode that is used to read() below
469469

470470
yield
471471

0 commit comments

Comments
 (0)