"""Map-catalog guard regression (the 2026-07-26 artrucks outage). 1. ValueSets.maps offers EXACTLY the Mac 4.10 console catalog (8 maps, catalog order) -- internal RES fragments (artrucks...) hidden. 2. The relay warns loudly when an egg names an unplayable map. 3. A real map stays silent. 4. The 60s all-pods-stalled hint names the egg's map. """ import contextlib import io import os import re import shutil import sys import time sys.path.insert(0, r"C:\git\bt411\tools") os.chdir(r"C:\git\bt411\content") import btconsole # noqa: E402 import eggmodel # noqa: E402 fails = [] def check(label, ok, extra=""): print(" %-56s %s %s" % (label, "OK" if ok else "*** FAIL ***", extra)) if not ok: fails.append(label) v = eggmodel.ValueSets() check("dropdown = the console catalog, in order", v.maps == list(eggmodel.CONSOLE_MAPS), repr(v.maps)) check("artrucks hidden from the dropdown", "artrucks" not in v.maps) shutil.copyfile("FOGDAY.EGG", "_maptest.EGG") raw = re.sub(rb"^map=\S+", b"map=artrucks", open("_maptest.EGG", "rb").read(), count=1, flags=re.M) open("_maptest.EGG", "wb").write(raw) buf = io.StringIO() with contextlib.redirect_stdout(buf): btconsole.Relay(1500, "_maptest.EGG", "127.0.0.1", 0, manual_launch=True) check("relay warns on a phantom map", "NOT a playable mission" in buf.getvalue()) buf = io.StringIO() with contextlib.redirect_stdout(buf): r = btconsole.Relay(1500, "FOGDAY.EGG", "127.0.0.1", 0, manual_launch=True) check("real map stays silent", "NOT a playable mission" not in buf.getvalue()) class C: ready = False r.launches_sent = 0 r.launch_at = time.time() - 61 r.eggs_released = True r.by_host = {2: C(), 3: C()} r._hold_notice_at = 0 buf = io.StringIO() with contextlib.redirect_stdout(buf): r._tick_launch() check("60s all-stalled hint names the map", "stalled in MISSION LOAD" in buf.getvalue() and "map=" in buf.getvalue()) os.remove("_maptest.EGG") print() print("ALL PASS" if not fails else "FAILURES: %s" % fails) sys.exit(1 if fails else 0)