59 lines
5.3 KiB
GDScript
59 lines
5.3 KiB
GDScript
extends "res://tests/special/peeping_room_fixture.gd"
|
|
|
|
func _run() -> void:
|
|
var f := fixture()
|
|
var runtime: Variant = f[&"runtime"]
|
|
# Direct executor invocation distinguishes read-only domain state from queue receipts.
|
|
var validation := SimulationCommand.new()
|
|
validation.command_type = &"peeping_room_validate"
|
|
validation.payload = {&"origin": f[&"origin"]}
|
|
var before := var_to_bytes(runtime.create_snapshot())
|
|
expect(runtime._execute_peeping_room(validation).is_success(), "read-only validator executor")
|
|
expect(before == var_to_bytes(runtime.create_snapshot()), "validator changes no whole Runtime bytes")
|
|
var public_validation: CommandResult = runtime.submit_command(&"peeping_room_validate", validation.payload)
|
|
expect(public_validation.is_success(), "registered validation command runs through real queue")
|
|
var domain_before := [runtime.world_service.create_snapshot(), runtime.economy_service.create_snapshot(), runtime.id_generator.create_snapshot(), runtime.peeping_room_service.create_snapshot()]
|
|
var unavailable: CommandResult = runtime.submit_command(&"peeping_room_place", validation.payload)
|
|
expect(not unavailable.is_success() and unavailable.details[&"reason"] == &"BUILD_DEFINITION_PENDING_D04", "production placement unavailable with precise reason")
|
|
expect(var_to_bytes(domain_before) == var_to_bytes([runtime.world_service.create_snapshot(), runtime.economy_service.create_snapshot(), runtime.id_generator.create_snapshot(), runtime.peeping_room_service.create_snapshot()]), "placement adds no room, occupancy, cost or ID (normal queue receipt only)")
|
|
var room := place(f)
|
|
enable_fixture(f, room)
|
|
var blocked: CommandResult = runtime.submit_command(&"peeping_room_record_evidence", {&"room_id": room, &"source_event_key": &"fixture.command"})
|
|
expect(not blocked.is_success() and blocked.details[&"reason"] == &"RECORDER_ELIGIBILITY_PENDING_D04_D08_P16", "registered evidence command cannot reach ledger")
|
|
var missing: CommandResult = runtime.submit_command(&"peeping_room_record_evidence", {&"room_id": room})
|
|
expect(not missing.is_success() and missing.details[&"reason"] == &"SOURCE_EVENT_KEY_REQUIRED", "public command requires named key")
|
|
var malformed: CommandResult = runtime.submit_command(&"peeping_room_validate", {&"origin": [0, 1, 1]})
|
|
expect(not malformed.is_success() and malformed.details[&"reason"] == &"INVALID_PAYLOAD", "wrong payload type safely rejected")
|
|
expect(runtime.peeping_room_service.create_snapshot()[&"evidence"].is_empty(), "commands cannot inject arbitrary content events")
|
|
var fixture_command: CommandResult = runtime.submit_command(&"controlled_fixture_place", validation.payload)
|
|
expect(not fixture_command.is_success(), "no fixture command registration")
|
|
_mimi_format(f)
|
|
finish("Peeping room runtime")
|
|
|
|
func _mimi_format(f: Dictionary) -> void:
|
|
var runtime: Variant = f[&"runtime"]
|
|
const Quote := preload("res://scripts/supply/supply_purchase_quote_v2.gd")
|
|
expect(runtime.submit_command(&"build_facility", {&"definition_id": &"warehouse", &"origin": Vector3i(2, 0, 1)}).is_success(), "paid warehouse for independent existing MIMI format path")
|
|
f[&"clock"].advance_minutes(runtime.definition_registry.get_facility(&"warehouse").build_minutes)
|
|
var warehouse: StringName = &""
|
|
for facility: FacilityInstance in runtime.facility_service.get_instances():
|
|
if facility.definition_id == &"warehouse": warehouse = facility.instance_id
|
|
expect(not warehouse.is_empty(), "completed real warehouse")
|
|
var mimi := StaffRuntime.new().configure(Quote.MIMI, &"porter", {&"employment_kind": StaffRuntime.EmploymentKind.UNIQUE})
|
|
expect(runtime.staff_service.register_staff(mimi).is_success(), "CONTROLLED_FIXTURE existing MIMI unique registration, no natural join claim")
|
|
expect(runtime.submit_command(&"set_staff_work_assignment", {&"staff_id": Quote.MIMI, &"facility_id": warehouse, &"template_id": &"NIGHT"}).is_success(), "existing persistent MIMI assignment")
|
|
expect(runtime.submit_command(&"purchase_supplies", {&"warehouse_id": warehouse, &"item_id": SupplyCatalog.RAW_FOOD, &"quantity": 1}).is_success(), "existing real v2 paid purchase")
|
|
var snapshot: Dictionary = runtime.create_snapshot()
|
|
expect(snapshot[&"systems"][&"runtime"][&"runtime_schema_version"] == 15 and snapshot[&"systems"][&"runtime"].has(&"special_peeping_rooms"), "v2 purchase history and special section coexist")
|
|
expect(runtime.restore_snapshot(snapshot) and var_to_bytes(snapshot) == var_to_bytes(runtime.create_snapshot()), "v15 optional section exact typed restore")
|
|
var directory := "user://tests/p13_reference_mimi_%d" % OS.get_process_id()
|
|
expect(SaveService.save_snapshot(directory, snapshot)[&"ok"], "physical v15 save accepts validated extension without loosening purchase allowlist")
|
|
var loaded := SaveService.load_snapshot(directory)
|
|
expect(loaded[&"ok"], "physical MIMI section save loads")
|
|
if loaded[&"ok"]:
|
|
expect(loaded[&"manifest"]["format_version"] == 2 and loaded[&"manifest"]["runtime_schema_version"] == 15, "format2 manifest still exactly15")
|
|
expect(runtime.restore_snapshot(loaded[&"snapshot"]), "MIMI package restore reaches same staged section validator")
|
|
var bad := snapshot.duplicate(true)
|
|
bad[&"systems"][&"runtime"][&"special_peeping_rooms"][&"version"] = 2
|
|
expect(not SaveService.save_snapshot(directory + "_bad", bad)[&"ok"], "save-format adapter rejects malformed optional section")
|