Payload shorter than code_len raises ValueError.
()
| 99 | |
| 100 | |
| 101 | def test_bytecode_decode_length_mismatch(): |
| 102 | """Payload shorter than code_len raises ValueError.""" |
| 103 | import struct |
| 104 | import zlib |
| 105 | |
| 106 | import pytest |
| 107 | |
| 108 | code = b"\xff" |
| 109 | crc = zlib.crc32(code) & 0xFFFF_FFFF |
| 110 | # Claim code_len=5 but provide only 1 byte. |
| 111 | bad_len = b"XQBC" + bytes([1, 0, 0]) + struct.pack(">II", 5, crc) + code |
| 112 | with pytest.raises(ValueError, match="length mismatch"): |
| 113 | program_from_bytecode(bad_len) |
| 114 | |
| 115 | |
| 116 | def test_bytecode_decode_crc_mismatch(): |
nothing calls this directly
no test coverage detected