From 1dbe4906233cefb67f8cbebeffa31e0cc2b024d6 Mon Sep 17 00:00:00 2001 From: Robert Zajac Date: Wed, 9 Jan 2019 20:24:41 -0500 Subject: [PATCH] fixing linting errors with protocol_muxer and adding to Travis --- .travis.yml | 2 +- protocol_muxer/multiselect.py | 21 +++++++++-------- protocol_muxer/multiselect_client.py | 27 +++++++++++----------- protocol_muxer/multiselect_communicator.py | 2 +- 4 files changed, 27 insertions(+), 25 deletions(-) diff --git a/.travis.yml b/.travis.yml index 77ec45a..0b86cdb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ install: script: - pytest --cov=./ -v - - pylint --rcfile=.pylintrc encryption host libp2p network peer stream_muxer transport tests + - pylint --rcfile=.pylintrc encryption host libp2p network peer protocol_muxer stream_muxer transport tests after_success: - codecov diff --git a/protocol_muxer/multiselect.py b/protocol_muxer/multiselect.py index b2f4532..971547b 100644 --- a/protocol_muxer/multiselect.py +++ b/protocol_muxer/multiselect.py @@ -72,21 +72,22 @@ class Multiselect(IMultiselectMuxer): handshake_contents = await communicator.read_stream_until_eof() # Confirm that the protocols are the same - if not self.validate_handshake(handshake_contents): + if not validate_handshake(handshake_contents): raise MultiselectError("multiselect protocol ID mismatch") # Handshake succeeded if this point is reached - def validate_handshake(self, handshake_contents): - """ - Determine if handshake is valid and should be confirmed - :param handshake_contents: contents of handshake message - :return: true if handshake is complete, false otherwise - """ - # TODO: Modify this when format used by go repo for messages - # is added - return handshake_contents == MULTISELECT_PROTOCOL_ID +def validate_handshake(handshake_contents): + """ + Determine if handshake is valid and should be confirmed + :param handshake_contents: contents of handshake message + :return: true if handshake is complete, false otherwise + """ + + # TODO: Modify this when format used by go repo for messages + # is added + return handshake_contents == MULTISELECT_PROTOCOL_ID class MultiselectError(ValueError): """Raised when an error occurs in multiselect process""" diff --git a/protocol_muxer/multiselect_client.py b/protocol_muxer/multiselect_client.py index c455877..5aeecea 100644 --- a/protocol_muxer/multiselect_client.py +++ b/protocol_muxer/multiselect_client.py @@ -9,7 +9,7 @@ class MultiselectClient(IMultiselectClient): Client for communicating with receiver's multiselect module in order to select a protocol id to communicate over """ - + def __init__(self): pass @@ -30,22 +30,11 @@ class MultiselectClient(IMultiselectClient): handshake_contents = await communicator.read_stream_until_eof() # Confirm that the protocols are the same - if not self.validate_handshake(handshake_contents): + if not validate_handshake(handshake_contents): raise MultiselectClientError("multiselect protocol ID mismatch") # Handshake succeeded if this point is reached - def validate_handshake(self, handshake_contents): - """ - Determine if handshake is valid and should be confirmed - :param handshake_contents: contents of handshake message - :return: true if handshake is complete, false otherwise - """ - - # TODO: Modify this when format used by go repo for messages - # is added - return handshake_contents == MULTISELECT_PROTOCOL_ID - async def select_protocol_or_fail(self, protocol, stream): """ Send message to multiselect selecting protocol @@ -117,5 +106,17 @@ class MultiselectClient(IMultiselectClient): else: raise MultiselectClientError("unrecognized response: " + response) + +def validate_handshake(handshake_contents): + """ + Determine if handshake is valid and should be confirmed + :param handshake_contents: contents of handshake message + :return: true if handshake is complete, false otherwise + """ + + # TODO: Modify this when format used by go repo for messages + # is added + return handshake_contents == MULTISELECT_PROTOCOL_ID + class MultiselectClientError(ValueError): """Raised when an error occurs in protocol selection process""" diff --git a/protocol_muxer/multiselect_communicator.py b/protocol_muxer/multiselect_communicator.py index bfdeabf..56b5b99 100644 --- a/protocol_muxer/multiselect_communicator.py +++ b/protocol_muxer/multiselect_communicator.py @@ -6,7 +6,7 @@ class MultiselectCommunicator(IMultiselectCommunicator): and multistream module will follow the same multistream protocol, which is necessary for them to work """ - + def __init__(self, stream): self.stream = stream