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.
This commit is contained in:
Sebastian Falbesoner 2024-02-01 13:23:50 +01:00
parent b198b9c2ce
commit 7ddfc28309

View File

@ -285,6 +285,9 @@ class P2PConnection(asyncio.Protocol):
self.recvbuf = self.recvbuf[length:]
if self.v2_state.tried_v2_handshake:
self.send_version()
# process post-v2-handshake data immediately, if available
if len(self.recvbuf) > 0:
self._on_data()
# Socket read methods