Add durable cellular action protocol v7
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (checks) (push) Failing after 40s
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 (client) (push) Canceled after 1m16s
Foundation / checks (ecs) (push) Canceled after 1m8s
Foundation / checks (network) (push) Canceled after 37s

This commit is contained in:
dingo
2026-10-10 22:57:03 -04:00
parent d0c7a938f1
commit d1717410d6
7 changed files with 163 additions and 18 deletions
+32 -1
View File
@@ -1,5 +1,6 @@
#include "evo/network/session_protocol.hpp"
#include <algorithm>
#include <cstdio>
#include <source_location>
#include <stdexcept>
@@ -65,13 +66,43 @@ void malformed_frames_are_refused() {
CHECK(!old_version && old_version.error() == SessionCodecError::unsupported_version);
CHECK(encode_session(SessionMessage{CellularIntention{1, 2, 3, 4}}, 7).empty());
}
void v7_reliable_action_is_stable_and_strict() {
const CellularAction action{17, 23, 29, 31, -707, 707, true, 4'000, 5'000};
const auto bytes = encode_session(SessionMessage{action});
CHECK(bytes.size() == session_header_bytes + 48);
std::uint16_t version{};
const auto decoded = decode_session(bytes, &version);
CHECK(decoded && version == session_protocol_v7);
CHECK(std::get<CellularAction>(*decoded) == action);
CHECK(encode_session(*decoded) == bytes);
CHECK(encode_session(SessionMessage{action}, session_protocol_v6).empty());
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);
CHECK(encode_session(SessionMessage{outcome}, session_protocol_v6).empty());
auto bad = bytes;
std::fill(bad.begin() + static_cast<std::ptrdiff_t>(session_header_bytes + 16),
bad.begin() + static_cast<std::ptrdiff_t>(session_header_bytes + 24),
std::uint8_t{0});
CHECK(!decode_session(bad)); // Stable action id cannot be zero.
bad = bytes;
bad[session_header_bytes + 37] = 1;
CHECK(!decode_session(bad)); // Reserved bytes are canonical.
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.
}
} // namespace
int main() {
try {
round_trip_and_version_gate();
malformed_frames_are_refused();
std::puts("PASS cellular intention protocol: v6 round trip and strict framing");
v7_reliable_action_is_stable_and_strict();
std::puts("PASS cellular protocol: v6 intention and v7 action strict framing");
} catch (const std::exception& error) {
std::fprintf(stderr, "%s\n", error.what());
return 1;