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

32 lines
1.7 KiB
Python

#!/usr/bin/env python3
"""Vendor byte comparisons against the pinned native writer; no client claim."""
from pathlib import Path
import struct
import subprocess
import sys
root=Path(__file__).resolve().parents[1]
build=root/'build/forever-schema'
driver=build/'vendor-fixture.cpp'
driver.write_text('''#include "gateway/gameplay.hpp"
#include "gateway/object_updates.hpp"
#include <iostream>
int main(){try { gateway::Bytes b;char c;while(std::cin.get(c))b.push_back(uint8_t(c));
gateway::Reader r(b);auto realm=r.le(2),map=r.le(4);
auto v=gateway::turtle_vendor_inventory(r.take(r.left()));
auto out=gateway::forever_vendor_inventory(v,gateway::forever_creature_guid(v.guid,uint32_t(v.guid>>24)&0xFFFFFF,realm,map));
std::cout.write(reinterpret_cast<const char*>(out.data()),out.size());
}catch(const std::exception& e){std::cerr<<e.what();return 1;}}
''')
subprocess.run(['clang++','-std=c++20','-I'+str(root/'include'),str(driver),str(root/'build/libgateway_protocol.a'),'-lcrypto','-lz','-o',str(build/'vendor-fixture')],check=True)
P=struct.pack
rows=[(1,25,1710,0xFFFFFFFF,7,20,1),(2,117,6399,4,25,0,5)]
cases=[P('<QB',0xF130000098000001,len(items))+b''.join(P('<7I',*r) for r in items) for items in [rows[:1],rows,rows*0]]
cases[-1]+=b'\x00'
cases += [P('<QBB',0xF130000098000001,0,reason) for reason in [1,2]]
for body in cases:
wire=P('<HI',70,0)+body
direct=subprocess.run([str(build/'vendor-fixture')],input=wire,capture_output=True,check=True).stdout
native=subprocess.run([sys.argv[1],'--vendor-inventory'],input=wire,capture_output=True,check=True).stdout
assert direct==native,'Vendor bytes differ from pinned native serializer'
print(len(cases),'vendor cases match pinned native bytes; actual merchant UI requires client evidence.')