fixing linting errors with protocol_muxer and adding to Travis

This commit is contained in:
Robert Zajac 2019-01-09 20:24:41 -05:00
parent ab1aa0e7a8
commit 1dbe490623
4 changed files with 27 additions and 25 deletions

View File

@ -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

View File

@ -72,12 +72,13 @@ 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):
def validate_handshake(handshake_contents):
"""
Determine if handshake is valid and should be confirmed
:param handshake_contents: contents of handshake message

View File

@ -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"""