From 7ed33e9a5552e41d40ca13093922018d556386e1 Mon Sep 17 00:00:00 2001 From: guha-rahul <69rahul16@gmail.com> Date: Fri, 27 Jun 2025 04:41:52 +0530 Subject: [PATCH] smol fix , adds degree --- tests/utils/pubsub/utils.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/utils/pubsub/utils.py b/tests/utils/pubsub/utils.py index 5a10ce52..7413d4e6 100644 --- a/tests/utils/pubsub/utils.py +++ b/tests/utils/pubsub/utils.py @@ -24,16 +24,22 @@ def make_pubsub_msg( ) -# TODO: Implement sparse connect async def dense_connect(hosts: Sequence[IHost]) -> None: await connect_some(hosts, 10) -# FIXME: `degree` is not used at all async def connect_some(hosts: Sequence[IHost], degree: int) -> None: + """ + Connect each host to up to 'degree' number of other hosts. + Creates a sparse network topology where each node has limited connections. + """ for i, host in enumerate(hosts): - for host2 in hosts[i + 1 :]: - await connect(host, host2) + connections_made = 0 + for j in range(i + 1, len(hosts)): + if connections_made >= degree: + break + await connect(host, hosts[j]) + connections_made += 1 async def one_to_all_connect(hosts: Sequence[IHost], central_host_index: int) -> None: