mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-18 13:17:55 +02:00
Clean message_count and last_message
This commit clarifies the intended usage of message_count and last_message. Additionally it changes the only usage of message_count to using last_message instead, bringing the code further along the intended usage.
This commit is contained in:
parent
31d2b4098a
commit
2c6a02e024
1 changed files with 7 additions and 3 deletions
|
|
@ -283,9 +283,13 @@ class P2PInterface(P2PConnection):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
# Track number of messages of each type received and the most recent
|
# Track number of messages of each type received.
|
||||||
# message of each type
|
# Should be read-only in a test.
|
||||||
self.message_count = defaultdict(int)
|
self.message_count = defaultdict(int)
|
||||||
|
|
||||||
|
# Track the most recent message of each type.
|
||||||
|
# To wait for a message to be received, pop that message from
|
||||||
|
# this and use wait_until.
|
||||||
self.last_message = {}
|
self.last_message = {}
|
||||||
|
|
||||||
# A count of the number of ping messages we've sent to the node
|
# A count of the number of ping messages we've sent to the node
|
||||||
|
|
@ -472,7 +476,7 @@ class P2PInterface(P2PConnection):
|
||||||
|
|
||||||
def wait_for_verack(self, timeout=60):
|
def wait_for_verack(self, timeout=60):
|
||||||
def test_function():
|
def test_function():
|
||||||
return self.message_count["verack"]
|
return "verack" in self.last_message
|
||||||
|
|
||||||
self.wait_until(test_function, timeout=timeout)
|
self.wait_until(test_function, timeout=timeout)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue