883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
36 lines
1.9 KiB
Python
36 lines
1.9 KiB
Python
#!/usr/bin/env python3
|
|
"""Compare standalone creature replies to pinned Forever source serialization.
|
|
This is an independent serialization oracle, not proof of actual client behavior.
|
|
"""
|
|
from pathlib import Path
|
|
import struct
|
|
import subprocess
|
|
import sys
|
|
root=Path(__file__).resolve().parents[1]
|
|
build=root/'build/forever-schema'
|
|
driver=build/'query-fixture.cpp'
|
|
driver.write_text('''#include "gateway/queries.hpp"
|
|
#include <iostream>
|
|
int main() {
|
|
try {
|
|
gateway::Bytes bytes;char c;while(std::cin.get(c))bytes.push_back(uint8_t(c));
|
|
gateway::Reader r(bytes);auto cls=r.le(1);auto raw=r.take(r.left());
|
|
auto result=gateway::forever_creature_template(gateway::turtle_creature_template(raw),cls);
|
|
std::cout.write(reinterpret_cast<const char*>(result.data()),result.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/'query-fixture')],check=True)
|
|
def wire(entry,names,title,flags=0,leader=0):
|
|
return bytes([1])+struct.pack('<I',entry)+b''.join(n.encode()+b'\0' for n in names)+title.encode()+b'\0'+struct.pack('<7I2B',flags,7,0,0,0,0,1859,0,leader)
|
|
cases=[wire(197,['Marshal McBride','','',''],''),
|
|
wire(6,['Primary','Second','Third','Fourth'],'A title',0x12345678,1),
|
|
wire(38,['N'*255,'','',''],'T'*255),
|
|
bytes([0])+struct.pack('<I',197|0x80000000)]
|
|
for value in cases:
|
|
direct=subprocess.run([str(build/'query-fixture')],input=value,capture_output=True,check=True).stdout
|
|
native=subprocess.run([sys.argv[1],'--creature-template'],input=value,capture_output=True,check=True).stdout
|
|
assert direct==native, (len(direct),len(native),'standalone/native query mismatch')
|
|
print('4 creature-template cases match pinned Forever source bytes; actual names require client testing.')
|