added extra tests for identifu push for concurrency cap

This commit is contained in:
lla-dane
2025-07-04 17:28:44 +05:30
parent 8bfd4bde94
commit a7d122a0f9
3 changed files with 111 additions and 10 deletions

View File

@ -2,13 +2,30 @@ from unittest.mock import (
MagicMock,
)
import trio
def create_mock_connections() -> dict:
from libp2p.abc import IHost
def create_mock_connections(count: int = 50) -> dict:
connections = {}
for i in range(1, 31):
for i in range(1, count):
peer_id = f"peer-{i}"
mock_conn = MagicMock(name=f"INetConn-{i}")
connections[peer_id] = mock_conn
return connections
async def run_host_forever(host: IHost, addr):
async with host.run([addr]):
await trio.sleep_forever()
async def wait_until_listening(host, timeout=3):
with trio.move_on_after(timeout):
while not host.get_addrs():
await trio.sleep(0.05)
return
raise RuntimeError("Timed out waiting for host to get an address")