From e61a5a677fd0797c551eb1635df0ec40de91e153 Mon Sep 17 00:00:00 2001 From: Alex Stokes Date: Wed, 6 Nov 2019 15:04:17 -0800 Subject: [PATCH] clean up tests w/ default protocols in place --- tests/host/test_basic_host.py | 4 +++- tests/host/test_ping.py | 22 +--------------------- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/tests/host/test_basic_host.py b/tests/host/test_basic_host.py index 4d22222d..f25f4e72 100644 --- a/tests/host/test_basic_host.py +++ b/tests/host/test_basic_host.py @@ -11,4 +11,6 @@ def test_default_protocols(): mux = host.get_mux() handlers = mux.handlers - assert handlers == get_default_protocols(host) + # NOTE: comparing keys for equality as handlers may be closures that do not compare in the way + # this test is concerned with + assert handlers.keys() == get_default_protocols(host).keys() diff --git a/tests/host/test_ping.py b/tests/host/test_ping.py index d6f02449..a5296f13 100644 --- a/tests/host/test_ping.py +++ b/tests/host/test_ping.py @@ -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)