Skip to content

Commit 654f5c4

Browse files
committed
Speed up test_autorelay
1 parent 0d2614d commit 654f5c4

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

tests/test_relays.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
import hivemind
77

88

9-
async def ping_to_client(dht, node, peer_id: str):
10-
return await node.protocol.call_ping(hivemind.PeerID.from_base58(str(peer_id)))
9+
async def ping_to_client(dht, node, peer_id: hivemind.p2p.PeerID):
10+
return await node.protocol.call_ping(peer_id)
1111

1212

1313
@pytest.mark.forked
@@ -38,7 +38,6 @@ def test_autorelay(use_auto_relay: bool, use_relay: bool):
3838
client_mode=False,
3939
use_auto_relay=use_auto_relay,
4040
)
41-
time.sleep(5)
4241
dht_second_peer = hivemind.DHT(
4342
initial_peers=initial_peers,
4443
start=True,
@@ -50,15 +49,9 @@ def test_autorelay(use_auto_relay: bool, use_relay: bool):
5049

5150
assert dht_first_peer.is_alive() and dht_second_peer.is_alive() and dht_third_peer.is_alive()
5251

53-
time_start = time.perf_counter()
54-
while time.perf_counter() - time_start < 30:
55-
reached_ip = dht_second_peer.run_coroutine(partial(ping_to_client, peer_id=dht_third_peer.peer_id))
56-
if reached_ip:
57-
assert use_relay
58-
break
59-
time.sleep(2)
60-
else:
61-
assert not use_relay
52+
reached_ip = dht_second_peer.run_coroutine(partial(ping_to_client, peer_id=dht_third_peer.peer_id))
53+
if reached_ip:
54+
assert use_relay
6255

6356
for peer in dht_first_peer, dht_second_peer, dht_third_peer:
6457
peer.shutdown()

0 commit comments

Comments
 (0)