Skip to content

Commit 7ddfc28

Browse files
committed
test: p2p: process post-v2-handshake data immediately
In the course of executing the asyncio data reception callback during a v2 handshake, it's possible that the receive buffer already contains data for after the handshake (usually a VERSION message for inbound connections). If we don't process that data immediately, we would do so after the next message is received, but with the adapted protocol flow introduced in the next commit, there is no next message, as the TestNode wouldn't continue until we send back our own version in `on_version`. Fix this by calling `self._on_data` immediately if there's data left in the receive buffer after a completed v2 handshake.
1 parent b198b9c commit 7ddfc28

File tree

1 file changed

+3
-0
lines changed
  • test/functional/test_framework

1 file changed

+3
-0
lines changed

test/functional/test_framework/p2p.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,9 @@ def v2_handshake(self):
285285
self.recvbuf = self.recvbuf[length:]
286286
if self.v2_state.tried_v2_handshake:
287287
self.send_version()
288+
# process post-v2-handshake data immediately, if available
289+
if len(self.recvbuf) > 0:
290+
self._on_data()
288291

289292
# Socket read methods
290293

0 commit comments

Comments
 (0)