Skip to content

Commit 3c16361

Browse files
committed
merge bitcoin#29356: make v2transport arg in addconnection mandatory and few cleanups
1 parent c53cd93 commit 3c16361

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

src/rpc/net.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ static RPCHelpMan addconnection()
360360
{
361361
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The IP address and port to attempt connecting to."},
362362
{"connection_type", RPCArg::Type::STR, RPCArg::Optional::NO, "Type of connection to open (\"outbound-full-relay\", \"block-relay-only\", \"addr-fetch\" or \"feeler\")."},
363-
{"v2transport", RPCArg::Type::BOOL, RPCArg::Default{false}, "Attempt to connect using BIP324 v2 transport protocol"},
363+
{"v2transport", RPCArg::Type::BOOL, RPCArg::Optional::NO, "Attempt to connect using BIP324 v2 transport protocol"},
364364
},
365365
RPCResult{
366366
RPCResult::Type::OBJ, "", "",

test/functional/feature_anchors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def run_test(self):
100100
self.restart_node(0, extra_args=[f"-onion={onion_conf.addr[0]}:{onion_conf.addr[1]}"])
101101

102102
self.log.info("Add 256-bit-address block-relay-only connections to node")
103-
self.nodes[0].addconnection(ONION_ADDR, 'block-relay-only')
103+
self.nodes[0].addconnection(ONION_ADDR, 'block-relay-only', v2transport=False)
104104

105105
self.log.debug("Stop node")
106106
with self.nodes[0].assert_debug_log([f"DumpAnchors: Flush 1 outbound block-relay-only peer addresses to anchors.dat"]):

test/functional/test_framework/p2p.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ def connection_lost(self, exc):
272272
self.on_close()
273273

274274
# v2 handshake method
275-
def v2_handshake(self):
275+
def _on_data_v2_handshake(self):
276276
"""v2 handshake performed before P2P messages are exchanged (see BIP324). P2PConnection is the initiator
277277
(in inbound connections to TestNode) and the responder (in outbound connections from TestNode).
278278
Performed by:
@@ -325,7 +325,7 @@ def data_received(self, t):
325325
if len(t) > 0:
326326
self.recvbuf += t
327327
if self.supports_v2_p2p and not self.v2_state.tried_v2_handshake:
328-
self.v2_handshake()
328+
self._on_data_v2_handshake()
329329
else:
330330
self._on_data()
331331

@@ -631,9 +631,7 @@ def wait_for_disconnect(self, timeout=60):
631631

632632
def wait_for_reconnect(self, timeout=60):
633633
def test_function():
634-
if not (self.is_connected and self.last_message.get('version') and self.v2_state is None):
635-
return False
636-
return True
634+
return self.is_connected and self.last_message.get('version') and not self.supports_v2_p2p
637635
self.wait_until(test_function, timeout=timeout, check_connected=False)
638636

639637
# Message receiving helper methods

test/functional/test_framework/v2_p2p.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ def authenticate_handshake(self, response):
259259
# decoy packets have contents = None. v2 handshake is complete only when version packet
260260
# (can be empty with contents = b"") with contents != None is received.
261261
if contents is not None:
262+
assert contents == b"" # currently TestNode sends an empty version packet
262263
self.tried_v2_handshake = True
263264
return processed_length, True
264265
response = response[length:]

0 commit comments

Comments
 (0)