diff --git a/examples/chat/chat.py b/examples/chat/chat.py index 0b0fd43..ea3c11e 100755 --- a/examples/chat/chat.py +++ b/examples/chat/chat.py @@ -8,7 +8,6 @@ import multiaddr from libp2p import new_node from libp2p.peer.peerinfo import info_from_p2p_addr - PROTOCOL_ID = "/chat/1.0.0" diff --git a/libp2p/__init__.py b/libp2p/__init__.py index bebd120..68e96cb 100644 --- a/libp2p/__init__.py +++ b/libp2p/__init__.py @@ -2,15 +2,15 @@ import asyncio from Crypto.PublicKey import RSA -from .security.insecure_security import InsecureTransport -from .peer.peerstore import PeerStore -from .peer.id import ID -from .network.swarm import Swarm from .host.basic_host import BasicHost -from .transport.upgrader import TransportUpgrader -from .transport.tcp.tcp import TCP from .kademlia.network import KademliaServer +from .network.swarm import Swarm +from .peer.id import ID +from .peer.peerstore import PeerStore from .routing.kademlia.kademlia_peer_router import KadmeliaPeerRouter +from .security.insecure_security import InsecureTransport +from .transport.tcp.tcp import TCP +from .transport.upgrader import TransportUpgrader async def cleanup_done_tasks(): diff --git a/libp2p/host/basic_host.py b/libp2p/host/basic_host.py index ff1b165..e29cff5 100644 --- a/libp2p/host/basic_host.py +++ b/libp2p/host/basic_host.py @@ -3,11 +3,10 @@ from typing import Any, Awaitable, Callable, List, Sequence import multiaddr from libp2p.network.network_interface import INetwork +from libp2p.network.stream.net_stream_interface import INetStream from libp2p.peer.id import ID from libp2p.peer.peerinfo import PeerInfo from libp2p.peer.peerstore_interface import IPeerStore - -from libp2p.network.stream.net_stream_interface import INetStream from libp2p.routing.kademlia.kademlia_peer_router import KadmeliaPeerRouter from .host_interface import IHost diff --git a/libp2p/host/host_interface.py b/libp2p/host/host_interface.py index 9bf5464..dd6d865 100644 --- a/libp2p/host/host_interface.py +++ b/libp2p/host/host_interface.py @@ -4,12 +4,10 @@ from typing import Any, Awaitable, Callable, List, Sequence import multiaddr from libp2p.network.network_interface import INetwork +from libp2p.network.stream.net_stream_interface import INetStream from libp2p.peer.id import ID from libp2p.peer.peerinfo import PeerInfo -from libp2p.network.stream.net_stream_interface import INetStream - - StreamHandlerFn = Callable[[INetStream], Awaitable[None]] diff --git a/libp2p/kademlia/crawling.py b/libp2p/kademlia/crawling.py index 97a4855..c649da0 100644 --- a/libp2p/kademlia/crawling.py +++ b/libp2p/kademlia/crawling.py @@ -4,7 +4,6 @@ import logging from .kad_peerinfo import KadPeerHeap, create_kad_peerinfo from .utils import gather_dict - log = logging.getLogger(__name__) diff --git a/libp2p/kademlia/kad_peerinfo.py b/libp2p/kademlia/kad_peerinfo.py index ea05aeb..9fab8dc 100644 --- a/libp2p/kademlia/kad_peerinfo.py +++ b/libp2p/kademlia/kad_peerinfo.py @@ -1,11 +1,13 @@ import heapq +from operator import itemgetter import random -from operator import itemgetter from multiaddr import Multiaddr -from libp2p.peer.peerinfo import PeerInfo + from libp2p.peer.id import ID from libp2p.peer.peerdata import PeerData +from libp2p.peer.peerinfo import PeerInfo + from .utils import digest P_IP = "ip4" diff --git a/libp2p/kademlia/network.py b/libp2p/kademlia/network.py index 27cfe32..fcf4b9a 100644 --- a/libp2p/kademlia/network.py +++ b/libp2p/kademlia/network.py @@ -1,16 +1,15 @@ """ Package for interacting on the network at a high level. """ -import pickle import asyncio import logging +import pickle -from .protocol import KademliaProtocol -from .utils import digest -from .storage import ForgetfulStorage +from .crawling import NodeSpiderCrawl, ValueSpiderCrawl from .kad_peerinfo import create_kad_peerinfo -from .crawling import ValueSpiderCrawl -from .crawling import NodeSpiderCrawl +from .protocol import KademliaProtocol +from .storage import ForgetfulStorage +from .utils import digest log = logging.getLogger(__name__) diff --git a/libp2p/kademlia/protocol.py b/libp2p/kademlia/protocol.py index eade292..8606fc2 100644 --- a/libp2p/kademlia/protocol.py +++ b/libp2p/kademlia/protocol.py @@ -1,12 +1,12 @@ -import random import asyncio import logging +import random from rpcudp.protocol import RPCProtocol + from .kad_peerinfo import create_kad_peerinfo from .routing import RoutingTable - log = logging.getLogger(__name__) diff --git a/libp2p/kademlia/routing.py b/libp2p/kademlia/routing.py index 0179155..d0a2b35 100644 --- a/libp2p/kademlia/routing.py +++ b/libp2p/kademlia/routing.py @@ -1,10 +1,10 @@ -import heapq -import time -import operator import asyncio - from collections import OrderedDict -from .utils import OrderedSet, shared_prefix, bytes_to_bit_string +import heapq +import operator +import time + +from .utils import OrderedSet, bytes_to_bit_string, shared_prefix class KBucket: diff --git a/libp2p/kademlia/storage.py b/libp2p/kademlia/storage.py index bcbf625..afd30e8 100644 --- a/libp2p/kademlia/storage.py +++ b/libp2p/kademlia/storage.py @@ -1,8 +1,8 @@ -import time +from abc import ABC, abstractmethod +from collections import OrderedDict from itertools import takewhile import operator -from collections import OrderedDict -from abc import abstractmethod, ABC +import time class IStorage(ABC): diff --git a/libp2p/kademlia/utils.py b/libp2p/kademlia/utils.py index f5fa2d1..78ff082 100644 --- a/libp2p/kademlia/utils.py +++ b/libp2p/kademlia/utils.py @@ -1,9 +1,9 @@ """ General catchall for functions that don't make sense as methods. """ +import asyncio import hashlib import operator -import asyncio async def gather_dict(dic): diff --git a/libp2p/network/network_interface.py b/libp2p/network/network_interface.py index 131eba8..90dae80 100644 --- a/libp2p/network/network_interface.py +++ b/libp2p/network/network_interface.py @@ -1,5 +1,5 @@ from abc import ABC, abstractmethod -from typing import Awaitable, Callable, Dict, Sequence, TYPE_CHECKING +from typing import TYPE_CHECKING, Awaitable, Callable, Dict, Sequence from multiaddr import Multiaddr diff --git a/libp2p/network/notifee_interface.py b/libp2p/network/notifee_interface.py index 73f4ecd..5f303b8 100644 --- a/libp2p/network/notifee_interface.py +++ b/libp2p/network/notifee_interface.py @@ -3,9 +3,8 @@ from typing import TYPE_CHECKING from multiaddr import Multiaddr -from libp2p.stream_muxer.muxed_connection_interface import IMuxedConn - from libp2p.network.stream.net_stream_interface import INetStream +from libp2p.stream_muxer.muxed_connection_interface import IMuxedConn if TYPE_CHECKING: from .network_interface import INetwork diff --git a/libp2p/network/swarm.py b/libp2p/network/swarm.py index ce6b67c..dc0c690 100644 --- a/libp2p/network/swarm.py +++ b/libp2p/network/swarm.py @@ -10,18 +10,16 @@ from libp2p.protocol_muxer.multiselect_client import MultiselectClient from libp2p.routing.interfaces import IPeerRouting from libp2p.stream_muxer.muxed_connection_interface import IMuxedConn from libp2p.stream_muxer.muxed_stream_interface import IMuxedStream -from libp2p.transport.upgrader import TransportUpgrader -from libp2p.transport.transport_interface import ITransport from libp2p.transport.listener_interface import IListener +from libp2p.transport.transport_interface import ITransport +from libp2p.transport.upgrader import TransportUpgrader - +from .connection.raw_connection import RawConnection from .network_interface import INetwork from .notifee_interface import INotifee -from .connection.raw_connection import RawConnection from .stream.net_stream import NetStream from .stream.net_stream_interface import INetStream - StreamHandlerFn = Callable[[INetStream], Awaitable[None]] diff --git a/libp2p/peer/addrbook_interface.py b/libp2p/peer/addrbook_interface.py index 722dc10..0ba2614 100644 --- a/libp2p/peer/addrbook_interface.py +++ b/libp2p/peer/addrbook_interface.py @@ -1,7 +1,6 @@ from abc import ABC, abstractmethod from typing import List, Sequence - from multiaddr import Multiaddr from .id import ID diff --git a/libp2p/peer/id.py b/libp2p/peer/id.py index 91df71a..9e39cf0 100644 --- a/libp2p/peer/id.py +++ b/libp2p/peer/id.py @@ -2,7 +2,6 @@ import hashlib from typing import Union import base58 - import multihash diff --git a/libp2p/peer/peerstore_interface.py b/libp2p/peer/peerstore_interface.py index bc68234..3ffd9a2 100644 --- a/libp2p/peer/peerstore_interface.py +++ b/libp2p/peer/peerstore_interface.py @@ -1,7 +1,6 @@ from abc import abstractmethod from typing import List, Sequence - from .addrbook_interface import IAddrBook from .id import ID from .peerinfo import PeerInfo diff --git a/libp2p/protocol_muxer/multiselect.py b/libp2p/protocol_muxer/multiselect.py index f381b2f..62d836c 100644 --- a/libp2p/protocol_muxer/multiselect.py +++ b/libp2p/protocol_muxer/multiselect.py @@ -1,6 +1,5 @@ -from .multiselect_muxer_interface import IMultiselectMuxer from .multiselect_communicator import MultiselectCommunicator - +from .multiselect_muxer_interface import IMultiselectMuxer MULTISELECT_PROTOCOL_ID = "/multistream/1.0.0" PROTOCOL_NOT_FOUND_MSG = "na" diff --git a/libp2p/protocol_muxer/multiselect_client.py b/libp2p/protocol_muxer/multiselect_client.py index 6dd9f12..6fbf82d 100644 --- a/libp2p/protocol_muxer/multiselect_client.py +++ b/libp2p/protocol_muxer/multiselect_client.py @@ -1,7 +1,6 @@ from .multiselect_client_interface import IMultiselectClient from .multiselect_communicator import MultiselectCommunicator - MULTISELECT_PROTOCOL_ID = "/multistream/1.0.0" PROTOCOL_NOT_FOUND_MSG = "na" diff --git a/libp2p/pubsub/gossipsub.py b/libp2p/pubsub/gossipsub.py index 9ffa743..ce79e3d 100644 --- a/libp2p/pubsub/gossipsub.py +++ b/libp2p/pubsub/gossipsub.py @@ -1,7 +1,7 @@ from ast import literal_eval import asyncio import random -from typing import Any, Dict, Iterable, List, Set, Sequence +from typing import Any, Dict, Iterable, List, Sequence, Set from libp2p.peer.id import ID diff --git a/libp2p/pubsub/pubsub.py b/libp2p/pubsub/pubsub.py index 262f26b..87019e1 100644 --- a/libp2p/pubsub/pubsub.py +++ b/libp2p/pubsub/pubsub.py @@ -1,13 +1,12 @@ import asyncio import time -from typing import Any, Dict, List, Tuple, TYPE_CHECKING +from typing import TYPE_CHECKING, Any, Dict, List, Tuple from lru import LRU from libp2p.host.host_interface import IHost -from libp2p.peer.id import ID - from libp2p.network.stream.net_stream_interface import INetStream +from libp2p.peer.id import ID from .pb import rpc_pb2 from .pubsub_notifee import PubsubNotifee diff --git a/libp2p/pubsub/pubsub_notifee.py b/libp2p/pubsub/pubsub_notifee.py index bc7197e..f8caa20 100644 --- a/libp2p/pubsub/pubsub_notifee.py +++ b/libp2p/pubsub/pubsub_notifee.py @@ -4,9 +4,8 @@ from multiaddr import Multiaddr from libp2p.network.network_interface import INetwork from libp2p.network.notifee_interface import INotifee -from libp2p.stream_muxer.muxed_connection_interface import IMuxedConn - from libp2p.network.stream.net_stream_interface import INetStream +from libp2p.stream_muxer.muxed_connection_interface import IMuxedConn if TYPE_CHECKING: import asyncio diff --git a/libp2p/pubsub/pubsub_router_interface.py b/libp2p/pubsub/pubsub_router_interface.py index 38c5394..ce445d0 100644 --- a/libp2p/pubsub/pubsub_router_interface.py +++ b/libp2p/pubsub/pubsub_router_interface.py @@ -1,5 +1,5 @@ from abc import ABC, abstractmethod -from typing import List, TYPE_CHECKING +from typing import TYPE_CHECKING, List from libp2p.peer.id import ID diff --git a/libp2p/security/insecure_security.py b/libp2p/security/insecure_security.py index 9537265..981869e 100644 --- a/libp2p/security/insecure_security.py +++ b/libp2p/security/insecure_security.py @@ -1,7 +1,7 @@ -from libp2p.security.secure_transport_interface import ISecureTransport -from libp2p.security.secure_conn_interface import ISecureConn +from typing import TYPE_CHECKING, Any, Dict, cast -from typing import TYPE_CHECKING, Dict, Any, cast +from libp2p.security.secure_conn_interface import ISecureConn +from libp2p.security.secure_transport_interface import ISecureTransport if TYPE_CHECKING: from libp2p.network.connection.raw_connection_interface import IRawConnection diff --git a/libp2p/security/secure_conn_interface.py b/libp2p/security/secure_conn_interface.py index e39d853..ce4f31c 100644 --- a/libp2p/security/secure_conn_interface.py +++ b/libp2p/security/secure_conn_interface.py @@ -1,5 +1,4 @@ from abc import ABC, abstractmethod - from typing import TYPE_CHECKING if TYPE_CHECKING: diff --git a/libp2p/security/secure_transport_interface.py b/libp2p/security/secure_transport_interface.py index 865d5ea..069eb74 100644 --- a/libp2p/security/secure_transport_interface.py +++ b/libp2p/security/secure_transport_interface.py @@ -1,5 +1,4 @@ from abc import ABC, abstractmethod - from typing import TYPE_CHECKING if TYPE_CHECKING: diff --git a/libp2p/security/security_multistream.py b/libp2p/security/security_multistream.py index d81824a..3ec8b32 100644 --- a/libp2p/security/security_multistream.py +++ b/libp2p/security/security_multistream.py @@ -1,8 +1,8 @@ from abc import ABC -from libp2p.protocol_muxer.multiselect_client import MultiselectClient -from libp2p.protocol_muxer.multiselect import Multiselect +from typing import TYPE_CHECKING, Dict, NewType -from typing import TYPE_CHECKING, NewType, Dict +from libp2p.protocol_muxer.multiselect import Multiselect +from libp2p.protocol_muxer.multiselect_client import MultiselectClient if TYPE_CHECKING: from libp2p.network.connection.raw_connection_interface import IRawConnection diff --git a/libp2p/security/simple_security.py b/libp2p/security/simple_security.py index 07a0129..fb36ba3 100644 --- a/libp2p/security/simple_security.py +++ b/libp2p/security/simple_security.py @@ -1,9 +1,9 @@ import asyncio -from libp2p.security.secure_transport_interface import ISecureTransport -from libp2p.security.secure_conn_interface import ISecureConn - from typing import TYPE_CHECKING, cast +from libp2p.security.secure_conn_interface import ISecureConn +from libp2p.security.secure_transport_interface import ISecureTransport + if TYPE_CHECKING: from libp2p.network.connection.raw_connection_interface import IRawConnection from libp2p.peer.id import ID diff --git a/libp2p/security/typing.py b/libp2p/security/typing.py index 9832fbe..66b9316 100644 --- a/libp2p/security/typing.py +++ b/libp2p/security/typing.py @@ -1,4 +1,3 @@ -from typing import TypeVar, Dict, Any, NewType - +from typing import Any, Dict, NewType, TypeVar TSecurityDetails = NewType("TSecurityDetails", Dict[str, str]) diff --git a/libp2p/stream_muxer/mplex/mplex.py b/libp2p/stream_muxer/mplex/mplex.py index 12a2a55..f498471 100644 --- a/libp2p/stream_muxer/mplex/mplex.py +++ b/libp2p/stream_muxer/mplex/mplex.py @@ -1,8 +1,8 @@ import asyncio -from .utils import encode_uvarint, decode_uvarint_from_stream, get_flag -from .mplex_stream import MplexStream from ..muxed_connection_interface import IMuxedConn +from .mplex_stream import MplexStream +from .utils import decode_uvarint_from_stream, encode_uvarint, get_flag class Mplex(IMuxedConn): diff --git a/libp2p/stream_muxer/mplex/utils.py b/libp2p/stream_muxer/mplex/utils.py index b5c852f..70dcd12 100644 --- a/libp2p/stream_muxer/mplex/utils.py +++ b/libp2p/stream_muxer/mplex/utils.py @@ -1,5 +1,6 @@ import asyncio import struct + from .constants import HEADER_TAGS diff --git a/libp2p/transport/upgrader.py b/libp2p/transport/upgrader.py index b7d74da..f14d7fc 100644 --- a/libp2p/transport/upgrader.py +++ b/libp2p/transport/upgrader.py @@ -1,5 +1,5 @@ -from libp2p.stream_muxer.mplex.mplex import Mplex from libp2p.security.security_multistream import SecurityMultistream +from libp2p.stream_muxer.mplex.mplex import Mplex class TransportUpgrader: diff --git a/setup.py b/setup.py index 1ff4aa9..a46d879 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,5 @@ import setuptools - classifiers = [f"Programming Language :: Python :: {version}" for version in ["3.7"]] diff --git a/tests/examples/test_chat.py b/tests/examples/test_chat.py index 3c949a0..1eaec5f 100644 --- a/tests/examples/test_chat.py +++ b/tests/examples/test_chat.py @@ -1,12 +1,12 @@ -import pytest import asyncio -import multiaddr -from tests.utils import cleanup, set_up_nodes_by_transport_opt +import multiaddr +import pytest + from libp2p import new_node from libp2p.peer.peerinfo import info_from_p2p_addr from libp2p.protocol_muxer.multiselect_client import MultiselectClientError - +from tests.utils import cleanup, set_up_nodes_by_transport_opt PROTOCOL_ID = "/chat/1.0.0" diff --git a/tests/kademlia/test_basic.py b/tests/kademlia/test_basic.py index 03e92c6..9c30808 100644 --- a/tests/kademlia/test_basic.py +++ b/tests/kademlia/test_basic.py @@ -1,4 +1,5 @@ import pytest + from libp2p.kademlia.network import KademliaServer diff --git a/tests/kademlia/test_providers.py b/tests/kademlia/test_providers.py index f460275..f58e945 100644 --- a/tests/kademlia/test_providers.py +++ b/tests/kademlia/test_providers.py @@ -1,4 +1,5 @@ import pytest + from libp2p.kademlia.network import KademliaServer diff --git a/tests/libp2p/test_libp2p.py b/tests/libp2p/test_libp2p.py index 9e669e0..bc58a8c 100644 --- a/tests/libp2p/test_libp2p.py +++ b/tests/libp2p/test_libp2p.py @@ -1,8 +1,8 @@ import multiaddr import pytest -from tests.utils import cleanup, set_up_nodes_by_transport_opt from libp2p.peer.peerinfo import info_from_p2p_addr +from tests.utils import cleanup, set_up_nodes_by_transport_opt @pytest.mark.asyncio diff --git a/tests/libp2p/test_notify.py b/tests/libp2p/test_notify.py index bb13c32..7dd3ccb 100644 --- a/tests/libp2p/test_notify.py +++ b/tests/libp2p/test_notify.py @@ -9,17 +9,17 @@ TODO: Add tests for closed_stream disconnected, listen_close when those features are implemented in swarm """ -import pytest import multiaddr +import pytest +from libp2p import initialize_default_swarm, new_node +from libp2p.host.basic_host import BasicHost +from libp2p.network.notifee_interface import INotifee from tests.utils import ( cleanup, echo_stream_handler, perform_two_host_set_up_custom_handler, ) -from libp2p import new_node, initialize_default_swarm -from libp2p.network.notifee_interface import INotifee -from libp2p.host.basic_host import BasicHost class MyNotifee(INotifee): diff --git a/tests/network/test_connection.py b/tests/network/test_connection.py index a2b2c20..0beadec 100644 --- a/tests/network/test_connection.py +++ b/tests/network/test_connection.py @@ -1,4 +1,5 @@ import asyncio + import pytest diff --git a/tests/peer/test_addrbook.py b/tests/peer/test_addrbook.py index d88de34..1cc273d 100644 --- a/tests/peer/test_addrbook.py +++ b/tests/peer/test_addrbook.py @@ -1,7 +1,6 @@ import pytest -from libp2p.peer.peerstore import PeerStoreError -from libp2p.peer.peerstore import PeerStore +from libp2p.peer.peerstore import PeerStore, PeerStoreError # Testing methods from IAddrBook base class. diff --git a/tests/peer/test_peerid.py b/tests/peer/test_peerid.py index 4c034e3..908e6b8 100644 --- a/tests/peer/test_peerid.py +++ b/tests/peer/test_peerid.py @@ -1,10 +1,11 @@ import random + +from Crypto.PublicKey import RSA +import base58 import multihash import pytest -import base58 -from Crypto.PublicKey import RSA -from libp2p.peer.id import ID +from libp2p.peer.id import ID ALPHABETS = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" diff --git a/tests/peer/test_peerinfo.py b/tests/peer/test_peerinfo.py index e98a877..dc4f6cd 100644 --- a/tests/peer/test_peerinfo.py +++ b/tests/peer/test_peerinfo.py @@ -1,13 +1,11 @@ import random +import multiaddr import pytest -import multiaddr - -from libp2p.peer.peerinfo import PeerInfo, info_from_p2p_addr, InvalidAddrError -from libp2p.peer.peerdata import PeerData from libp2p.peer.id import ID - +from libp2p.peer.peerdata import PeerData +from libp2p.peer.peerinfo import InvalidAddrError, PeerInfo, info_from_p2p_addr ALPHABETS = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" diff --git a/tests/peer/test_peermetadata.py b/tests/peer/test_peermetadata.py index 2d5e79e..412a151 100644 --- a/tests/peer/test_peermetadata.py +++ b/tests/peer/test_peermetadata.py @@ -1,8 +1,6 @@ import pytest - -from libp2p.peer.peerstore import PeerStoreError -from libp2p.peer.peerstore import PeerStore +from libp2p.peer.peerstore import PeerStore, PeerStoreError # Testing methods from IPeerMetadata base class. diff --git a/tests/protocol_muxer/test_protocol_muxer.py b/tests/protocol_muxer/test_protocol_muxer.py index a543601..775c460 100644 --- a/tests/protocol_muxer/test_protocol_muxer.py +++ b/tests/protocol_muxer/test_protocol_muxer.py @@ -1,7 +1,7 @@ import pytest -from tests.utils import cleanup, set_up_nodes_by_transport_opt from libp2p.protocol_muxer.multiselect_client import MultiselectClientError +from tests.utils import cleanup, set_up_nodes_by_transport_opt # TODO: Add tests for multiple streams being opened on different # protocols through the same connection diff --git a/tests/pubsub/configs.py b/tests/pubsub/configs.py index 31f50bb..e5adfad 100644 --- a/tests/pubsub/configs.py +++ b/tests/pubsub/configs.py @@ -1,6 +1,5 @@ from typing import NamedTuple - FLOODSUB_PROTOCOL_ID = "/floodsub/1.0.0" GOSSIPSUB_PROTOCOL_ID = "/gossipsub/1.0.0" diff --git a/tests/pubsub/dummy_account_node.py b/tests/pubsub/dummy_account_node.py index 083e10e..c2ca8bf 100644 --- a/tests/pubsub/dummy_account_node.py +++ b/tests/pubsub/dummy_account_node.py @@ -4,13 +4,11 @@ import uuid from libp2p.host.host_interface import IHost from libp2p.pubsub.floodsub import FloodSub from libp2p.pubsub.pubsub import Pubsub - from tests.configs import LISTEN_MADDR from .factories import FloodsubFactory, PubsubFactory from .utils import message_id_generator - CRYPTO_TOPIC = "ethereum" # Message format: diff --git a/tests/pubsub/factories.py b/tests/pubsub/factories.py index d48ffa1..9bcd4a7 100644 --- a/tests/pubsub/factories.py +++ b/tests/pubsub/factories.py @@ -7,10 +7,9 @@ from libp2p.host.basic_host import BasicHost from libp2p.pubsub.floodsub import FloodSub from libp2p.pubsub.gossipsub import GossipSub from libp2p.pubsub.pubsub import Pubsub - from tests.configs import LISTEN_MADDR -from .configs import FLOODSUB_PROTOCOL_ID, GOSSIPSUB_PROTOCOL_ID, GOSSIPSUB_PARAMS +from .configs import FLOODSUB_PROTOCOL_ID, GOSSIPSUB_PARAMS, GOSSIPSUB_PROTOCOL_ID def swarm_factory(): diff --git a/tests/pubsub/floodsub_integration_test_settings.py b/tests/pubsub/floodsub_integration_test_settings.py index dabcd89..009fa9b 100644 --- a/tests/pubsub/floodsub_integration_test_settings.py +++ b/tests/pubsub/floodsub_integration_test_settings.py @@ -8,7 +8,6 @@ from tests.utils import cleanup, connect from .configs import FLOODSUB_PROTOCOL_ID from .factories import PubsubFactory - SUPPORTED_PROTOCOLS = [FLOODSUB_PROTOCOL_ID] FLOODSUB_PROTOCOL_TEST_CASES = [ diff --git a/tests/pubsub/test_floodsub.py b/tests/pubsub/test_floodsub.py index 3134a16..c659929 100644 --- a/tests/pubsub/test_floodsub.py +++ b/tests/pubsub/test_floodsub.py @@ -3,13 +3,12 @@ import asyncio import pytest from libp2p.peer.id import ID - from tests.utils import cleanup, connect from .factories import FloodsubFactory from .floodsub_integration_test_settings import ( - perform_test_from_obj, floodsub_protocol_pytest_params, + perform_test_from_obj, ) diff --git a/tests/pubsub/test_gossipsub_backward_compatibility.py b/tests/pubsub/test_gossipsub_backward_compatibility.py index 2fef354..05b6c40 100644 --- a/tests/pubsub/test_gossipsub_backward_compatibility.py +++ b/tests/pubsub/test_gossipsub_backward_compatibility.py @@ -5,8 +5,8 @@ import pytest from .configs import FLOODSUB_PROTOCOL_ID from .factories import GossipsubFactory from .floodsub_integration_test_settings import ( - perform_test_from_obj, floodsub_protocol_pytest_params, + perform_test_from_obj, ) diff --git a/tests/pubsub/test_pubsub.py b/tests/pubsub/test_pubsub.py index bd21c9a..e382e8c 100644 --- a/tests/pubsub/test_pubsub.py +++ b/tests/pubsub/test_pubsub.py @@ -6,12 +6,10 @@ import pytest from libp2p.peer.id import ID from libp2p.pubsub.pb import rpc_pb2 - from tests.utils import connect from .utils import make_pubsub_msg - TESTING_TOPIC = "TEST_SUBSCRIBE" TESTING_DATA = b"data" diff --git a/tests/pubsub/utils.py b/tests/pubsub/utils.py index 0314bc1..d130207 100644 --- a/tests/pubsub/utils.py +++ b/tests/pubsub/utils.py @@ -3,7 +3,6 @@ from typing import Sequence from libp2p.peer.id import ID from libp2p.pubsub.pb import rpc_pb2 - from tests.utils import connect diff --git a/tests/routing/test_kad_peer_router.py b/tests/routing/test_kad_peer_router.py index 798df7e..69d374c 100644 --- a/tests/routing/test_kad_peer_router.py +++ b/tests/routing/test_kad_peer_router.py @@ -1,7 +1,7 @@ import pytest -from libp2p.peer.id import ID from libp2p.kademlia.network import KademliaServer +from libp2p.peer.id import ID from libp2p.routing.kademlia.kademlia_peer_router import KadmeliaPeerRouter diff --git a/tests/security/test_security_multistream.py b/tests/security/test_security_multistream.py index 674ff72..070f29d 100644 --- a/tests/security/test_security_multistream.py +++ b/tests/security/test_security_multistream.py @@ -1,4 +1,5 @@ import asyncio + import multiaddr import pytest @@ -7,10 +8,8 @@ from libp2p.peer.peerinfo import info_from_p2p_addr from libp2p.protocol_muxer.multiselect_client import MultiselectClientError from libp2p.security.insecure_security import InsecureTransport from libp2p.security.simple_security import SimpleSecurityTransport - from tests.utils import cleanup, connect - # TODO: Add tests for multiple streams being opened on different # protocols through the same connection diff --git a/tests/utils.py b/tests/utils.py index 36a4d9b..58a0880 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -1,5 +1,6 @@ -from contextlib import suppress import asyncio +from contextlib import suppress + import multiaddr from libp2p import new_node