Skip to content

Commit 0fbb804

Browse files
committed
Merge bitcoin/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
2 parents e6e4c18 + 0000276 commit 0fbb804

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

test/functional/test_framework/test_framework.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python3
2-
# Copyright (c) 2014-2022 The Bitcoin Core developers
2+
# Copyright (c) 2014-present The Bitcoin Core developers
33
# Distributed under the MIT software license, see the accompanying
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
"""Base class for RPC testing."""
@@ -636,23 +636,19 @@ def connect_nodes(self, a, b, *, peer_advertises_v2=None, wait_for_connect: bool
636636
def find_conn(node, peer_subversion, inbound):
637637
return next(filter(lambda peer: peer['subver'] == peer_subversion and peer['inbound'] == inbound, node.getpeerinfo()), None)
638638

639-
# poll until version handshake complete to avoid race conditions
640-
# with transaction relaying
641-
# See comments in net_processing:
642-
# * Must have a version message before anything else
643-
# * Must have a verack message before anything else
644639
self.wait_until(lambda: find_conn(from_connection, to_connection_subver, inbound=False) is not None)
645640
self.wait_until(lambda: find_conn(to_connection, from_connection_subver, inbound=True) is not None)
646641

647642
def check_bytesrecv(peer, msg_type, min_bytes_recv):
648643
assert peer is not None, "Error: peer disconnected"
649644
return peer['bytesrecv_per_msg'].pop(msg_type, 0) >= min_bytes_recv
650645

651-
self.wait_until(lambda: check_bytesrecv(find_conn(from_connection, to_connection_subver, inbound=False), 'verack', 21))
652-
self.wait_until(lambda: check_bytesrecv(find_conn(to_connection, from_connection_subver, inbound=True), 'verack', 21))
653-
654-
# The message bytes are counted before processing the message, so make
655-
# sure it was fully processed by waiting for a ping.
646+
# Poll until version handshake (fSuccessfullyConnected) is complete to
647+
# avoid race conditions, because some message types are blocked from
648+
# being sent or received before fSuccessfullyConnected.
649+
#
650+
# As the flag fSuccessfullyConnected is not exposed, check it by
651+
# waiting for a pong, which can only happen after the flag was set.
656652
self.wait_until(lambda: check_bytesrecv(find_conn(from_connection, to_connection_subver, inbound=False), 'pong', 29))
657653
self.wait_until(lambda: check_bytesrecv(find_conn(to_connection, from_connection_subver, inbound=True), 'pong', 29))
658654

0 commit comments

Comments
 (0)