import struct import hashlib import sys import unittest from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parents[1])) from aligned_lzss_banks import decode, members, banks from aot_overlay_spike.extract_generic import filter_full_discovery_seeds from aot_overlay_pipeline import positioned_sources def literal_stream(body): out = bytearray(b'\0' + (len(body) - 1).to_bytes(3, 'big')) for offset in range(0, len(body), 8): block = body[offset:offset + 8] out.append((1 << len(block)) - 1) out.extend(block) return bytes(out) def archive(*payloads): head = bytearray(64) struct.pack_into(' 24 more As. self.assertEqual(decode(bytes.fromhex('0800000101410094'))[0], b'A' * 25) # Parameter 7: zero length bits, distance occupies all 16 bits. self.assertEqual(decode(bytes.fromhex('0700000101410001'))[0], b'AAAA') def test_external_ram_and_truncation_rejected(self): for stream in [b'', bytes.fromhex('000000010141'), bytes.fromhex('0000000101410000'), bytes.fromhex('0000000101410100')]: with self.subTest(stream=stream), self.assertRaises(ValueError): decode(stream) with self.assertRaises(ValueError): decode(literal_stream(b'ab'), max_output=1) def test_selected_bank_and_uninterpreted_data(self): meta = literal_stream(struct.pack('