@@ -424,8 +424,8 @@ def debug_log_path(self) -> Path:
424
424
def wallets_path (self ) -> Path :
425
425
return self .chain_path / "wallets"
426
426
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 :
429
429
dl .seek (0 , 2 )
430
430
return dl .tell ()
431
431
@@ -434,13 +434,13 @@ def assert_debug_log(self, expected_msgs, unexpected_msgs=None, timeout=2):
434
434
if unexpected_msgs is None :
435
435
unexpected_msgs = []
436
436
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
438
438
439
439
yield
440
440
441
441
while True :
442
442
found = True
443
- with open (self .debug_log_path , encoding = ' utf-8' ) as dl :
443
+ with open (self .debug_log_path , encoding = " utf-8" , errors = "replace" ) as dl :
444
444
dl .seek (prev_size )
445
445
log = dl .read ()
446
446
print_log = " - " + "\n - " .join (log .splitlines ())
@@ -465,7 +465,7 @@ def wait_for_debug_log(self, expected_msgs, timeout=60):
465
465
the number of log lines we encountered when matching
466
466
"""
467
467
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
469
469
470
470
yield
471
471
0 commit comments