mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-02 19:52:01 +02:00
[test] make v2transport arg in addconnection mandatory and few cleanups
`TestNode::add_outbound_p2p_connection()` is the only place where addconnection test-only RPC is used. here, we always pass the appropriate v2transport option to addconnection RPC. currently the v2transport option for addconnection RPC is optional. so simply make the v2transport option mandatory instead.
This commit is contained in:
@ -243,7 +243,7 @@ class P2PConnection(asyncio.Protocol):
|
||||
self.on_close()
|
||||
|
||||
# v2 handshake method
|
||||
def v2_handshake(self):
|
||||
def _on_data_v2_handshake(self):
|
||||
"""v2 handshake performed before P2P messages are exchanged (see BIP324). P2PConnection is the initiator
|
||||
(in inbound connections to TestNode) and the responder (in outbound connections from TestNode).
|
||||
Performed by:
|
||||
@ -295,7 +295,7 @@ class P2PConnection(asyncio.Protocol):
|
||||
if len(t) > 0:
|
||||
self.recvbuf += t
|
||||
if self.supports_v2_p2p and not self.v2_state.tried_v2_handshake:
|
||||
self.v2_handshake()
|
||||
self._on_data_v2_handshake()
|
||||
else:
|
||||
self._on_data()
|
||||
|
||||
@ -593,9 +593,7 @@ class P2PInterface(P2PConnection):
|
||||
|
||||
def wait_for_reconnect(self, timeout=60):
|
||||
def test_function():
|
||||
if not (self.is_connected and self.last_message.get('version') and self.v2_state is None):
|
||||
return False
|
||||
return True
|
||||
return self.is_connected and self.last_message.get('version') and not self.supports_v2_p2p
|
||||
self.wait_until(test_function, timeout=timeout, check_connected=False)
|
||||
|
||||
# Message receiving helper methods
|
||||
|
@ -220,6 +220,7 @@ class EncryptedP2PState:
|
||||
# decoy packets have contents = None. v2 handshake is complete only when version packet
|
||||
# (can be empty with contents = b"") with contents != None is received.
|
||||
if contents is not None:
|
||||
assert contents == b"" # currently TestNode sends an empty version packet
|
||||
self.tried_v2_handshake = True
|
||||
return processed_length, True
|
||||
response = response[length:]
|
||||
|
Reference in New Issue
Block a user