From 1d77f3ff550f2b27019a1e436ea617f2ea909645 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Fri, 13 Sep 2024 10:05:48 +0000 Subject: [PATCH] merge bitcoin#26519: Add getpeerinfo test for missing version message Co-Authored-By: UdjinM6 --- test/functional/rpc_net.py | 45 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/test/functional/rpc_net.py b/test/functional/rpc_net.py index 16114a6d38..1972a94984 100755 --- a/test/functional/rpc_net.py +++ b/test/functional/rpc_net.py @@ -109,6 +109,51 @@ class NetTest(DashTestFramework): assert_equal(peer_info[2][0]['connection_type'], 'manual') + self.log.info("Check getpeerinfo output before a version message was sent") + no_version_peer_id = 3 + no_version_peer_conntime = self.mocktime + with self.nodes[0].assert_debug_log([f"Added connection peer={no_version_peer_id}"]): + self.nodes[0].add_p2p_connection(P2PInterface(), send_version=False, wait_for_verack=False) + peer_info = self.nodes[0].getpeerinfo()[no_version_peer_id] + peer_info.pop("addr") + peer_info.pop("addrbind") + assert_equal( + peer_info, + { + "addr_processed": 0, + "addr_rate_limited": 0, + "addr_relay_enabled": False, + "bip152_hb_from": False, + "bip152_hb_to": False, + "bytesrecv": 0, + "bytesrecv_per_msg": {}, + "bytessent": 0, + "bytessent_per_msg": {}, + "connection_type": "inbound", + "conntime": no_version_peer_conntime, + "id": no_version_peer_id, + "inbound": True, + "inflight": [], + "last_block": 0, + "last_transaction": 0, + "lastrecv": 0, + "lastsend": 0, + "masternode": False, + "network": "not_publicly_routable", + "permissions": [], + "relaytxes": False, + "services": "0000000000000000", + "servicesnames": [], + "startingheight": -1, + "subver": "", + "synced_blocks": -1, + "synced_headers": -1, + "timeoffset": 0, + "version": 0, + }, + ) + self.nodes[0].disconnect_p2ps() + def test_getnettotals(self): self.log.info("Test getnettotals") # Test getnettotals and getpeerinfo by doing a ping. The bytes