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

101 lines
5.1 KiB
Python

#!/usr/bin/env python3
"""Changed continent presentation/activation field boundary; no asset acceptance."""
import copy
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_component_links_candidate
def chunk(tag,data):
return tag[::-1].encode()+struct.pack('<I',len(data))+data
def fixture(mid):
globals_={0:[970,1100798,1101056,1668812,2488184,775969,775970,0],
1:[970,1100658,1100779,1668820,2023510,782777,782778,0]}[mid]
main=bytearray(struct.pack('<II',2,0)*4096)
maid=bytearray(131072)
struct.pack_into('<II',main,(3*64+2)*8,1,0)
struct.pack_into('<8I',maid,(3*64+2)*32,101,102,103,104,105,106,107,108)
return (chunk('MVER',struct.pack('<I',18))+chunk('MPHD',struct.pack('<8I',*globals_))
+chunk('MAIN',main)+chunk('MAID',maid)+chunk('MAI2',bytes(range(256))*512))
class Openworld529PresentationTest(unittest.TestCase):
def test_whole_profile_activation_preservation_and_refusals(self):
for mid,control in [(0,775971),(1,782779)]:
raw=fixture(mid)
kw=dict(native_file_data_id=control,native_sha256=hashlib.sha256(raw).hexdigest(),
allow_source_obj0=True,presentation_profile='original529-five-role-MAI2',
source_active_tiles={(7,8)},source_empty_obj1_tiles={(7,8)},
tile_file_data_ids={(2,3):{'OBJ0':202},(7,8):dict(ROOT=1001,OBJ0=1002,
OBJ1=790799,TEX0=1004,MINIMAP=1008)})
out,audit=wdt_native_component_links_candidate(raw,**kw)
self.assertEqual(struct.unpack_from('<I',out,20)[0],0x24a)
self.assertEqual(struct.unpack_from('<2I',out,60+(8*64+7)*8),(1,0))
self.assertEqual(struct.unpack_from('<8I',out,32836+(3*64+2)*32),
(101,202,103,104,0,0,0,108))
self.assertEqual(struct.unpack_from('<8I',out,32836+(8*64+7)*32),
(1001,1002,790799,1004,0,0,0,1008))
# An independent exact byte allowlist proves that global6, all
# opaque MAI2 bytes, inactive cells and unrelated operands survive.
restore=bytearray(out)
spans=[(20,4),(60+(8*64+7)*8,8)]
spans += [(32836+(3*64+2)*32+4*i,4) for i in (1,4,5,6)]
spans += [(32836+(8*64+7)*32+4*i,4) for i in (0,1,2,3,7)]
for at,size in spans:restore[at:at+size]=raw[at:at+size]
self.assertEqual(bytes(restore),raw)
self.assertEqual(audit['presentation_MapID'],mid)
self.assertFalse(audit['native_profile_flags_preserved'])
self.assertFalse(audit['runtime_activation_verified'])
self.assertEqual(len(audit['activated_MAIN_cells']),1)
raw=fixture(0)
def body(at,fmt,value):
b=bytearray(raw);struct.pack_into(fmt,b,at,value);return bytes(b)
def revised(**changes):
out=copy.deepcopy(kw);out['native_file_data_id']=775971;out.update(changes);return out
good=revised()
bindings=good['tile_file_data_ids']
cases=[(raw,revised(presentation_profile='guessed-bits')),
(raw,revised(native_file_data_id=790377)),
(raw,revised(native_file_data_id=782779)),
(raw,revised(allow_source_obj0=False)),
(raw,revised(source_active_tiles=())),
(raw,revised(source_empty_obj1_tiles=())),
(body(24,'<I',999),good),
(body(60+(8*64+7)*8,'<I',0),good),
(body(60+(8*64+7)*8+4,'<I',1),good),
(body(32836+(8*64+7)*32,'<I',999),good),
(body(32836+(3*64+2)*32+28,'<I',0),good)]
for role in ('OBJ1','MINIMAP'):
b=copy.deepcopy(bindings);del b[(7,8)][role]
cases.append((raw,revised(tile_file_data_ids=b)))
b=copy.deepcopy(bindings);b[(7,8)]['LOD']=99
cases.append((raw,revised(tile_file_data_ids=b)))
b=copy.deepcopy(bindings);b[(7,8)]['MINIMAP']=True
cases.append((raw,revised(tile_file_data_ids=b)))
# Existing default may not acquire the new activation path implicitly.
cases.append((raw,revised(presentation_profile=None,source_active_tiles=())))
for index,(data,args) in enumerate(cases):
with self.subTest(refusal=index),self.assertRaises(ValueError):
wdt_native_component_links_candidate(data,**args)
result=dict(status='PASS_CHANGED_MAP0_MAP1_ORIGINAL529_PRESENTATION_ACTIVATION_BOUNDARY',
maps=2,structural_fixture_new_cells=2,refusals=len(cases),
complete_profile_0x24a_not_individual_bit_projection=True,
all_nonallowlisted_bytes_exact=True,own_global6_and_MAI2_exact=True,
default_activation_gate_preserved=True,actual_Source_binding_or_native_acceptance=False,
old_asset_or_native_tests_repeated=False)
job=BASE/'runtime/continuation-20261026/openworld-MAIN-activation-contract'
job.mkdir(exist_ok=True)
(job/'producer-focused-result.json').write_text(json.dumps(result,indent=2)+'\n')
if __name__=='__main__':unittest.main()