Files
WoW-Hybrid-gateway/tests/lod_liquid_chunk_test.py
praxisandClaude Fable 5.2 7f2139d8d0 Offline test fixtures
883 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

43 lines
1.8 KiB
Python

#!/usr/bin/env python3
"""Focused native MLLD framing checks; full native census is a runtime receipt."""
import sys
import unittest
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'ops'))
from lod_liquid_chunk import pack_mlld, unpack_mlld # noqa: E402
class MlldTest(unittest.TestCase):
def test_native_sample_round_trip(self):
# Clean-parent native _lod file 1286528: 3+3 encoded bytes, two pads.
body = bytes.fromhex('070000000300030000000000c000ff8800ff0000')
self.assertEqual(unpack_mlld(body), (7, bytes.fromhex('c000ff'), bytes.fromhex('8800ff'), 0))
self.assertEqual(pack_mlld(*unpack_mlld(body)), body)
def test_source_payload_lengths_are_aligned(self):
for payload_size in range(8):
with self.subTest(payload_size=payload_size):
depth = bytes(range(payload_size))
alpha = b'\x81\x02\x03'
body = pack_mlld(7, depth, alpha)
required = -(12 + len(depth) + len(alpha)) % 4
self.assertEqual(len(body) % 4, 0)
self.assertEqual(body[-required:] if required else b'', bytes(required))
self.assertEqual(unpack_mlld(body), (7, depth, alpha, 0))
def test_opaque_and_flags_survive_round_trip(self):
body = pack_mlld(5, b'\x01', b'\x02\x03', 0x78563412)
self.assertEqual(unpack_mlld(body), (5, b'\x01', b'\x02\x03', 0x78563412))
def test_rejects_non_native_padding(self):
body = pack_mlld(7, b'\x01', b'\x02')
for bad in (body[:-1], body + b'\0\0\0\0', body[:-1] + b'\x01'):
with self.subTest(bad=bad):
with self.assertRaises(ValueError):
unpack_mlld(bad)
if __name__ == '__main__':
unittest.main()