mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2025-12-31 20:36:24 +00:00
clean up tests w/ default protocols in place
This commit is contained in:
@ -3,28 +3,16 @@ import secrets
|
||||
|
||||
import pytest
|
||||
|
||||
from libp2p.host.ping import ID, PING_LENGTH, handle_ping
|
||||
from libp2p.host.ping import ID, PING_LENGTH
|
||||
from libp2p.peer.peerinfo import info_from_p2p_addr
|
||||
from tests.utils import set_up_nodes_by_transport_opt
|
||||
|
||||
|
||||
def _add_ping_to(host):
|
||||
host.set_stream_handler(ID, handle_ping)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_ping_once():
|
||||
transport_opt_list = [["/ip4/127.0.0.1/tcp/0"], ["/ip4/127.0.0.1/tcp/0"]]
|
||||
(host_a, host_b) = await set_up_nodes_by_transport_opt(transport_opt_list)
|
||||
|
||||
# NOTE: this will fail after we add ping as a default handler
|
||||
# as a forced reminder to fix this test by removing the calls to
|
||||
# `_add_ping_to`
|
||||
assert host_a.get_mux().handlers == {}
|
||||
assert host_b.get_mux().handlers == {}
|
||||
_add_ping_to(host_a)
|
||||
_add_ping_to(host_b)
|
||||
|
||||
addr = host_a.get_addrs()[0]
|
||||
info = info_from_p2p_addr(addr)
|
||||
await host_b.connect(info)
|
||||
@ -45,14 +33,6 @@ async def test_ping_several():
|
||||
transport_opt_list = [["/ip4/127.0.0.1/tcp/0"], ["/ip4/127.0.0.1/tcp/0"]]
|
||||
(host_a, host_b) = await set_up_nodes_by_transport_opt(transport_opt_list)
|
||||
|
||||
# NOTE: this will fail after we add ping as a default handler
|
||||
# as a forced reminder to fix this test by removing the calls to
|
||||
# `_add_ping_to`
|
||||
assert host_a.get_mux().handlers == {}
|
||||
assert host_b.get_mux().handlers == {}
|
||||
_add_ping_to(host_a)
|
||||
_add_ping_to(host_b)
|
||||
|
||||
addr = host_a.get_addrs()[0]
|
||||
info = info_from_p2p_addr(addr)
|
||||
await host_b.connect(info)
|
||||
|
||||
Reference in New Issue
Block a user