Files
WoW-Hybrid-gateway/tests/global_wdt_root_tex_links_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

65 lines
3.2 KiB
Python

#!/usr/bin/env python3
"""Only the two qualified same-map global WDT operands may change."""
import hashlib
import json
import struct
import sys
import unittest
from pathlib import Path
BASE=Path(__file__).resolve().parents[1]
sys.path.insert(0,str(BASE/'ops'))
from map_asset_preflight import wdt_native_global_links_candidate
def chunk(tag,data):return tag[::-1].encode('ascii')+struct.pack('<I',len(data))+data
class GlobalWdtLinksTest(unittest.TestCase):
def test_exact_root_tex_field_union_and_refusals(self):
modf=struct.pack('<II12f4H',100,0xffffffff,*range(12),8,3,7,1024)
raw=(chunk('MVER',struct.pack('<I',18))
+chunk('MPHD',struct.pack('<8I',577,11,22,33,44,55,66,77))
+chunk('MAIN',bytes(32768))+chunk('MAID',bytes(131072))
+chunk('MODF',modf)+chunk('MAI2',b'opaque native operand bytes'))
mphd=20;modf_at=raw.index(b'FDOM')+8
args=dict(map_id=34,baseline_file_data_id=400,
baseline_sha256=hashlib.sha256(raw).hexdigest(),
expected_root_file_data_id=100,expected_tex_file_data_id=55,
root_file_data_id=200,tex_file_data_id=300)
out,audit=wdt_native_global_links_candidate(raw,**args)
self.assertEqual(struct.unpack_from('<I',out,modf_at)[0],200)
self.assertEqual(struct.unpack_from('<I',out,mphd+20)[0],300)
restored=bytearray(out)
struct.pack_into('<I',restored,modf_at,100)
struct.pack_into('<I',restored,mphd+20,55)
self.assertEqual(bytes(restored),raw)
self.assertEqual(out[modf_at+4:modf_at+64],raw[modf_at+4:modf_at+64])
self.assertEqual({r['role']for r in audit['changes']},{'MODF_ROOT','MPHD_TEX'})
def changed(at,fmt,value):
b=bytearray(raw);struct.pack_into(fmt,b,at,value);return bytes(b)
cases=[(raw,dict(args,root_file_data_id=0)),
(raw,dict(args,tex_file_data_id=True)),
(raw,dict(args,expected_root_file_data_id=101)),
(raw,dict(args,expected_tex_file_data_id=56)),
(raw,dict(args,baseline_file_data_id=0)),
(raw,dict(args,baseline_sha256='unqualified')),
(changed(mphd,'<I',0),args),
(changed(raw.index(b'NIAM')+8,'<I',1),args),
(changed(modf_at+56,'<H',12),args),
(changed(modf_at+62,'<H',512),args),
(raw[:-1],args),(raw+chunk('MODF',modf),args)]
for index,(body,kw)in enumerate(cases):
with self.subTest(index=index),self.assertRaises(ValueError):
wdt_native_global_links_candidate(body,**kw)
job=BASE/'runtime/continuation-20261026/global-TEX-mip-cache-producer'
result=dict(status='PASS_SAME_MAP_GLOBAL_WDT_ROOT_TEX_LINKER_SYNTHETIC_BOUNDARY',
changed_operands=['MODF_rootFDI','MPHD_TEX_word5'],refusals=len(cases),
source52_and_native8_MODF_bytes_preserved=True,
other_MPHD_MAIN_MAID_MAI2_and_all_other_bytes_exact=True,
original_body_reads=0,actual_asset_bindings_or_runtime_verified=False)
(job/'WDT-root-TEX-linker-focused-result.json').write_text(json.dumps(result,indent=2)+'\n')
if __name__=='__main__':unittest.main()