aboutsummaryrefslogtreecommitdiff
path: root/test/functional/p2p_add_connections.py
diff options
context:
space:
mode:
authorJohn Newbery <john@johnnewbery.com>2021-08-23 10:42:39 +0100
committerJohn Newbery <john@johnnewbery.com>2021-09-22 16:12:14 +0100
commit0220b834b175dc8c45a2c60213474a72c0ef8193 (patch)
treee3077a9f637e510cf3a388e4badac3ff942164d6 /test/functional/p2p_add_connections.py
parentdbcb5742c48fd26f77e500291d7083e12eec741b (diff)
downloadbitcoin-0220b834b175dc8c45a2c60213474a72c0ef8193.tar.xz
[test] Add testing for outbound feeler connections
Extend the addconnection RPC method to allow creating outbound feeler connections. Extend the test framework to accept those feeler connections.
Diffstat (limited to 'test/functional/p2p_add_connections.py')
-rwxr-xr-xtest/functional/p2p_add_connections.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/functional/p2p_add_connections.py b/test/functional/p2p_add_connections.py
index a04ba5db2d..82674befeb 100755
--- a/test/functional/p2p_add_connections.py
+++ b/test/functional/p2p_add_connections.py
@@ -14,6 +14,13 @@ def check_node_connections(*, node, num_in, num_out):
assert_equal(info["connections_in"], num_in)
assert_equal(info["connections_out"], num_out)
+class P2PFeelerReceiver(P2PInterface):
+ def on_version(self, message):
+ # The bitcoind node closes feeler connections as soon as a version
+ # message is received from the test framework. Don't send any responses
+ # to the node's version message since the connection will already be
+ # closed.
+ pass
class P2PAddConnections(BitcoinTestFramework):
def set_test_params(self):
@@ -91,6 +98,14 @@ class P2PAddConnections(BitcoinTestFramework):
check_node_connections(node=self.nodes[1], num_in=5, num_out=10)
+ self.log.info("Add 1 feeler connection to node 0")
+ feeler_conn = self.nodes[0].add_outbound_p2p_connection(P2PFeelerReceiver(), p2p_idx=6, connection_type="feeler")
+
+ # Feeler connection is closed
+ assert not feeler_conn.is_connected
+
+ # Verify version message received
+ assert_equal(feeler_conn.message_count["version"], 1)
if __name__ == '__main__':
P2PAddConnections().main()