883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
39 lines
2.8 KiB
Python
39 lines
2.8 KiB
Python
#!/usr/bin/env python3
|
|
"""Affected peer producer oracle: legacy defaults must equal typed native defaults.
|
|
Uses the existing peer packet builders; does not rerun their movement/layout suite.
|
|
"""
|
|
import importlib.util, os, subprocess, sys
|
|
from pathlib import Path
|
|
codec=Path(sys.argv[1]).resolve()
|
|
keep=sys.argv[:];sys.argv=[sys.argv[0]]
|
|
spec=importlib.util.spec_from_file_location('peer_packet_builders',Path(__file__).with_name('peer_player_serializer_fixture.py'))
|
|
m=importlib.util.module_from_spec(spec);spec.loader.exec_module(m);sys.argv=keep
|
|
adapter=None;library=None;dll_directory=None
|
|
if codec.suffix.lower()=='.dll':
|
|
# Reuse the established C-ABI fixture adapter; Windows has no CLI codec.
|
|
spec=importlib.util.spec_from_file_location('existing_codec_adapter',Path(__file__).with_name('native_codec_driver.py'))
|
|
adapter=importlib.util.module_from_spec(spec);spec.loader.exec_module(adapter)
|
|
dll_directory=os.add_dll_directory(str(codec.parent))
|
|
previous=os.environ.get('GW_TEST_CODEC_PATH');os.environ['GW_TEST_CODEC_PATH']=str(codec)
|
|
try:library=adapter.load()
|
|
finally:
|
|
if previous is None:os.environ.pop('GW_TEST_CODEC_PATH',None)
|
|
else:os.environ['GW_TEST_CODEC_PATH']=previous
|
|
# Independent pinned source ChrRaces -> native ChrRaceXChrModel/ChrModel expectations.
|
|
BINDINGS=[(1, 0, 49, 57899), (1, 1, 50, 56658), (2, 0, 51, 51894), (2, 1, 52, 53762), (3, 0, 53, 49242), (3, 1, 54, 53768), (4, 0, 55, 54918), (4, 1, 56, 54439), (5, 0, 57, 54041), (5, 1, 58, 56327), (6, 0, 59, 55077), (6, 1, 60, 56316), (7, 0, 1563, 51877), (7, 1, 1564, 53291), (8, 0, 1478, 59071), (8, 1, 1479, 59223), (10, 0, 15476, 62127), (10, 1, 15475, 62128)]
|
|
def run(mode,fields,delta=None):
|
|
body=m.descriptor(m.source_packet(m.create_record(fields=fields) if delta is None else m.values_record(delta)),fields)
|
|
if adapter:return adapter.serialize(library,adapter.MODES.index(mode),body)
|
|
p=subprocess.run([str(codec),mode],input=body,capture_output=True)
|
|
if p.returncode:raise AssertionError('affected codec producer rejected a valid family member')
|
|
return p.stdout
|
|
for race,sex,source,target in BINDINGS:
|
|
raw={**m.FIELDS,36:race|(1<<8)|(sex<<16),131:source,132:source,260:19019}
|
|
native={**raw,131:target,132:target}
|
|
assert run('--players',raw)==run('--players',native),(race,sex,'create')
|
|
assert run('--player-values',raw,{131:source})==run('--player-values',native,{131:target}),(race,sex,'restore')
|
|
morph={**raw,131:123456};native_morph={**morph,132:target}
|
|
assert run('--players',morph)==run('--players',native_morph),(race,sex,'morph')
|
|
assert run('--players',raw)!=run('--players',{**raw,260:0}),(race,sex,'equipment preserved')
|
|
print('PASS18 typed default create/update producers, active morph preservation, equipment serialization retained')
|