mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-02 09:46:52 -05:00
test: Fix race condition in index pruning test
Nodes are restarted and reconnected as part of the test. Afterwards `sync_blocks` is called immediately on the nodes. `sync_blocks` first checks that all the included nodes have at least one connection. Since adding a connection is usually happening in a thread, sometimes nodes could run into this check before the connection was fully established so that it would fail the entire test. This fix uses the `connect_nodes` helper to make the connection the nodes. `connect_nodes` has a wait for the connection built into it.
This commit is contained in:
parent
2709ffb9da
commit
4faa550072
1 changed files with 3 additions and 4 deletions
|
@ -8,7 +8,6 @@ from test_framework.util import (
|
|||
assert_equal,
|
||||
assert_greater_than,
|
||||
assert_raises_rpc_error,
|
||||
p2p_port,
|
||||
)
|
||||
|
||||
|
||||
|
@ -132,11 +131,11 @@ class FeatureIndexPruneTest(BitcoinTestFramework):
|
|||
self.nodes[i].assert_start_raises_init_error(extra_args=self.extra_args[i], expected_msg=msg)
|
||||
|
||||
self.log.info("make sure the nodes start again with the indices and an additional -reindex arg")
|
||||
ip_port = "127.0.0.1:" + str(p2p_port(3))
|
||||
for i in range(3):
|
||||
# The nodes need to be reconnected to the non-pruning node upon restart, otherwise they will be stuck
|
||||
restart_args = self.extra_args[i]+["-reindex", f"-connect={ip_port}"]
|
||||
restart_args = self.extra_args[i]+["-reindex"]
|
||||
self.restart_node(i, extra_args=restart_args)
|
||||
# The nodes need to be reconnected to the non-pruning node upon restart, otherwise they will be stuck
|
||||
self.connect_nodes(i, 3)
|
||||
|
||||
self.sync_blocks(timeout=300)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue