Add canonical cellular action input codec
Foundation / checks (deploy) (push) Successful in 6s
Foundation / checks (checks) (push) Failing after 39s
Foundation / checks (postgres) (push) Canceled after 0s
Foundation / checks (tsan) (push) Canceled after 0s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (ecs) (push) Canceled after 1m39s
Foundation / checks (network) (push) Canceled after 1m8s
Foundation / checks (client) (push) Canceled after 1m49s

This commit is contained in:
dingo
2026-10-10 22:59:05 -04:00
parent 49f6fac3e7
commit a2e5cd5f68
6 changed files with 94 additions and 0 deletions
+20
View File
@@ -78,6 +78,15 @@ void v7_reliable_action_is_stable_and_strict() {
CHECK(encode_session(*decoded) == bytes);
CHECK(encode_session(SessionMessage{action}, session_protocol_v6).empty());
const CellularActionInput input{31, -707, 707, true, 4'000, 5'000};
const auto canonical = encode_cellular_action_input(input);
CHECK(canonical.size() == cellular_action_input_bytes);
CHECK(decode_cellular_action_input(canonical) == input);
const CellularAction retry{99, 101, 29, 31, -707, 707, true, 4'000, 5'000};
CHECK(encode_cellular_action_input(
{retry.tick, retry.move_x, retry.move_y, retry.has_intake_target,
retry.intake_x_um, retry.intake_y_um}) == canonical);
const auto outcome = ActionOutcome{29, ActionResult::committed, 31, 41};
const auto outcome_bytes = encode_session(SessionMessage{outcome}, session_protocol_v7);
CHECK(std::get<ActionOutcome>(*decode_session(outcome_bytes)) == outcome);
@@ -94,6 +103,17 @@ void v7_reliable_action_is_stable_and_strict() {
bad = encode_session(SessionMessage{CellularAction{1, 2, 3, 4, 0, 0, false, 0, 0}});
bad[session_header_bytes + 44] = 1;
CHECK(!decode_session(bad)); // An absent patch has no coordinates.
auto malformed_input = canonical;
malformed_input[12] = 2;
CHECK(!decode_cellular_action_input(malformed_input));
malformed_input = canonical;
malformed_input[13] = 1;
CHECK(!decode_cellular_action_input(malformed_input));
malformed_input = canonical;
// The canonical biological input itself requires a nonzero tick.
std::fill(malformed_input.begin(), malformed_input.begin() + 8, std::uint8_t{0});
CHECK(!decode_cellular_action_input(malformed_input));
}
} // namespace