Bunch of dedupes

This commit is contained in:
Lam Wei Lun
2026-09-21 18:43:08 +08:00
parent 6fdf697bc7
commit 5a4fcafb5b
7 changed files with 232 additions and 244 deletions
+18 -6
View File
@@ -133,16 +133,28 @@ TEST_CASE("filament sync follows the printer's AMS capability", "[OrcaPrinterAge
/*local=*/true);
CHECK(agent.get_filament_sync_mode() == Slic3r::FilamentSyncMode::subscription);
// The pull contract (Sidebar's blocking path) is gone: a pull-mode fetch is
// refused by the mode guard, and a subscription fetch for a device that is
// not the active printer is refused before any HTTP.
CHECK_FALSE(agent.fetch_filament_info("dev-ams-1", Slic3r::FilamentSyncMode::pull));
CHECK_FALSE(agent.fetch_filament_info("dev-ams-2", Slic3r::FilamentSyncMode::subscription));
agent.disconnect_printer();
CHECK(agent.get_filament_sync_mode() == Slic3r::FilamentSyncMode::none);
}
// OrcaSonar's contract: an absent ams_ops key means "no AMS controls" (app.go
// omits it when no driver declares a write op; Qidi is the shipped example).
// Answering get_capabilities without it must gate every AMS write client-side,
// not fall back to the base default's "no record -> never gate".
TEST_CASE("a capability reply without ams_ops gates AMS writes", "[OrcaPrinterAgent]") {
Probe agent("/tmp");
agent.deliver_to_sink("dev-noops",
R"({"info":{"command":"get_capabilities","capabilities":{"protocol":{"features":{"fms":true}}}}})",
/*local=*/true);
bool unsupported = false;
OrcaPrinterAgent::canonicalize_ams_payload(
"dev-noops",
R"({"print":{"command":"ams_change_filament","target":0,"slot_id":0,"ams_id":0}})",
&unsupported);
CHECK(unsupported);
}
// The subscription refresh is self-triggered: a pushed frame whose print block
// carries a CHANGED topology_state.material_hash (spec REQ-STS-007 §7.7) is
// the doorbell; repeat hashes, temperature-only frames and hash-less blocks
+13
View File
@@ -184,6 +184,19 @@ TEST_CASE("unit: AMS payload sets exist bits beyond 31 lanes", "[unit][moonraker
CHECK_FALSE(u8[1].contains("tray_slot_placeholder")); // slot 33 present
}
// why: a flat lane range renders into 4-slot AMS units; both agents and the
// builder share this one formula so they cannot drift.
TEST_CASE("unit: AMS unit count rounds lane ranges up to 4-slot units", "[unit][moonraker]")
{
CHECK(ams_count_for_lanes(-1) == 0);
CHECK(ams_count_for_lanes(0) == 1);
CHECK(ams_count_for_lanes(3) == 1);
CHECK(ams_count_for_lanes(4) == 2);
CHECK(ams_count_for_lanes(6) == 2);
CHECK(ams_count_for_lanes(7) == 2);
CHECK(ams_count_for_lanes(8) == 3);
}
// why: the sync mode keys off the printer's declared material system; a device
// with no capability record must never read as AMS-capable.
TEST_CASE("unit: AMS capability registry reports only declared material systems", "[unit][moonraker]")