Skip to content

Commit

Permalink
Test propagating errors and timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
borzunov committed Aug 3, 2021
1 parent 0c9d125 commit 51764f6
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/test_dht.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,25 @@
from multiaddr import Multiaddr

import hivemind
from hivemind.utils.networking import get_free_port

from test_utils.dht_swarms import launch_dht_instances


@pytest.mark.asyncio
async def test_startup_error():
with pytest.raises(hivemind.p2p.P2PDaemonError, match=r"Failed to connect to bootstrap peers"):
hivemind.DHT(
initial_peers=[f"/ip4/127.0.0.1/tcp/{get_free_port()}/p2p/QmdaK4LUeQaKhqSFPRu9N7MvXUEWDxWwtCvPrS444tCgd1"],
start=True,
)

dht = hivemind.DHT(start=True, await_ready=False)
with pytest.raises(TimeoutError):
dht.wait_until_ready(timeout=0.1)
dht.shutdown()


@pytest.mark.forked
def test_get_store(n_peers=10):
peers = launch_dht_instances(n_peers)
Expand Down

0 comments on commit 51764f6

Please sign in to comment.