Skip to content

Commit

Permalink
Collect messages in WireMock.process ethereum#50
Browse files Browse the repository at this point in the history
  • Loading branch information
konradkonrad committed Jan 18, 2017
1 parent 6b9f880 commit d90aef3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions devp2p/tests/test_kademlia_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,20 @@ def process(self, kademlia_protocols, steps=0):
"""
process messages until none are left
or if process steps messages if steps >0
also yields all messages for asserting
"""
i = 0
proto_by_node = dict((p.this_node, p) for p in kademlia_protocols)
while self.messages:
msg = self.messages.pop(0)
print(msg)
assert isinstance(msg[2], kademlia.Node)
target = proto_by_node[msg[0]]
cmd = 'recv_' + msg[1]
getattr(target, cmd)(*msg[2:])
i += 1
yield msg[1:]
if steps and i == steps:
return # messages may be left
assert not self.messages
Expand Down

0 comments on commit d90aef3

Please sign in to comment.