Fix linting issues'

This commit is contained in:
Stuckinaboot 2019-05-01 13:54:19 -04:00
parent e555f17a7b
commit 4333c2d061
10 changed files with 31 additions and 31 deletions

View File

@ -2,6 +2,7 @@ import asyncio
import multiaddr import multiaddr
from Crypto.PublicKey import RSA from Crypto.PublicKey import RSA
from libp2p.security.insecure_security import InsecureTransport
from .peer.peerstore import PeerStore from .peer.peerstore import PeerStore
from .peer.id import id_from_public_key from .peer.id import id_from_public_key
from .network.swarm import Swarm from .network.swarm import Swarm
@ -10,7 +11,6 @@ from .kademlia.routed_host import RoutedHost
from .transport.upgrader import TransportUpgrader from .transport.upgrader import TransportUpgrader
from .transport.tcp.tcp import TCP from .transport.tcp.tcp import TCP
from .kademlia.network import KademliaServer from .kademlia.network import KademliaServer
from libp2p.security.insecure_security import InsecureTransport
async def cleanup_done_tasks(): async def cleanup_done_tasks():

View File

@ -1,7 +1,5 @@
import asyncio
from .raw_connection_interface import IRawConnection from .raw_connection_interface import IRawConnection
class RawConnection(IRawConnection): class RawConnection(IRawConnection):
def __init__(self, ip, port, reader, writer, initiator): def __init__(self, ip, port, reader, writer, initiator):

View File

@ -1,5 +1,7 @@
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
# pylint: disable=W0105
""" """
Represents a secured connection object, which includes a connection and details about the security Represents a secured connection object, which includes a connection and details about the security
involved in the secured connection involved in the secured connection
@ -19,4 +21,3 @@ class ISecureConn(ABC):
""" """
:return: map containing details about the connections security :return: map containing details about the connections security
""" """

View File

@ -1,7 +1,7 @@
import asyncio
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
# pylint: disable=W0105
""" """
Transport that is used to secure a connection. This transport is Transport that is used to secure a connection. This transport is
chosen by a security transport multistream module. chosen by a security transport multistream module.

View File

@ -1,9 +1,9 @@
import asyncio from abc import ABC
from abc import ABC, abstractmethod
from libp2p.protocol_muxer.multiselect_client import MultiselectClient from libp2p.protocol_muxer.multiselect_client import MultiselectClient
from libp2p.protocol_muxer.multiselect import Multiselect from libp2p.protocol_muxer.multiselect import Multiselect
# pylint: disable=W0105
""" """
Represents a secured connection object, which includes a connection and details about the security Represents a secured connection object, which includes a connection and details about the security
involved in the secured connection involved in the secured connection
@ -72,13 +72,15 @@ class SecurityMultistream(ABC):
:param initiator: true if we are the initiator, false otherwise :param initiator: true if we are the initiator, false otherwise
:return: selected secure transport :return: selected secure transport
""" """
# TODO: Is conn acceptable to multiselect/multiselect_client instead of stream? In go repo, # TODO: Is conn acceptable to multiselect/multiselect_client
# they pass in a raw conn (https://raw.githubusercontent.com/libp2p/go-conn-security-multistream/master/ssms.go) # instead of stream? In go repo, they pass in a raw conn
# (https://raw.githubusercontent.com/libp2p/go-conn-security-multistream/master/ssms.go)
protocol = None protocol = None
if initiator: if initiator:
# Select protocol if initiator # Select protocol if initiator
protocol = await self.multiselect_client.select_one_of(list(self.transports.keys()), conn) protocol = \
await self.multiselect_client.select_one_of(list(self.transports.keys()), conn)
else: else:
# Select protocol if non-initiator # Select protocol if non-initiator
protocol, _ = await self.multiselect.negotiate(conn) protocol, _ = await self.multiselect.negotiate(conn)

View File

@ -25,8 +25,8 @@ class TransportUpgrader:
""" """
if initiator: if initiator:
return await self.security_multistream.secure_outbound(raw_conn, peer_id) return await self.security_multistream.secure_outbound(raw_conn, peer_id)
else:
return await self.security_multistream.secure_inbound(raw_conn) return await self.security_multistream.secure_inbound(raw_conn)
def upgrade_connection(self, conn, generic_protocol_handler, peer_id): def upgrade_connection(self, conn, generic_protocol_handler, peer_id):
""" """

View File

@ -4,9 +4,8 @@ import pytest
from libp2p import new_node from libp2p import new_node
from libp2p.peer.peerinfo import info_from_p2p_addr from libp2p.peer.peerinfo import info_from_p2p_addr
from tests.utils import cleanup, set_up_nodes_by_transport_opt from libp2p.security.insecure_security import InsecureTransport
from libp2p.security.security_multistream import SecurityMultistream from tests.utils import cleanup
from libp2p.security.insecure_security import InsecureConn, InsecureTransport
from simple_security import SimpleSecurityTransport from simple_security import SimpleSecurityTransport
# TODO: Add tests for multiple streams being opened on different # TODO: Add tests for multiple streams being opened on different
@ -25,7 +24,8 @@ async def connect(node1, node2):
info = info_from_p2p_addr(addr) info = info_from_p2p_addr(addr)
await node1.connect(info) await node1.connect(info)
async def perform_simple_test(assertion_func, transports_for_initiator, transports_for_noninitiator): async def perform_simple_test(assertion_func, \
transports_for_initiator, transports_for_noninitiator):
# Create libp2p nodes and connect them, then secure the connection, then check # Create libp2p nodes and connect them, then secure the connection, then check
# the proper security was chosen # the proper security was chosen
@ -93,4 +93,3 @@ async def test_two_simple_test_security_transport_for_initiator_succeeds():
await perform_simple_test(assertion_func, await perform_simple_test(assertion_func,
transports_for_initiator, transports_for_noninitiator) transports_for_initiator, transports_for_noninitiator)