Files
WoW-Hybrid-gateway/tests/guild_bank_wire_admission_test.py

25 lines
1.4 KiB
Python

"""#91: every client opcode the guild bank translator accepts must also pass the Wire gameplay admission
(native/wine_pipe_host.c). The log query 0x2f0019 was translated but dropped at the Wire as client-drop."""
import re
from pathlib import Path
root=Path(__file__).resolve().parents[1]
host=(root/'native/wine_pipe_host.c').read_text()
bank=(root/'native/guild_bank_translation.cpp').read_text()
body=bank[bank.index('NativeWorldTranslation::bank_request('):]
body=body[:body.index('if(!bank_current())')]
accepted=set(re.findall(r'opcode\s*[!=]=\s*(0x[0-9a-f]+)',body))
for lo,hi in re.findall(r'opcode\s*>=\s*(0x[0-9a-f]+)\s*&&\s*opcode\s*<=\s*(0x[0-9a-f]+)',body):
accepted|={hex(v) for v in range(int(lo,16),int(hi,16)+1)}
expressions=re.findall(r'if\(([^{}]+)\)\{\s*init\(&c,GW_WIRE_GAMEPLAY\)',host)
assert len(expressions)>=1,'gameplay admission branch not found'
admitted=set()
for x in expressions:
admitted|={hex(int(v,16)) for v in re.findall(r'opcode\s*==\s*(0x[0-9a-f]+)',x)}
for lo,hi in re.findall(r'opcode\s*>=\s*(0x[0-9a-f]+)\s*&&\s*opcode\s*<=\s*(0x[0-9a-f]+)',x):
admitted|={hex(v) for v in range(int(lo,16),int(hi,16)+1)}
accepted={hex(int(v,16)) for v in accepted}
missing=sorted(accepted-admitted)
assert len(accepted)>=15,f'bank opcode extraction too small: {sorted(accepted)}'
assert not missing,f'guild bank opcodes translated but not admitted by the Wire: {missing}'
print(f'guild bank wire admission PASS: {len(accepted)} opcodes')