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

28 lines
1.7 KiB
Python

#!/usr/bin/env python3
"""Independent original70334 UnitData mount bit61 goldens; offline only."""
import os,struct,sys
from pathlib import Path
sys.path.insert(0,str(Path(__file__).resolve().parent))
from native_codec_driver import ROOT,load,serialize,MODES
if not Path(os.environ.get('GW_TEST_CODEC_PATH',ROOT/'build/forever-schema/libforever_codec.so')).is_file():sys.exit(77)
P=struct.pack;library=load()
def packed(raw):return P('<'+('H'if len(raw)==16 else'B'),sum(1<<i for i,b in enumerate(raw)if b))+bytes(b for b in raw if b)
for owner in(4518,(0xf130<<48)|(3310<<24)|1):
modern=P('<QQ',owner if owner<2**32 else owner&0xffffff,(2<<58)|(70<<42)if owner<2**32 else(8<<58)|(70<<42)|(1<<29)|(3310<<6))
for mount in(0,1566,2224,0x7fffffff):
# Source133 -> target group32/bit61. Mask block1=0x20000001,
# blocks-presence0x02; original build70334 adds one false bit then flush.
values=bytes([int(owner==4518),0,3])+P('<I',32)+bytes.fromhex('022000000100')+P('<I',mount)
block=b'\0'+packed(modern)+P('<I',len(values))+values
expected=P('<HIBI',1,1,128,len(block))+block
body=P('<IBB',1,0,0)+packed(P('<Q',owner))+bytes([5])+P('<5I',0,0,0,0,1<<5)+P('<I',mount)
header=P('<HIQI',70,1,4518,0xa9)
actual=serialize(library,MODES.index('--unit-values'),header+body)
assert actual==expected,('Mount display identity/explicit clear/ownership mask differs',mount,actual.hex(),expected.hex())
# Reject negative destination representations rather than overflow int32.
bad=body[:-4]+P('<I',0x80000000)
try:serialize(library,MODES.index('--unit-values'),header+bad)
except ValueError:pass
else:raise AssertionError('Invalid source mount display accepted')
print('8 independent self/NPC native mount-display delta/clear goldens pass; no live rendering claim.')