mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2026-02-10 23:20:55 +00:00
Pull request feedback
This commit is contained in:
@ -4,6 +4,7 @@ import pytest
|
||||
|
||||
from libp2p.host.exceptions import ConnectionFailure
|
||||
from libp2p.peer.peerinfo import PeerInfo
|
||||
from libp2p.routing.kademlia.kademlia_peer_router import peer_info_to_str
|
||||
from tests.utils import (
|
||||
set_up_nodes_by_transport_and_disc_opt,
|
||||
set_up_nodes_by_transport_opt,
|
||||
@ -23,11 +24,11 @@ async def test_host_routing_success():
|
||||
# Set routing info
|
||||
await routers[0].server.set(
|
||||
host_a.get_id().xor_id,
|
||||
PeerInfo(host_a.get_id(), host_a.get_addrs()).to_string(),
|
||||
peer_info_to_str(PeerInfo(host_a.get_id(), host_a.get_addrs())),
|
||||
)
|
||||
await routers[1].server.set(
|
||||
host_b.get_id().xor_id,
|
||||
PeerInfo(host_b.get_id(), host_b.get_addrs()).to_string(),
|
||||
peer_info_to_str(PeerInfo(host_b.get_id(), host_b.get_addrs())),
|
||||
)
|
||||
|
||||
# forces to use routing as no addrs are provided
|
||||
@ -54,11 +55,11 @@ async def test_host_routing_fail():
|
||||
# Set routing info
|
||||
await routers[0].server.set(
|
||||
host_a.get_id().xor_id,
|
||||
PeerInfo(host_a.get_id(), host_a.get_addrs()).to_string(),
|
||||
peer_info_to_str(PeerInfo(host_a.get_id(), host_a.get_addrs())),
|
||||
)
|
||||
await routers[1].server.set(
|
||||
host_b.get_id().xor_id,
|
||||
PeerInfo(host_b.get_id(), host_b.get_addrs()).to_string(),
|
||||
peer_info_to_str(PeerInfo(host_b.get_id(), host_b.get_addrs())),
|
||||
)
|
||||
|
||||
# routing fails because host_c does not use routing
|
||||
|
||||
@ -2,7 +2,10 @@ import pytest
|
||||
|
||||
from libp2p.kademlia.network import KademliaServer
|
||||
from libp2p.peer.id import ID
|
||||
from libp2p.routing.kademlia.kademlia_peer_router import KadmeliaPeerRouter
|
||||
from libp2p.routing.kademlia.kademlia_peer_router import (
|
||||
KadmeliaPeerRouter,
|
||||
peer_info_to_str,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@ -15,7 +18,7 @@ async def test_simple_two_nodes():
|
||||
|
||||
node_a_value = await node_b.bootstrap([("127.0.0.1", 5678)])
|
||||
node_a_kad_peerinfo = node_a_value[0]
|
||||
await node_a.set(node_a_kad_peerinfo.xor_id, node_a_kad_peerinfo.to_string())
|
||||
await node_a.set(node_a_kad_peerinfo.xor_id, peer_info_to_str(node_a_kad_peerinfo))
|
||||
|
||||
router = KadmeliaPeerRouter(node_b)
|
||||
returned_info = await router.find_peer(ID(node_a_kad_peerinfo.peer_id_bytes))
|
||||
@ -37,7 +40,7 @@ async def test_simple_three_nodes():
|
||||
node_a_kad_peerinfo = node_a_value[0]
|
||||
|
||||
await node_c.bootstrap([("127.0.0.1", 5702)])
|
||||
await node_a.set(node_a_kad_peerinfo.xor_id, node_a_kad_peerinfo.to_string())
|
||||
await node_a.set(node_a_kad_peerinfo.xor_id, peer_info_to_str(node_a_kad_peerinfo))
|
||||
|
||||
router = KadmeliaPeerRouter(node_c)
|
||||
returned_info = await router.find_peer(ID(node_a_kad_peerinfo.peer_id_bytes))
|
||||
@ -65,7 +68,7 @@ async def test_simple_four_nodes():
|
||||
|
||||
await node_d.bootstrap([("127.0.0.1", 5803)])
|
||||
|
||||
await node_b.set(node_a_kad_peerinfo.xor_id, node_a_kad_peerinfo.to_string())
|
||||
await node_b.set(node_a_kad_peerinfo.xor_id, peer_info_to_str(node_a_kad_peerinfo))
|
||||
|
||||
router = KadmeliaPeerRouter(node_d)
|
||||
returned_info = await router.find_peer(ID(node_a_kad_peerinfo.peer_id_bytes))
|
||||
|
||||
Reference in New Issue
Block a user