Skip to content

Commit 4faa550

Browse files
committed
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.
1 parent 2709ffb commit 4faa550

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

test/functional/feature_index_prune.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
assert_equal,
99
assert_greater_than,
1010
assert_raises_rpc_error,
11-
p2p_port,
1211
)
1312

1413

@@ -132,11 +131,11 @@ def run_test(self):
132131
self.nodes[i].assert_start_raises_init_error(extra_args=self.extra_args[i], expected_msg=msg)
133132

134133
self.log.info("make sure the nodes start again with the indices and an additional -reindex arg")
135-
ip_port = "127.0.0.1:" + str(p2p_port(3))
136134
for i in range(3):
137-
# The nodes need to be reconnected to the non-pruning node upon restart, otherwise they will be stuck
138-
restart_args = self.extra_args[i]+["-reindex", f"-connect={ip_port}"]
135+
restart_args = self.extra_args[i]+["-reindex"]
139136
self.restart_node(i, extra_args=restart_args)
137+
# The nodes need to be reconnected to the non-pruning node upon restart, otherwise they will be stuck
138+
self.connect_nodes(i, 3)
140139

141140
self.sync_blocks(timeout=300)
142141

0 commit comments

Comments
 (0)