Skip to content

Commit 149eca4

Browse files
author
MarcoFalke
committed
Merge #19599: test: clean message_count and last_message
2c6a02e Clean message_count and last_message (Troy Giorshev) Pull request description: From #19580 This PR changes comments to clarify the intended usage of `message_count` and `last_message`. Additionally it changes the only usage of `message_count` to use `last_message` instead, bringing the code into alignment with the intended usage. Note: Now `message_count` is completely unused. However, it is ready to be used (i.e. the supporting code works) and likely will be used in some test in the future. ACKs for top commit: jnewbery: utACK 2c6a02e Tree-SHA512: 07c7684c9586de4f845e10d7aac36c1aab9fb56b409949c1c70d5ca705bc3971ca7d5943245a0472def4efd7b4e1c5dad2f713db5ead8fca08404daf4891e98b
2 parents 8db2334 + 2c6a02e commit 149eca4

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

test/functional/test_framework/mininode.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,13 @@ class P2PInterface(P2PConnection):
283283
def __init__(self):
284284
super().__init__()
285285

286-
# Track number of messages of each type received and the most recent
287-
# message of each type
286+
# Track number of messages of each type received.
287+
# Should be read-only in a test.
288288
self.message_count = defaultdict(int)
289+
290+
# Track the most recent message of each type.
291+
# To wait for a message to be received, pop that message from
292+
# this and use wait_until.
289293
self.last_message = {}
290294

291295
# A count of the number of ping messages we've sent to the node
@@ -472,7 +476,7 @@ def test_function():
472476

473477
def wait_for_verack(self, timeout=60):
474478
def test_function():
475-
return self.message_count["verack"]
479+
return "verack" in self.last_message
476480

477481
self.wait_until(test_function, timeout=timeout)
478482

0 commit comments

Comments
 (0)