From ab422066527992d53c92bb482c6b993f089b2999 Mon Sep 17 00:00:00 2001 From: Sebastian Falbesoner Date: Thu, 4 Jul 2024 20:35:22 +0200 Subject: [PATCH] Reapply "test: p2p: check that connecting to ourself leads to disconnect" This reverts commit 9ec2c53701a391629b55aeb2804e8060d2c453a4 with a tiny change included (identation of the wait_until call). Github-Pull: #30394 Rebased-From: 16bd283b3ad05daa41259a062aee0fc05b463fa6 --- test/functional/p2p_handshake.py | 26 ++++++++++++++++++++++++++ test/functional/test_runner.py | 2 ++ 2 files changed, 28 insertions(+) create mode 100755 test/functional/p2p_handshake.py diff --git a/test/functional/p2p_handshake.py b/test/functional/p2p_handshake.py new file mode 100755 index 0000000000000..29d88db3c94a0 --- /dev/null +++ b/test/functional/p2p_handshake.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 +# Copyright (c) 2024 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 P2P behaviour during the handshake phase. +""" +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import p2p_port + + +class P2PHandshakeTest(BitcoinTestFramework): + def set_test_params(self): + self.num_nodes = 1 + + def run_test(self): + node = self.nodes[0] + self.log.info("Check that connecting to ourself leads to immediate disconnect") + with node.assert_debug_log(["connected to self", "disconnecting"]): + node_listen_addr = f"127.0.0.1:{p2p_port(0)}" + node.addconnection(node_listen_addr, "outbound-full-relay", self.options.v2transport) + self.wait_until(lambda: len(node.getpeerinfo()) == 0) + + +if __name__ == '__main__': + P2PHandshakeTest().main() diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py index a23c5f7333dea..3eb2733cc1fb8 100755 --- a/test/functional/test_runner.py +++ b/test/functional/test_runner.py @@ -395,6 +395,8 @@ 'rpc_getdescriptorinfo.py', 'rpc_mempool_info.py', 'rpc_help.py', + 'p2p_handshake.py', + 'p2p_handshake.py --v2transport', 'feature_dirsymlinks.py', 'feature_help.py', 'feature_shutdown.py',