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

45 lines
2.8 KiB
Python

#!/usr/bin/env python3
"""New schema-only boundary; no registry, method, row or process reads."""
import importlib.util,json,struct
from pathlib import Path
root=Path(__file__).resolve().parents[1]
spec=importlib.util.spec_from_file_location('engine_session_inspect',root/'ops/engine_session_inspect.py');m=importlib.util.module_from_spec(spec);spec.loader.exec_module(m)
class Memory:
def __init__(self,field_count=3,row_size=32,offsets=(0,8,16),counts=(1,2,1),types=(2,1,0)):
self.cells={};self.reads=[]
for n,(name,descriptor) in enumerate(m.MAP_AREA_TYPED_DESCRIPTORS):
schema=0x200000+n*0x1000;self.put(descriptor+8,struct.pack('<Q',schema));self.put(schema+0x10,struct.pack('<2I',row_size,field_count))
arrays=(schema+0x100,schema+0x300,schema+0x500)
self.put(schema+0x20,struct.pack('<3Q',*arrays))
for address,values in zip(arrays,(offsets,counts,types)):self.put(address,struct.pack('<'+'I'*len(values),*values))
def put(self,address,data):
for n,value in enumerate(data):self.cells[address+n]=value
def read(self,address,size):
assert 0<size<=512
self.reads.append((address,size))
if any(address+n not in self.cells for n in range(size)):raise ValueError('Unreadable fixture mapping')
return bytes(self.cells[address+n] for n in range(size))
def run(self):return m.inspect_map_area_schemas(self.read)
def main():
memory=Memory();result=memory.run()
assert len(memory.reads)==12
assert all(x['field_count']==3 and x['row_size']==32 and x['wire_types']==[2,1,0] and x['offsets']==[0,8,16] and x['element_counts']==[1,2,1] for x in result['tables'])
assert all(x['source_defaults_or_semantic_type_aliases_proven'] is False for x in result['tables'])
checks=1
for args in ({'field_count':129},{'field_count':0},{'row_size':65537},{'row_size':0},{'offsets':(0,8,32)},{'counts':(1,0,1)},{'types':(2,6,0)}):
memory=Memory(**args);held=memory.run()
assert all(x['status']=='schema-mapping-or-shape-held' for x in held['tables'])
if 'field_count' in args or 'row_size' in args:assert len(memory.reads)==4
checks+=1
memory=Memory();memory.cells.pop(0x200100)
assert memory.run()['tables'][0]['status']=='schema-mapping-or-shape-held';checks+=1
pinned=m.MAP_AREA_TYPED_DESCRIPTORS;m.MAP_AREA_TYPED_DESCRIPTORS=(('Map',0xdead000),)
memory=Memory();assert memory.run()['status']=='fixed-descriptor-pins-held' and memory.reads==[]
m.MAP_AREA_TYPED_DESCRIPTORS=pinned;checks+=1
assert m.ENABLE_MAP_AREA_SCHEMA_LOOKUP is False
print(json.dumps({'status':'PASS','new_schema_checks':checks,'process_or_auth_reads':False,'registry_or_method_checks_repeated':False,'default_lookup_enabled':False}))
if __name__=='__main__':main()