Skip to content

Commit 5374229

Browse files
fanquakepanleone
authored andcommitted
Merge bitcoin#30252: test: Remove redundant verack check
0000276 test: Remove redundant verack check (MarcoFalke) Pull request description: Currently the sync in `connect_nodes` mentions the `version` and `verack` message types, but only checks the `verack`. Neither check is required, as the `pong` check implies both. In case of failure, the debug log will have to be consulted anyway, so the redundant check doesn't add value. Also clarify in the comments that the goal is to check the flag `fSuccessfullyConnected` indirectly. ACKs for top commit: furszy: utACK 0000276 brunoerg: ACK 0000276 tdb3: ACK 0000276 Tree-SHA512: f9ddcb1436d2f70da462a8dd470ecfc90a534dd6507c23877ef7626e7c02326c077001a42ad0171a87fba5c5275d1970d8c5e5d82c56c8412de944856fdfd6db
1 parent e7c21c7 commit 5374229

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

test/functional/test_framework/test_framework.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -353,23 +353,19 @@ def connect_nodes(self, a, b):
353353
def find_conn(node, peer_subversion, inbound):
354354
return next(filter(lambda peer: peer['subver'] == peer_subversion and peer['inbound'] == inbound, node.getpeerinfo()), None)
355355

356-
# poll until version handshake complete to avoid race conditions
357-
# with transaction relaying
358-
# See comments in net_processing:
359-
# * Must have a version message before anything else
360-
# * Must have a verack message before anything else
361356
wait_until(lambda: find_conn(from_connection, to_connection_subver, inbound=False) is not None)
362357
wait_until(lambda: find_conn(to_connection, from_connection_subver, inbound=True) is not None)
363358

364359
def check_bytesrecv(peer, msg_type, min_bytes_recv):
365360
assert peer is not None, "Error: peer disconnected"
366361
return peer['bytesrecv_per_msg'].pop(msg_type, 0) >= min_bytes_recv
367362

368-
wait_until(lambda: check_bytesrecv(find_conn(from_connection, to_connection_subver, inbound=False), 'verack', 21))
369-
wait_until(lambda: check_bytesrecv(find_conn(to_connection, from_connection_subver, inbound=True), 'verack', 21))
370-
371-
# The message bytes are counted before processing the message, so make
372-
# sure it was fully processed by waiting for a ping.
363+
# Poll until version handshake (fSuccessfullyConnected) is complete to
364+
# avoid race conditions, because some message types are blocked from
365+
# being sent or received before fSuccessfullyConnected.
366+
#
367+
# As the flag fSuccessfullyConnected is not exposed, check it by
368+
# waiting for a pong, which can only happen after the flag was set.
373369
wait_until(lambda: check_bytesrecv(find_conn(from_connection, to_connection_subver, inbound=False), 'pong', 29))
374370
wait_until(lambda: check_bytesrecv(find_conn(to_connection, from_connection_subver, inbound=True), 'pong', 29))
375371

0 commit comments

Comments
 (0)