35 lines
2.3 KiB
Python
35 lines
2.3 KiB
Python
"""Q103(5) stance codec: 3 SpellMisc replies changed, every other provider response key identical, startup identical, re-keyed pages."""
|
|
import json,os,struct,sys,hashlib
|
|
from pathlib import Path
|
|
J=Path(__file__).resolve().parent
|
|
sys.path.insert(0,'/mnt/Games/@project/build/q103-spell-parity-20261128')
|
|
import overlay
|
|
from spell_aura_restrictions_hotfix_fixture import db_query
|
|
sys.path.insert(0,'/mnt/Games/@project/build/q103-charge-provider-20261128')
|
|
from importlib.util import spec_from_file_location,module_from_spec
|
|
s=spec_from_file_location('cp','/mnt/Games/@project/build/q103-charge-provider-20261128/compose.py');base=module_from_spec(s);s.loader.exec_module(base)
|
|
def opened(p):
|
|
os.environ['GW_TEST_CODEC_PATH']=str(p);return overlay.load()
|
|
old=opened(J/'current/host/libforever_codec.so');new=opened(J/'stance2/host/libforever_codec.so')
|
|
prov=json.load(open('/mnt/Games/@project/build/q103-stance-on-f28e-20261128/provider2.json'));prov['responses']=json.load(open('/mnt/Games/@project/build/q103-stance-presentation-20261128/provider.json'))['responses']
|
|
want={(r['table'],r['id']):r for r in prov['records']}
|
|
H={'SpellMisc':0xc603b228,'SpellShapeshift':None}
|
|
changed=same=0
|
|
for r in prov['records']:
|
|
a=db_query(old,r['table'],r['id']);b=db_query(new,r['table'],r['id'])
|
|
assert a[17:]==bytes.fromhex(r['before']) and b[17:]==bytes.fromhex(r['after']) and a[:17]==b[:17],r['id'];changed+=1
|
|
tab=prov['records'][0]['table']
|
|
for k in prov['responses']:
|
|
t,i=k.split('/');i=int(i)
|
|
if t!='SpellMisc' or (tab,i) in want:continue
|
|
assert db_query(old,tab,i)==db_query(new,tab,i),k;same+=1
|
|
fa,pa=overlay.initialization(old);fb,pb=overlay.initialization(new)
|
|
assert fa==fb and pa==pb
|
|
m=json.load(open(J/'stance2/candidate.json'))
|
|
for pg in m['changed_pages']:
|
|
assert hashlib.sha256(overlay.request(old,[pg['before']])).hexdigest()==pg['before_reply_sha256']
|
|
e=overlay.request(new,[pg['after']]);assert hashlib.sha256(e).hexdigest()==pg['after_reply_sha256']
|
|
assert overlay.request(new,[pg['before']])==struct.pack('<II',0,0) and overlay.request(old,[pg['after']])==struct.pack('<II',0,0)
|
|
for push,_ in pb: assert overlay.request(old,[push])==overlay.request(new,[push])
|
|
print(json.dumps(dict(changed=changed,unchanged_controls=same,startup_identical=True,advertised=len(pb),rekeyed_pages=len(m['changed_pages']))))
|