Skip to content

Commit

Permalink
1. Bumped p2pd version to 0.3.16
Browse files Browse the repository at this point in the history
2. Fixed autorelay test  sleep and correct order of dht peers and added more sleep time beetween peers
  • Loading branch information
Vahe1994 committed Dec 29, 2022
1 parent 8a291e1 commit 630b4e8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
from setuptools.command.build_py import build_py
from setuptools.command.develop import develop

P2PD_VERSION = "v0.3.16.dev1"
P2PD_VERSION = "v0.3.16"

P2PD_SOURCE_URL = f"https://github.com/learning-at-home/go-libp2p-daemon/archive/refs/tags/{P2PD_VERSION}.tar.gz"
P2PD_BINARY_URL = f"https://github.com/learning-at-home/go-libp2p-daemon/releases/download/{P2PD_VERSION}/"

# The value is sha256 of the binary from the release page
EXECUTABLES = {
"p2pd": "5902dc2b0d2d17493b87fc9660edb8fd8bc0792c32ec7f69a034d7da784d04f5",
"p2pd": "057ec61edbe926cf049e9532d43ea9540da55db7b2d8c816d2bbdddce23f3cdf",
}

here = os.path.abspath(os.path.dirname(__file__))
Expand Down
32 changes: 14 additions & 18 deletions tests/test_relays.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async def ping_to_client(dht, node, peer_id: str):
(False, False),
],
)
def test_client_pinging(use_auto_relay: bool, use_relay: bool):
def test_autorelay(use_auto_relay: bool, use_relay: bool):
dht_first_peer = hivemind.DHT(
start=True,
use_auto_relay=use_auto_relay,
Expand All @@ -29,40 +29,36 @@ def test_client_pinging(use_auto_relay: bool, use_relay: bool):
initial_peers = dht_first_peer.get_visible_maddrs()
assert dht_first_peer_id is not None

dht_second_peer = hivemind.DHT(
dht_third_peer = hivemind.DHT(
initial_peers=initial_peers,
host_maddrs=["/ip4/0.0.0.0/tcp/0"],
host_maddrs=[],
start=True,
client_mode=False,
no_listen=False,
no_listen=True,
use_relay=use_relay,
client_mode=False,
use_auto_relay=use_auto_relay,
)

dht_third_peer = hivemind.DHT(
time.sleep(5)
dht_second_peer = hivemind.DHT(
initial_peers=initial_peers,
host_maddrs=["/ip4/0.0.0.0/tcp/0"],
start=True,
client_mode=False,
no_listen=True,
no_listen=False,
use_relay=use_relay,
use_auto_relay=use_auto_relay,
)

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

time_passed = time.time()
while time.time() - time_passed < 10:
time_start = time.perf_counter()
while time.perf_counter() - time_start < 30:
reached_ip = dht_second_peer.run_coroutine(partial(ping_to_client, peer_id=dht_third_peer.peer_id))
if reached_ip:
assert use_relay
break
time.sleep(2)

if use_auto_relay and use_relay:
assert reached_ip is not None
else:
assert reached_ip is None
assert not use_relay

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

0 comments on commit 630b4e8

Please sign in to comment.