Skip to content

Commit

Permalink
test: set P2PConnection.p2p_connected_to_node in peer_connect_helper()
Browse files Browse the repository at this point in the history
Set `P2PConnection.p2p_connected_to_node` in
`P2PConnection.peer_connect_helper()` instead of
`TestNode.add_p2p_connection()` and
`TestNode.add_outbound_p2p_connection()`.

This way tests can create an instance of `P2PConnection` and use
`P2PConnection.peer_connect_helper()` directly.
  • Loading branch information
vasild committed Oct 22, 2024
1 parent 22cd0e8 commit 57529ac
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
1 change: 1 addition & 0 deletions test/functional/test_framework/p2p.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ def peer_connect_helper(self, dstaddr, dstport, net, timeout_factor):
self.on_connection_send_msg = None
self.recvbuf = b""
self.magic_bytes = MAGIC_BYTES[net]
self.p2p_connected_to_node = dstport != 0

def peer_connect(self, dstaddr, dstport, *, net, timeout_factor, supports_v2_p2p):
self.peer_connect_helper(dstaddr, dstport, net, timeout_factor)
Expand Down
2 changes: 0 additions & 2 deletions test/functional/test_framework/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,6 @@ def add_p2p_connection(self, p2p_conn, *, wait_for_verack=True, send_version=Tru
if supports_v2_p2p is None:
supports_v2_p2p = self.use_v2transport

p2p_conn.p2p_connected_to_node = True
if self.use_v2transport:
kwargs['services'] = kwargs.get('services', P2P_SERVICES) | NODE_P2P_V2
supports_v2_p2p = self.use_v2transport and supports_v2_p2p
Expand Down Expand Up @@ -781,7 +780,6 @@ def addconnection_callback(address, port):
self.log.debug("Connecting to %s:%d %s" % (address, port, connection_type))
self.addconnection('%s:%d' % (address, port), connection_type, advertise_v2_p2p)

p2p_conn.p2p_connected_to_node = False
if supports_v2_p2p is None:
supports_v2_p2p = self.use_v2transport
if advertise_v2_p2p is None:
Expand Down

0 comments on commit 57529ac

Please sign in to comment.