File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -94,6 +94,15 @@ class Bolt:
9494
9595 PROTOCOL_VERSION = None
9696
97+ @classmethod
98+ def get_handshake (cls ):
99+ """ Return the supported Bolt versions as bytes.
100+ The length is 16 bytes as specified in the Bolt version negotiation.
101+ :return: bytes
102+ """
103+ offered_versions = sorted (cls .protocol_handlers ().keys (), reverse = True )[:4 ]
104+ return b"" .join (version .to_bytes () for version in offered_versions ).ljust (16 , b"\x00 " )
105+
97106 @classmethod
98107 def protocol_handlers (cls , protocol_version = None ):
99108 """ Return a dictionary of available Bolt protocol handlers,
Original file line number Diff line number Diff line change @@ -48,3 +48,9 @@ def test_class_method_protocol_handlers_with_invalid_protocol_version():
4848 # python -m pytest tests/unit/io/test_class_bolt.py -s -v -k test_class_method_protocol_handlers_with_invalid_protocol_version
4949 with pytest .raises (TypeError ):
5050 Bolt .protocol_handlers (protocol_version = 2 )
51+
52+
53+ def test_class_method_get_handshake ():
54+ # python -m pytest tests/unit/io/test_class_bolt.py -s -v -k test_class_method_get_handshake
55+ handshake = Bolt .get_handshake ()
56+ assert handshake == b"\x00 \x00 \x00 \x04 \x00 \x00 \x00 \x03 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 "
You can’t perform that action at this time.
0 commit comments