From ba621ffb9cb63a01053854bb270786c470c90392 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Wed, 17 May 2023 16:53:02 +0200 Subject: [PATCH] test: improve debug log message from P2PConnection::connection_made() This is used in both cases - TCP server (accept) and TCP client (connect). The message "Connected & Listening address:port" is confusing. Print both ends of the TCP connection. --- test/functional/test_framework/p2p.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/functional/test_framework/p2p.py b/test/functional/test_framework/p2p.py index 4f1265eb548..adabbcf22f4 100755 --- a/test/functional/test_framework/p2p.py +++ b/test/functional/test_framework/p2p.py @@ -217,7 +217,12 @@ class P2PConnection(asyncio.Protocol): def connection_made(self, transport): """asyncio callback when a connection is opened.""" assert not self._transport - logger.debug("Connected & Listening: %s:%d" % (self.dstaddr, self.dstport)) + info = transport.get_extra_info("socket") + us = info.getsockname() + them = info.getpeername() + logger.debug(f"Connected: us={us[0]}:{us[1]}, them={them[0]}:{them[1]}") + self.dstaddr = them[0] + self.dstport = them[1] self._transport = transport # in an inbound connection to the TestNode with P2PConnection as the initiator, [TestNode <---- P2PConnection] # send the initial handshake immediately