diff options
author | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2024-02-01 13:23:50 +0100 |
---|---|---|
committer | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2024-02-01 13:33:23 +0100 |
commit | 7ddfc28309e6b70c273112a93f01e518409ceaa0 (patch) | |
tree | ea008f081d1aa69121319299d31761f326470a01 | |
parent | b198b9c2ce28463f7c6a2b4cf08d64138c8509ee (diff) | |
download | bitcoin-7ddfc28309e6b70c273112a93f01e518409ceaa0.tar.xz |
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.
-rwxr-xr-x | test/functional/test_framework/p2p.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/test/functional/test_framework/p2p.py b/test/functional/test_framework/p2p.py index 783baf480d..d766800902 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 |