aboutsummaryrefslogtreecommitdiff
path: root/test/functional/p2p_add_connections.py
diff options
context:
space:
mode:
authorMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2024-07-16 13:40:43 +0200
committerMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2024-07-17 11:49:01 +0200
commitfaed5d3870fb32fb5278961ee23e38fd9ea6ca15 (patch)
tree341f7d07dab9e1fd8e091ce86d2168154924dab3 /test/functional/p2p_add_connections.py
parent6f9db1ebcab4064065ccd787161bf2b87e03cc1f (diff)
test: Non-Shy version sender
Diffstat (limited to 'test/functional/p2p_add_connections.py')
-rwxr-xr-xtest/functional/p2p_add_connections.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/test/functional/p2p_add_connections.py b/test/functional/p2p_add_connections.py
index bd766a279e..0775fd873d 100755
--- a/test/functional/p2p_add_connections.py
+++ b/test/functional/p2p_add_connections.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-# Copyright (c) 2020-2021 The Bitcoin Core developers
+# Copyright (c) 2020-present The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test add_outbound_p2p_connection test framework functionality"""
@@ -11,6 +11,14 @@ from test_framework.util import (
check_node_connections,
)
+
+class VersionSender(P2PInterface):
+ def on_open(self):
+ assert self.on_connection_send_msg is not None
+ self.send_version()
+ assert self.on_connection_send_msg is None
+
+
class P2PFeelerReceiver(P2PInterface):
def on_version(self, message):
# The bitcoind node closes feeler connections as soon as a version
@@ -106,5 +114,19 @@ class P2PAddConnections(BitcoinTestFramework):
# Feeler connections do not request tx relay
assert_equal(feeler_conn.last_message["version"].relay, 0)
+ self.log.info("Send version message early to node")
+ # Normally the test framework would be shy and send the version message
+ # only after it received one. See the on_version method. Check that
+ # bitcoind behaves properly when a version is sent unexpectedly (but
+ # tolerably) early.
+ #
+ # This checks that bitcoind sends its own version prior to processing
+ # the remote version (and replying with a verack). Otherwise it would
+ # be violating its own rules, such as "non-version message before
+ # version handshake".
+ ver_conn = self.nodes[0].add_outbound_p2p_connection(VersionSender(), p2p_idx=6, connection_type="outbound-full-relay", supports_v2_p2p=False, advertise_v2_p2p=False)
+ ver_conn.sync_with_ping()
+
+
if __name__ == '__main__':
P2PAddConnections().main()