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

75 lines
3.9 KiB
Python

#!/usr/bin/env python3
"""One standalone Windows worker check; never launches/attaches the game."""
import argparse
import json
import struct
import subprocess
from pathlib import Path
MAGIC = 0x42495747
GENERATION = 0x5141495043
HEADER = struct.Struct('<IHHQQII')
def request(operation, sequence, max_payload):
# Independent field encoder. 640 is the reviewed ABI size, never a copied
# struct/pointer representation; no credentials, socket handles or keys.
values = struct.pack('<IIIQQ9I', 1, 640, operation, 0, 0,
0, 70334, 0, 0, 16, 0, 0, 0, 0)
body = values + struct.pack('<BBI', 1, 0, 0)
assert len(body) < max_payload
return HEADER.pack(MAGIC, 1, 1, GENERATION, sequence, len(body), 0) + body
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--host', required=True, type=Path)
parser.add_argument('--backend', required=True, type=Path)
parser.add_argument('--max-payload', required=True, type=int)
parser.add_argument('--report', required=True, type=Path)
args = parser.parse_args()
assert args.max_payload > 0
wire = b''.join(request(op, seq, args.max_payload)
for seq, op in enumerate((0, 18, 25, 0), start=1))
# Declared body is over the complete private frame bound: reject before
# reading/allocating it and before invoking the existing backend.
wire += HEADER.pack(MAGIC, 1, 1, GENERATION, 5,
args.max_payload + 65536, 0)
process = subprocess.run([str(args.host.resolve()), str(args.backend.resolve()),
str(GENERATION)], input=wire, capture_output=True,
timeout=20, check=False)
assert process.returncode == 1, 'malformed stream not rejected'
assert process.stderr == b'Standalone backend host stopped at its owned protocol boundary\n'.replace(b'\n', b'\r\n') or process.stderr == b'Standalone backend host stopped at its owned protocol boundary\n'
cursor = 0
summaries = []
for sequence, expected_op in enumerate((0, 18, 25, 0), start=1):
assert len(process.stdout) - cursor >= HEADER.size, 'reply missing'
magic, version, kind, generation, actual_seq, length, reserved = HEADER.unpack_from(process.stdout, cursor)
assert (magic, version, kind, generation, actual_seq, reserved) == (MAGIC, 1, 2, GENERATION, sequence, 0), 'reply ownership/context mismatch'
cursor += HEADER.size
payload = process.stdout[cursor:cursor + length]
assert len(payload) == length, 'reply truncated'
cursor += length
op, status, result, login, transport, opcode, required, consumed, value, rejection, packetop, packetbytes = struct.unpack_from('<IiiQQ7I', payload)
assert op == expected_op and status == 0 and login == transport == 0
assert result == (-1 if op == 25 else 0), 'real backend outcome not retained'
if op == 0:
assert value == 1, 'real backend ABI Ping mismatch'
if op == 18:
assert value == consumed == 0, 'unexpected backend owner state'
summaries.append({'sequence': sequence, 'operation': op,
'dispatch_status': status, 'backend_result': result})
assert cursor == len(process.stdout), 'unsolicited/extra reply'
args.report.write_text(json.dumps({
'status': 'PASS', 'boundary': 'owned anonymous pipes -> standalone host -> real existing backend ABI/codec dependency load',
'operations': summaries, 'malformed_declared_length_rejected_before_dispatch': True,
'game_client_started': False, 'authenticated': False, 'gameplay_verified': False,
'original_client_attachment_compatible': False,
'credentials_or_packet_payloads_recorded': False,
}, indent=2) + '\n', encoding='utf-8')
print('Standalone real backend load/Ping, response ownership and malformed length PASS')
if __name__ == '__main__':
main()