mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-03 17:30:25 +01:00
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().
This commit is contained in:
@@ -424,8 +424,8 @@ class TestNode():
|
|||||||
def wallets_path(self) -> Path:
|
def wallets_path(self) -> Path:
|
||||||
return self.chain_path / "wallets"
|
return self.chain_path / "wallets"
|
||||||
|
|
||||||
def debug_log_bytes(self) -> int:
|
def debug_log_size(self, **kwargs) -> int:
|
||||||
with open(self.debug_log_path, encoding='utf-8') as dl:
|
with open(self.debug_log_path, **kwargs) as dl:
|
||||||
dl.seek(0, 2)
|
dl.seek(0, 2)
|
||||||
return dl.tell()
|
return dl.tell()
|
||||||
|
|
||||||
@@ -434,7 +434,7 @@ class TestNode():
|
|||||||
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
|
||||||
prev_size = self.debug_log_bytes()
|
prev_size = self.debug_log_size(encoding="utf-8") # Must use same encoding that is used to read() below
|
||||||
|
|
||||||
yield
|
yield
|
||||||
|
|
||||||
@@ -465,7 +465,7 @@ class TestNode():
|
|||||||
the number of log lines we encountered when matching
|
the number of log lines we encountered when matching
|
||||||
"""
|
"""
|
||||||
time_end = time.time() + timeout * self.timeout_factor
|
time_end = time.time() + timeout * self.timeout_factor
|
||||||
prev_size = self.debug_log_bytes()
|
prev_size = self.debug_log_size(mode="rb") # Must use same mode that is used to read() below
|
||||||
|
|
||||||
yield
|
yield
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user