Skip to content

Commit

Permalink
test: enable v2 transport for p2p_timeouts.py
Browse files Browse the repository at this point in the history
by skipping the part where we send a non-version message
before the version - this message would be interpreted as
part of the v2 handshake.
  • Loading branch information
mzumsande committed Nov 8, 2023
1 parent 2c1669c commit 35fb993
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
15 changes: 10 additions & 5 deletions test/functional/p2p_timeouts.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,27 @@ def run_test(self):

with self.nodes[0].assert_debug_log(['Unsupported message "ping" prior to verack from peer=0']):
no_verack_node.send_message(msg_ping())
with self.nodes[0].assert_debug_log(['non-version message before version handshake. Message "ping" from peer=1']):
no_version_node.send_message(msg_ping())

self.mock_forward(1)
# With v2, non-version messages before the handshake would be interpreted as part of the key exchange.
# Therefore, don't execute this part of the test if v2transport is chosen.
if not self.options.v2transport:
with self.nodes[0].assert_debug_log(['non-version message before version handshake. Message "ping" from peer=1']):
no_version_node.send_message(msg_ping())

self.mock_forward(1)
assert "version" in no_verack_node.last_message

assert no_verack_node.is_connected
assert no_version_node.is_connected
assert no_send_node.is_connected

no_verack_node.send_message(msg_ping())
no_version_node.send_message(msg_ping())
if not self.options.v2transport:
no_version_node.send_message(msg_ping())

expected_timeout_logs = [
"version handshake timeout peer=0",
"socket no message in first 3 seconds, 1 0 peer=1",
f"socket no message in first 3 seconds, {'0' if self.options.v2transport else '1'} 0 peer=1",
"socket no message in first 3 seconds, 0 0 peer=2",
]

Expand All @@ -100,5 +104,6 @@ def run_test(self):
extra_args=['-peertimeout=0'],
)


if __name__ == '__main__':
TimeoutsTest().main()
1 change: 1 addition & 0 deletions test/functional/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
'p2p_invalid_messages.py',
'rpc_createmultisig.py',
'p2p_timeouts.py',
'p2p_timeouts.py --v2transport',
'wallet_dump.py --legacy-wallet',
'rpc_signer.py',
'wallet_signer.py --descriptors',
Expand Down

0 comments on commit 35fb993

Please sign in to comment.