From 6a4ca62fd135190ecf8126ac15269f3ad6ce07cd Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Tue, 15 Oct 2024 09:43:55 +0000 Subject: [PATCH] merge bitcoin#28645: fix `assert_debug_log` call-site bugs, add type checks --- test/functional/feature_governance.py | 2 +- test/functional/p2p_v2_transport.py | 4 ++-- test/functional/test_framework/test_node.py | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/test/functional/feature_governance.py b/test/functional/feature_governance.py index 4e499ffa31..43c49784d2 100755 --- a/test/functional/feature_governance.py +++ b/test/functional/feature_governance.py @@ -302,7 +302,7 @@ class DashGovernanceTest (DashTestFramework): self.log.info("Move a few block past the recent superblock height and make sure we have no new votes") for _ in range(5): - with self.nodes[1].assert_debug_log("", [f"Voting NO-FUNDING for trigger:{winning_trigger_hash} success"]): + with self.nodes[1].assert_debug_log(expected_msgs=[""], unexpected_msgs=[f"Voting NO-FUNDING for trigger:{winning_trigger_hash} success"]): self.bump_mocktime(1) self.generate(self.nodes[0], 1, sync_fun=self.sync_blocks()) # Votes on both triggers should NOT change diff --git a/test/functional/p2p_v2_transport.py b/test/functional/p2p_v2_transport.py index a7f208c858..a99d368c70 100755 --- a/test/functional/p2p_v2_transport.py +++ b/test/functional/p2p_v2_transport.py @@ -145,7 +145,7 @@ class V2TransportTest(BitcoinTestFramework): wrong_network_magic_prefix = MAGIC_BYTES["mainnet"] + V1_PREFIX[4:] with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.connect(("127.0.0.1", p2p_port(0))) - with self.nodes[0].assert_debug_log("V2 transport error: V1 peer with wrong MessageStart"): + with self.nodes[0].assert_debug_log(["V2 transport error: V1 peer with wrong MessageStart"]): s.sendall(wrong_network_magic_prefix + b"somepayload") # Check detection of missing garbage terminator (hits after fixed amount of data if terminator never matches garbage) @@ -156,7 +156,7 @@ class V2TransportTest(BitcoinTestFramework): self.wait_until(lambda: len(self.nodes[0].getpeerinfo()) == num_peers + 1) s.sendall(b'\x00' * (MAX_KEY_GARB_AND_GARBTERM_LEN - 1)) self.wait_until(lambda: self.nodes[0].getpeerinfo()[-1]["bytesrecv"] == MAX_KEY_GARB_AND_GARBTERM_LEN - 1) - with self.nodes[0].assert_debug_log("V2 transport error: missing garbage terminator"): + with self.nodes[0].assert_debug_log(["V2 transport error: missing garbage terminator"]): s.sendall(b'\x00') # send out last byte # should disconnect immediately self.wait_until(lambda: len(self.nodes[0].getpeerinfo()) == num_peers) diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py index 3da025570f..91671e1f1f 100755 --- a/test/functional/test_framework/test_node.py +++ b/test/functional/test_framework/test_node.py @@ -427,6 +427,9 @@ class TestNode(): def assert_debug_log(self, expected_msgs, unexpected_msgs=None, timeout=2): if unexpected_msgs is None: unexpected_msgs = [] + assert_equal(type(expected_msgs), list) + assert_equal(type(unexpected_msgs), list) + time_end = time.time() + timeout * self.timeout_factor prev_size = self.debug_log_bytes()