diff options
author | merge-script <falke.marco@gmail.com> | 2021-09-25 08:50:52 +0200 |
---|---|---|
committer | merge-script <falke.marco@gmail.com> | 2021-09-25 08:50:52 +0200 |
commit | 442e32e1179a49db54521244e1672bd208d0ef94 (patch) | |
tree | d19aca69fd3250355381d03ee322b412967e63ed /test | |
parent | 03cb2b480bd5e35cd6bafbca3ff6adcba52dab8b (diff) | |
parent | fa04f26aa77d2cf746db4a8a43068b7c5c9cd02b (diff) | |
download | bitcoin-442e32e1179a49db54521244e1672bd208d0ef94.tar.xz |
Merge bitcoin/bitcoin#22817: test: Avoid race after connect_nodes
fa04f26aa77d2cf746db4a8a43068b7c5c9cd02b test: Avoid race after connect_nodes (MarcoFalke)
Pull request description:
Wait until the connection is fully established on both sides (verack). Fixes #22714
ACKs for top commit:
kiminuo:
utACK fa04f26aa77d2cf746db4a8a43068b7c5c9cd02b
Tree-SHA512: bc2c44b44b688086ff84046924cf5251dd625584e93ce8fa17de27023855b32f3bb55109b846abbcec775e2836c7f3c5a81d6b4aff7c4ac065b9aefa044c1883
Diffstat (limited to 'test')
-rwxr-xr-x | test/functional/test_framework/test_framework.py | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py index f382e0fdb3..3aca93fab3 100755 --- a/test/functional/test_framework/test_framework.py +++ b/test/functional/test_framework/test_framework.py @@ -560,18 +560,19 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass): self.nodes[i].process.wait(timeout) def connect_nodes(self, a, b): - def connect_nodes_helper(from_connection, node_num): - ip_port = "127.0.0.1:" + str(p2p_port(node_num)) - from_connection.addnode(ip_port, "onetry") - # 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 - wait_until_helper(lambda: all(peer['version'] != 0 for peer in from_connection.getpeerinfo())) - wait_until_helper(lambda: all(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in from_connection.getpeerinfo())) - - connect_nodes_helper(self.nodes[a], b) + from_connection = self.nodes[a] + to_connection = self.nodes[b] + ip_port = "127.0.0.1:" + str(p2p_port(b)) + from_connection.addnode(ip_port, "onetry") + # 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 + wait_until_helper(lambda: all(peer['version'] != 0 for peer in from_connection.getpeerinfo())) + wait_until_helper(lambda: all(peer['version'] != 0 for peer in to_connection.getpeerinfo())) + wait_until_helper(lambda: all(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in from_connection.getpeerinfo())) + wait_until_helper(lambda: all(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in to_connection.getpeerinfo())) def disconnect_nodes(self, a, b): def disconnect_nodes_helper(from_connection, node_num): |