Add typed depot logistics visibility, auto-strike, 16-block reach, and web panel controls
build / mod (push) Failing after 15s

This commit is contained in:
2026-12-04 13:37:54 +03:00
parent a02b7d1177
commit 76ef94b537
31 changed files with 2225 additions and 106 deletions
+38
View File
@@ -28,6 +28,8 @@ class PanelTest(unittest.TestCase):
self.home = Path(self.tmp.name)
self.store = Store(self.home / "db.sqlite")
self.launches = []
self.actions = []
self.auto_strike = False
self.live_frame = EMPTY
self.world_session = WORLD_SESSION
self.dimension = "minecraft:overworld"
@@ -67,6 +69,13 @@ class PanelTest(unittest.TestCase):
"label": "Огонь запрещён", "lines": ["Зафиксирован отказ"]}]}],
}
(self.home / "panel-snapshot-v1.json").write_text(json.dumps(response))
elif words[3] == "action":
self.actions.append(words)
_, req_id, _sess, act, val = words[3:]
if act == "autostrike":
self.auto_strike = val == "on"
(self.home / "panel-receipt-v1.json").write_text(json.dumps(
{"id": req_id, "accepted": True, "message": f"OK:{act}:{val}"}))
else:
assert words[3] == "launch"
self.launches.append(words)
@@ -302,6 +311,35 @@ class PanelTest(unittest.TestCase):
_, _, result = self.request("/api/events?object=1", cookie=cookie)
self.assertEqual(result["events"], [chain["events"][-1]])
def test_action_requires_operator_validates_and_tracks_sites_deltas(self):
viewer, operator = self.pair("viewer"), self.pair("operator")
self.bridge.begin()
action_id = "ab" * 16
body = {"id": action_id, "session": WORLD_SESSION, "action": "autostrike", "value": "on"}
self.assertEqual(self.request("/api/action", method="POST", cookie=viewer, body=body)[0], 403)
status, _, res = self.request("/api/action", method="POST", cookie=operator, body=body)
self.assertEqual(status, 200)
self.assertTrue(res["accepted"])
self.assertTrue(self.auto_strike)
self.assertEqual(len(self.actions), 1)
# Idempotent retry does not re-dispatch to game.
status2, _, res2 = self.request("/api/action", method="POST", cookie=operator, body=body)
self.assertEqual((status2, res2["accepted"]), (200, True))
self.assertEqual(len(self.actions), 1)
# Conflicting params with same request ID fail.
self.assertEqual(self.request("/api/action", method="POST", cookie=operator,
body=dict(body, value="off"))[0], 409)
# Strike dispatch passes site id cleanly.
strike_id = "cd" * 16
status3, _, res3 = self.request("/api/action", method="POST", cookie=operator,
body={"id": strike_id, "session": WORLD_SESSION, "action": "strike", "value": 3})
self.assertEqual((status3, res3["message"]), (200, "OK:strike:3"))
# Sites layer propagates through live deltas.
self.live_frame = dict(EMPTY, sites=[{"id": 3, "x": 120, "z": -80, "symbol": "site"}])
self.bridge.poll()
_, _, base = self.request("/api/live?delta=1", cookie=viewer)
self.assertEqual(base["frame"]["sites"][0]["id"], 3)
if __name__ == "__main__":
unittest.main()