From 7ddfc28309e6b70c273112a93f01e518409ceaa0 Mon Sep 17 00:00:00 2001 From: Sebastian Falbesoner Date: Thu, 1 Feb 2024 13:23:50 +0100 Subject: [PATCH] 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. --- test/functional/test_framework/p2p.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/functional/test_framework/p2p.py b/test/functional/test_framework/p2p.py index 783baf480da..d7668009028 100755 --- a/test/functional/test_framework/p2p.py +++ b/test/functional/test_framework/p2p.py @@ -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