Merge pull request #106 from zixuanzh/protocol-mux-lint
Fixing linting errors in protocol_muxer and adding to Travis
This commit is contained in:
commit
ba8d2491d4
|
@ -4,12 +4,14 @@ python:
|
||||||
- "3.6"
|
- "3.6"
|
||||||
|
|
||||||
install:
|
install:
|
||||||
|
- pip install --upgrade pip
|
||||||
- pip install -r requirements.txt
|
- pip install -r requirements.txt
|
||||||
- pip install codecov pytest pytest-cov
|
- pip install "pytest>=3.6"
|
||||||
|
- pip install codecov pytest-cov pytest-asyncio pylint
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- pytest --cov=./ -v
|
- 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:
|
after_success:
|
||||||
- codecov
|
- codecov
|
||||||
|
|
|
@ -72,21 +72,22 @@ class Multiselect(IMultiselectMuxer):
|
||||||
handshake_contents = await communicator.read_stream_until_eof()
|
handshake_contents = await communicator.read_stream_until_eof()
|
||||||
|
|
||||||
# Confirm that the protocols are the same
|
# 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")
|
raise MultiselectError("multiselect protocol ID mismatch")
|
||||||
|
|
||||||
# Handshake succeeded if this point is reached
|
# 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
|
def validate_handshake(handshake_contents):
|
||||||
# is added
|
"""
|
||||||
return handshake_contents == MULTISELECT_PROTOCOL_ID
|
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):
|
class MultiselectError(ValueError):
|
||||||
"""Raised when an error occurs in multiselect process"""
|
"""Raised when an error occurs in multiselect process"""
|
||||||
|
|
|
@ -30,22 +30,11 @@ class MultiselectClient(IMultiselectClient):
|
||||||
handshake_contents = await communicator.read_stream_until_eof()
|
handshake_contents = await communicator.read_stream_until_eof()
|
||||||
|
|
||||||
# Confirm that the protocols are the same
|
# 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")
|
raise MultiselectClientError("multiselect protocol ID mismatch")
|
||||||
|
|
||||||
# Handshake succeeded if this point is reached
|
# 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):
|
async def select_protocol_or_fail(self, protocol, stream):
|
||||||
"""
|
"""
|
||||||
Send message to multiselect selecting protocol
|
Send message to multiselect selecting protocol
|
||||||
|
@ -117,5 +106,17 @@ class MultiselectClient(IMultiselectClient):
|
||||||
else:
|
else:
|
||||||
raise MultiselectClientError("unrecognized response: " + response)
|
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):
|
class MultiselectClientError(ValueError):
|
||||||
"""Raised when an error occurs in protocol selection process"""
|
"""Raised when an error occurs in protocol selection process"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user