Add tests for jebp_utils

This commit is contained in:
2026-04-02 12:34:21 +02:00
parent b12555d883
commit 32ed782fef
5 changed files with 119 additions and 4 deletions
+5 -4
View File
@@ -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]: