Skip to content

Fix protocol negotiation for 4.0 servers #559

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions neo4j/io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,23 +239,24 @@ def version_list(cls, versions, limit=4):
returned is limited to four.
"""
ranges_supported = versions[0] >= Version(4, 3)
without_changes = {Version(4, 2)}
if versions and ranges_supported:
start, end = 0, 0
first_major = versions[start][0]
minors = []
for end, version in enumerate(versions):
for version in versions:
if version[0] == first_major:
minors.append(version[1])
else:
break
new_versions = ([Version(first_major, minors)] + versions[1:end])[:(limit - 1)]
try:
new_versions.append(versions[end])
except IndexError:
pass
return new_versions
new_versions = [
Version(first_major, minors),
*(v for v in versions[1:] if v not in without_changes)
]
else:
return versions[:limit]
new_versions = [v for v in versions if v not in without_changes]
new_versions = [*new_versions[:(limit - 1)], versions[-1]]
return new_versions

@classmethod
def get_handshake(cls):
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/io/test_class_bolt.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_class_method_protocol_handlers_with_invalid_protocol_version():
def test_class_method_get_handshake():
# python -m pytest tests/unit/io/test_class_bolt.py -s -v -k test_class_method_get_handshake
handshake = Bolt.get_handshake()
assert handshake == b"\x00\x03\x03\x04\x00\x00\x02\x04\x00\x00\x01\x04\x00\x00\x00\x03"
assert handshake == b"\x00\x03\x03\x04\x00\x00\x01\x04\x00\x00\x00\x04\x00\x00\x00\x03"


def test_magic_preamble():
Expand Down