883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
26 lines
1.2 KiB
Python
26 lines
1.2 KiB
Python
"""Guard the exact inline-ID mismatch that asserted in actual70334 DB2 loading."""
|
|
import hashlib
|
|
from pathlib import Path
|
|
import struct
|
|
import sys
|
|
import unittest
|
|
sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'ops'))
|
|
from item_sparse_compat import package_payloads
|
|
|
|
class InlineTextureTest(unittest.TestCase):
|
|
def row(self,outer,inner):
|
|
wire=struct.pack('<iBi',inner,0,25480)
|
|
return dict(table_name='TextureFileData',table_hash='0x1a473014',id=outer,
|
|
wire_hex=wire.hex(),sha256=hashlib.sha256(wire).hexdigest())
|
|
def test_matching_inline_identity_serializes(self):
|
|
self.assertTrue(package_payloads([self.row(149060,149060)])[0])
|
|
def test_valid_hash_cannot_hide_mismatching_inline_identity(self):
|
|
with self.assertRaisesRegex(ValueError,'inline primary key'):
|
|
package_payloads([self.row(149060,8529368)])
|
|
def test_truncated_correct_hash_rejected(self):
|
|
row=self.row(149060,149060);raw=bytes.fromhex(row['wire_hex'])[:-1]
|
|
row.update(wire_hex=raw.hex(),sha256=hashlib.sha256(raw).hexdigest())
|
|
with self.assertRaisesRegex(ValueError,'inline primary key'):package_payloads([row])
|
|
|
|
if __name__=='__main__':unittest.main()
|