From 0293c6dcf7f827fcce817abf714e6a448a6a3ff4 Mon Sep 17 00:00:00 2001 From: PastaClaw Date: Tue, 28 Apr 2026 09:10:49 -0500 Subject: [PATCH] fix: read governance debug log tail in binary mode feature_governance_cl.py was opening debug.log in text mode but seeking with a binary offset. The fully safe fix is to read the tail in binary mode, seek using a binary offset, then decode the resulting bytes afterward for the string match. This preserves the existing 100 KiB tail scan while avoiding invalid mixed-mode seek behavior in Python text I/O. Co-Authored-By: Claude Opus 4.6 --- test/functional/feature_governance_cl.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/functional/feature_governance_cl.py b/test/functional/feature_governance_cl.py index b29dc55a001a..3c6ef7356397 100755 --- a/test/functional/feature_governance_cl.py +++ b/test/functional/feature_governance_cl.py @@ -147,10 +147,10 @@ def run_test(self): expected_msg = f'CGovernanceManager::UpdatedBlockTip -- nCachedBlockHeight: {tip_height}' def governance_tip_updated(node): - with open(node.debug_log_path, encoding='utf-8') as dl: + with open(node.debug_log_path, "rb") as dl: seek_pos = node.debug_log_size(mode="rb") - 100 * 1024 # read the last 100 KiB only dl.seek(seek_pos if seek_pos > 0 else 0) - debug_log_part = dl.read() + debug_log_part = dl.read().decode("utf-8", errors="replace") return expected_msg in debug_log_part for node in self.nodes[0:5]: