From 084217013540ee1019721ed678b0a5cabad9de7c Mon Sep 17 00:00:00 2001 From: Alessandro Rezzi Date: Wed, 20 Mar 2024 17:08:41 +0100 Subject: [PATCH] Connect all nodes in parallel --- test/functional/test_framework/util.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py index 2c5856d2946201..4a7caefbb5ae21 100644 --- a/test/functional/test_framework/util.py +++ b/test/functional/test_framework/util.py @@ -13,6 +13,7 @@ import os import random import re +from concurrent.futures import ThreadPoolExecutor from subprocess import CalledProcessError import time @@ -384,11 +385,21 @@ def connect_nodes(from_connection, node_num): wait_until(lambda: all(peer['version'] != 0 for peer in from_connection.getpeerinfo())) def connect_nodes_clique(nodes): + # max_workers should be the maximum number of nodes that we have in the same functional test, + # 15 seems to be a good upper bound + parallel_exec = ThreadPoolExecutor(max_workers=15) l = len(nodes) - for a in range(l): - for b in range(a, l): + def connect_nodes_clique_internal(a): + for b in range(0, l): connect_nodes(nodes[a], b) - connect_nodes(nodes[b], a) + jobs = [] + for a in range(l): + jobs.append(parallel_exec.submit(connect_nodes_clique_internal, a)) + + for job in jobs: + job.result() + jobs.clear() + parallel_exec.shutdown() # Transaction/Block functions #############################