Add tests for jebp_utils
This commit is contained in:
@@ -90,7 +90,7 @@ async def readmsg(reader: asyncio.StreamReader, aesgcm: AESGCM = None, aesnonce:
|
||||
return aesgcm.decrypt(aesnonce, m, None)
|
||||
return m
|
||||
|
||||
def pack_fields(*fields: bytes) -> bytes:
|
||||
def pack_fields(fields: list[bytes]) -> bytes:
|
||||
'''
|
||||
Packs the fields into a compact bytestring.
|
||||
|
||||
@@ -100,11 +100,12 @@ def pack_fields(*fields: bytes) -> bytes:
|
||||
:return: The result
|
||||
:rtype: bytes
|
||||
'''
|
||||
|
||||
result = b''
|
||||
for field in fields:
|
||||
field_length = utils.int_to_bytes(len(field))
|
||||
field_length_length = utils.int_to_bytes(len(field_length))
|
||||
result += field_length_length + field_length + field
|
||||
payload_length = utils.int_to_bytes(len(field))
|
||||
payload_length_length = len(payload_length).to_bytes(1)
|
||||
result += payload_length_length + payload_length + field
|
||||
return result
|
||||
|
||||
def unpack_fields(raw: bytes) -> Sequence[bytes]:
|
||||
|
||||
Reference in New Issue
Block a user