mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-05 05:02:06 +02:00
Merge bitcoin/bitcoin#29356: test: make v2transport arg in addconnection mandatory and few cleanups
e7fd70f4b6
[test] make v2transport arg in addconnection mandatory and few cleanups (stratospher) Pull request description: - make `v2transport` argument in `addconnection` regression-testing only RPC mandatory. https://github.com/bitcoin/bitcoin/pull/24748#discussion_r1470738750 - previously it was an optional arg with default `false` value. - only place this RPC is used is in the [functional tests](11b436a66a/test/functional/test_framework/test_node.py (L742)
) where we always pass the appropriate `v2transport` option to the RPC anyways. (and that too just for python dummy peer(`P2PInterface`) and bitcoind(`TestNode`) interactions) - rename `v2_handshake()` to `_on_data_v2_handshake()` https://github.com/bitcoin/bitcoin/pull/24748#discussion_r1466958424 - more compact return statement in `wait_for_reconnect()` https://github.com/bitcoin/bitcoin/pull/24748#discussion_r1466979708 - assertion to check that empty version packets are received from `TestNode`. ACKs for top commit: glozow: ACKe7fd70f4b6
theStack: Code-review ACKe7fd70f4b6
mzumsande: Code Review ACKe7fd70f4b6
Tree-SHA512: e66e29baccd91e1e4398b91f7d45c5fc7c2841d77d8a6178734586017bf2be63496721649da91848dec71da605ee31664352407d5bb896e624cc693767c61a1f
This commit is contained in:
@ -242,7 +242,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:
|
||||
@ -298,7 +298,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()
|
||||
|
||||
@ -595,9 +595,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