diff options
author | fanquake <fanquake@gmail.com> | 2023-11-01 10:26:08 +0000 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2023-11-01 10:39:48 +0000 |
commit | eca2e430acf50f11da2220f56d13e20073a57c9b (patch) | |
tree | 1f8545cfd1ca2db12badf60e13102817b08c5c67 /test/functional/test_framework | |
parent | 4733de32422575fd71a8582380304c41dbef11d1 (diff) | |
parent | 9cfc1c94407359379f10906affd2b837851c1b84 (diff) |
Merge bitcoin/bitcoin#28632: test: make python p2p not send getaddr on incoming connections
9cfc1c94407359379f10906affd2b837851c1b84 test: check that we don't send a getaddr msg to an inbound peer (Martin Zumsande)
88c33c6748da3c4fdadc554ebca43ce7267e9178 test: make python p2p not send getaddr messages when it's being connected to (Martin Zumsande)
Pull request description:
`bitcoind` nodes send `getaddr` messages only to outbound nodes (and ignore `getaddr` received by outgoing connections).
The python p2p node should mirror this behavior by not sending a `getaddr` message when it is not the initiator of the connection.
This is currently causing several unnecessary messages being sent and then ignored (`Ignoring "getaddr" from outbound-full-relay connection.`) in tests like `p2p_add_connections.py`.
ACKs for top commit:
pinheadmz:
concept ACK 9cfc1c9440
pablomartin4btc:
re ACK 9cfc1c94407359379f10906affd2b837851c1b84
BrandonOdiwuor:
re ACK 9cfc1c94407359379f10906affd2b837851c1b84
Tree-SHA512: 812bec5d8a4828b4384d4cdd4362d6eec09acb2363e888f2b3e3bf8b925e0e17f15e13dc297d6b616c68b93ace9ede7245b07b405d3f5f8eada98350f74230dc
Diffstat (limited to 'test/functional/test_framework')
-rwxr-xr-x | test/functional/test_framework/p2p.py | 3 | ||||
-rwxr-xr-x | test/functional/test_framework/test_node.py | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/test/functional/test_framework/p2p.py b/test/functional/test_framework/p2p.py index be4ed624fc..352becb367 100755 --- a/test/functional/test_framework/p2p.py +++ b/test/functional/test_framework/p2p.py @@ -456,7 +456,8 @@ class P2PInterface(P2PConnection): self.send_message(msg_verack()) self.nServices = message.nServices self.relay = message.relay - self.send_message(msg_getaddr()) + if self.p2p_connected_to_node: + self.send_message(msg_getaddr()) # Connection helper methods diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py index c77cfbdd91..b6af71d85c 100755 --- a/test/functional/test_framework/test_node.py +++ b/test/functional/test_framework/test_node.py @@ -644,6 +644,7 @@ class TestNode(): if 'dstaddr' not in kwargs: kwargs['dstaddr'] = '127.0.0.1' + p2p_conn.p2p_connected_to_node = True p2p_conn.peer_connect(**kwargs, net=self.chain, timeout_factor=self.timeout_factor)() self.p2ps.append(p2p_conn) p2p_conn.wait_until(lambda: p2p_conn.is_connected, check_connected=False) @@ -689,6 +690,7 @@ class TestNode(): self.log.debug("Connecting to %s:%d %s" % (address, port, connection_type)) self.addconnection('%s:%d' % (address, port), connection_type) + p2p_conn.p2p_connected_to_node = False p2p_conn.peer_accept_connection(connect_cb=addconnection_callback, connect_id=p2p_idx + 1, net=self.chain, timeout_factor=self.timeout_factor, **kwargs)() if connection_type == "feeler": |