Skip to content

Commit 0000276

Browse files
author
MarcoFalke
committed
test: Remove redundant verack check
1 parent a44b0f7 commit 0000276

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)