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

102 lines
5.5 KiB
Python

"""One private three-word WDT association boundary, using accepted SDK rows."""
from copy import deepcopy
import hashlib
import json
from pathlib import Path
import struct
import sys
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / 'ops'))
import map_asset_preflight as maps
def main():
batch = ROOT / 'runtime/continuation-20261026/terrain-remaining3-layer-relationship'
job = batch / 'private-Azeroth-root-link'
candidate_path = job / 'azeroth-three-root-links.wdt'
assert not candidate_path.exists(), 'Do not replay the completed association constructor'
source = ROOT / 'runtime/map-asset-preflight-20261018/target/azeroth.wdt'
handoff = json.loads((batch / 'private-registration-storage/Gnome-Ocean23149-framing-SDK-publication-handoff.json').read_text())
sdk_ref = handoff['standard_recorded_SDK']
sdk = json.loads(Path(sdk_ref['path']).read_text())
assert sdk['passed'] and sdk['status'] == 'PASS_NATIVE_SDK_FILEID_BODY_READBACK'
sdk_rows = {r['requested_file_data_id']: r for r in sdk['rows']}
bindings = {}
for row in handoff['new_ROOT_bindings']:
coordinate = tuple(row['tile'])
asset = row['private_ROOT_asset']
observed = sdk_rows[asset['file_data_id']]
assert row['map_id'] == 0 and asset['kind'] == 'terrain-root'
assert row['source_reference'] in asset['source_paths']
assert observed['status'] == 'PASS'
assert observed['expected_content_key'] == observed['observed_body_MD5'] == asset['content_key']
assert observed['expected_size'] == observed['observed_size'] == asset['bytes']
bindings[coordinate] = asset['file_data_id']
assert bindings == {(28, 36): 8551263, (29, 34): 8551264, (30, 33): 8551262}
native_map = json.loads((job / 'retained-original-Map0-row.json').read_text())['rows'][0]
assert native_map['ID'] == 0 and native_map['Directory'] == 'Azeroth' and native_map['WdtFileDataID'] == 775971
# Single retained-body read is needed to construct the new byte-preserving clone.
native = source.read_bytes()
output, audit = maps.wdt_azeroth_root_links_candidate(native, root_file_data_ids=bindings)
assert len(output) == len(native)
chunks = maps._global_wmo_chunk_spans(native)
allowed = set()
for row in handoff['new_ROOT_bindings']:
x, y = row['tile']
offset = chunks['MAID'][0] + (y * 64 + x) * 32
expected = row['original_native_MAID']
roles = maps._TERRAIN_WDT_TILE_ROLES
assert struct.unpack_from('<8I', native, offset) == tuple(expected[r] for r in roles)
assert struct.unpack_from('<I', output, offset)[0] == bindings[(x, y)]
assert output[offset + 4:offset + 32] == native[offset + 4:offset + 32]
allowed.update(range(offset, offset + 4))
assert all(a == b for i, (a, b) in enumerate(zip(native, output)) if i not in allowed)
assert output[chunks['MAI2'][0]:] == native[chunks['MAI2'][0]:]
assert audit['runtime_activation_verified'] is False and audit['publishable'] is False
refusals = []
def refused(label, raw=native, links=bindings):
try:
maps.wdt_azeroth_root_links_candidate(raw, root_file_data_ids=links)
except ValueError:
refusals.append(label)
else:
raise AssertionError('Unsafe association admitted: ' + label)
changed = bytearray(native); changed[20] ^= 1
refused('wrong-original-MPHD', raw=bytes(changed))
refused('truncated-original', raw=native[:-1])
refused('untyped-original', raw=bytearray(native))
bad = deepcopy(bindings); bad.pop((28, 36)); refused('missing-coordinate', links=bad)
bad = deepcopy(bindings); bad[(0, 0)] = 8551263; refused('unrelated-coordinate', links=bad)
bad = deepcopy(bindings); bad[(28, 36)] = True; refused('boolean-ID', links=bad)
bad = deepcopy(bindings); bad[(28, 36)] = 0; refused('zero-ID', links=bad)
bad = deepcopy(bindings); bad[(28, 36)] = 2**32; refused('overflow-ID', links=bad)
bad = deepcopy(bindings); bad[(28, 36)] = bindings[(29, 34)]; refused('duplicate-new-ID', links=bad)
bad = deepcopy(bindings); bad[(28, 36)] = 777167; refused('unchanged-native-ID', links=bad)
candidate_path.write_bytes(output)
manifest = dict(status='PASS_PRIVATE_AZEROTH_THREE_MAID_ROOT_ASSOCIATIONS_RUNTIME_HELD',
original_WDT=str(source), original_WDT_file_data_id=775971,
original_SHA_reused='160452dec4c2b0ae4cbe7468ce52fee91ac7ec521d2cb0f28e955def0d087137',
candidate_WDT=str(candidate_path), candidate_bytes=len(output),
candidate_sha256=hashlib.sha256(output).hexdigest(), candidate_content_key=hashlib.md5(output).hexdigest(),
original_map=0, Map_row_changed=False, Map_field_for_later_owned_WDT='WdtFileDataID',
accepted_ROOT_SDK_receipt=sdk_ref, existing_asset_parent=23149,
changed_words=3, changed_slot_bytes=12, all_other_bytes_exact=True,
original_MPHD_MAIN_companions_and_MAI2_preserved=True,
focused_refusals=refusals, audit=audit,
native_MAI2_consumer='HELD: recorded opaque extension, including nonzero candidate row29_34; no table-selection inference',
no_new_original_SDK_Source_exports_or_ROOT_checks=True,
registered_WDT_ID=None, Source_TEX_or_whole_Map_constructor=False,
B_applied=False, runtime_activation_verified=False)
(job / 'private-Azeroth3-root-link-candidate.json').write_text(json.dumps(manifest, indent=2) + '\n')
print(manifest['status'])
if __name__ == '__main__':
main()