mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-01 08:24:21 +01:00
Merge bitcoin/bitcoin#29279: test: p2p: check disconnect due to lack of desirable service flags
2f23987849test: p2p: check limited peers desirability (depending on best block depth) (Sebastian Falbesoner)c4a67d396dtest: p2p: check disconnect due to lack of desirable service flags (Sebastian Falbesoner)405ac819aftest: p2p: support disconnect waiting for `add_outbound_p2p_connection` (Sebastian Falbesoner) Pull request description: This PR adds missing test coverage for disconnecting peers which don't offer the desirable service flags in their VERSION message:5f3a0574c4/src/net_processing.cpp (L3384-L3389)This check is relevant for the connection types "outbound-full-relay", "block-relay-only" and "addr-fetch" (see `CNode::ExpectServicesFromConn(...)`). Feeler connections always disconnect, which is also tested here. In lack of finding a proper file where this test would fit in, I created a new one. Happy to take suggestions there. ACKs for top commit: davidgumberg: reACK2f23987849itornaza: tested ACK2f23987849fjahr: re-utACK2f23987849cbergqvist: re ACK2f23987849stratospher: tested ACK2f23987. 🚀 Tree-SHA512: cf75d9d4379d0f34fa1e13152e6a8d93cd51b9573466ab3a2fec32dc3e1ac49b174bd1063cae558bc736b111c8a6e7058b1b57a496df56255221bf367d29eb5d
This commit is contained in:
@@ -724,7 +724,7 @@ class TestNode():
|
||||
|
||||
return p2p_conn
|
||||
|
||||
def add_outbound_p2p_connection(self, p2p_conn, *, wait_for_verack=True, p2p_idx, connection_type="outbound-full-relay", supports_v2_p2p=None, advertise_v2_p2p=None, **kwargs):
|
||||
def add_outbound_p2p_connection(self, p2p_conn, *, wait_for_verack=True, wait_for_disconnect=False, p2p_idx, connection_type="outbound-full-relay", supports_v2_p2p=None, advertise_v2_p2p=None, **kwargs):
|
||||
"""Add an outbound p2p connection from node. Must be an
|
||||
"outbound-full-relay", "block-relay-only", "addr-fetch" or "feeler" connection.
|
||||
|
||||
@@ -771,7 +771,7 @@ class TestNode():
|
||||
if reconnect:
|
||||
p2p_conn.wait_for_reconnect()
|
||||
|
||||
if connection_type == "feeler":
|
||||
if connection_type == "feeler" or wait_for_disconnect:
|
||||
# feeler connections are closed as soon as the node receives a `version` message
|
||||
p2p_conn.wait_until(lambda: p2p_conn.message_count["version"] == 1, check_connected=False)
|
||||
p2p_conn.wait_until(lambda: not p2p_conn.is_connected, check_connected=False)
|
||||
|
||||
Reference in New Issue
Block a user