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

"""Opt-in source-public diagnostic contract; no game, socket or account access."""
import json
import os
import subprocess
import sys
def run(value):
environment=dict(os.environ)
environment.pop('GW_NATIVE_COMBAT_DIAGNOSTICS',None)
if value is not None:environment['GW_NATIVE_COMBAT_DIAGNOSTICS']=value
result=subprocess.run([sys.argv[1]],env=environment,capture_output=True,check=True,text=True)
return [json.loads(line.removeprefix('GWCombat ')) for line in result.stderr.splitlines() if line.startswith('GWCombat ')]
assert run(None)==run('true')==[], 'Diagnostics must require explicit opt-in1'
rows=run('1')
assert 0<len(rows)<=256
assert set(r['stage'] for r in rows)=={'sheath_request','attack_start','attack_stop','melee','spell_damage'}
keys={'sequence','source_packet','stage','opcode','attacker','victim','state','flags','damage','blocked'}
assert all(set(row)==keys and type(row['source_packet']) is int for row in rows)
assert [r['sequence'] for r in rows]==list(range(1,len(rows)+1))
assert all(r['attacker'].isdecimal() and r['victim'].isdecimal() for r in rows)
request=next(r for r in rows if r['stage']=='sheath_request')
assert (request['opcode'],request['attacker'],request['victim'],request['state'],request['flags'])==(0x3f001f,'4509','0',1,0x80)
assert all(r['opcode'] in (0x143,0x144,0x14a,0x250,0x3f001f) for r in rows)
spell=next(r for r in rows if r['stage']=='spell_damage')
assert (spell['opcode'],spell['attacker'],spell['state'],spell['damage'],spell['blocked'])==(0x250,'4509',23894,120,3)
print('Disabled-by-default diagnostics retain only bounded parsed public combat identities/state; original packet/state assertions pass unchanged.')