Skip to content

Commit

Permalink
merge bitcoin#28645: fix assert_debug_log call-site bugs, add type …
Browse files Browse the repository at this point in the history
…checks
  • Loading branch information
kwvg committed Oct 16, 2024
1 parent deaee14 commit 6a4ca62
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion test/functional/feature_governance.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def sync_gov(node):

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
Expand Down
4 changes: 2 additions & 2 deletions test/functional/p2p_v2_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def run_test(self):
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)
Expand All @@ -156,7 +156,7 @@ def run_test(self):
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)
Expand Down
3 changes: 3 additions & 0 deletions test/functional/test_framework/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,9 @@ def debug_log_bytes(self) -> int:
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()

Expand Down

0 comments on commit 6a4ca62

Please sign in to comment.