test: Remove redundant verack check

pull/30252/head
MarcoFalke 5 months ago
parent a44b0f771f
commit 0000276b31
No known key found for this signature in database

@ -1,5 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# Copyright (c) 2014-2022 The Bitcoin Core developers # Copyright (c) 2014-present The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php. # file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Base class for RPC testing.""" """Base class for RPC testing."""
@ -636,11 +636,6 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
def find_conn(node, peer_subversion, inbound): def find_conn(node, peer_subversion, inbound):
return next(filter(lambda peer: peer['subver'] == peer_subversion and peer['inbound'] == inbound, node.getpeerinfo()), None) return next(filter(lambda peer: peer['subver'] == peer_subversion and peer['inbound'] == inbound, node.getpeerinfo()), None)
# poll until version handshake complete to avoid race conditions
# with transaction relaying
# See comments in net_processing:
# * Must have a version message before anything else
# * Must have a verack message before anything else
self.wait_until(lambda: find_conn(from_connection, to_connection_subver, inbound=False) is not None) self.wait_until(lambda: find_conn(from_connection, to_connection_subver, inbound=False) is not None)
self.wait_until(lambda: find_conn(to_connection, from_connection_subver, inbound=True) is not None) self.wait_until(lambda: find_conn(to_connection, from_connection_subver, inbound=True) is not None)
@ -648,11 +643,12 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
assert peer is not None, "Error: peer disconnected" assert peer is not None, "Error: peer disconnected"
return peer['bytesrecv_per_msg'].pop(msg_type, 0) >= min_bytes_recv return peer['bytesrecv_per_msg'].pop(msg_type, 0) >= min_bytes_recv
self.wait_until(lambda: check_bytesrecv(find_conn(from_connection, to_connection_subver, inbound=False), 'verack', 21)) # Poll until version handshake (fSuccessfullyConnected) is complete to
self.wait_until(lambda: check_bytesrecv(find_conn(to_connection, from_connection_subver, inbound=True), 'verack', 21)) # avoid race conditions, because some message types are blocked from
# being sent or received before fSuccessfullyConnected.
# The message bytes are counted before processing the message, so make #
# sure it was fully processed by waiting for a ping. # As the flag fSuccessfullyConnected is not exposed, check it by
# waiting for a pong, which can only happen after the flag was set.
self.wait_until(lambda: check_bytesrecv(find_conn(from_connection, to_connection_subver, inbound=False), 'pong', 29)) self.wait_until(lambda: check_bytesrecv(find_conn(from_connection, to_connection_subver, inbound=False), 'pong', 29))
self.wait_until(lambda: check_bytesrecv(find_conn(to_connection, from_connection_subver, inbound=True), 'pong', 29)) self.wait_until(lambda: check_bytesrecv(find_conn(to_connection, from_connection_subver, inbound=True), 'pong', 29))

Loading…
Cancel
Save