Bind squad and lineup views to confirmed engine player swaps (by Codex)
This commit is contained in:
1 parent
94dc5ecbc4
commit
7d3b3f1101
15 files changed
+340
-36
No files matched your search
@@ -51,6 +51,53 @@ int main() {
|
||||
rejects([&] { engine_camp_command(bundle, "resort:unknown", focus, "request:stable"); });
|
||||
auto invalid_focus = focus; invalid_focus["play"] = 16;
|
||||
rejects([&] { engine_camp_command(bundle, "resort:16", invalid_focus, "request:stable"); });
|
||||
auto squad_bundle = fixture();
|
||||
for (auto &item : squad_bundle) item["meta"]["scope"]["allowedCommands"].push_back("lineup.commit");
|
||||
const auto meta = squad_bundle.at("desktop").at("meta");
|
||||
Json players = Json::array(), order = Json::array(), role_rows = Json::array();
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
const auto id = "player:" + std::to_string(i);
|
||||
order.push_back(id); role_rows.push_back({{"playerId", id}, {"role", i < 2 ? "starter" : i == 2 ? "bench" : "reserve"}});
|
||||
players.push_back({{"player", {{"id", id}, {"name", "Engine Name " + std::to_string(i)}, {"positions", {"gk"}}, {"nationIds", {"nation:de"}}}},
|
||||
{"availability", "fit"}, {"age", 37}, {"skills", {{"speed", 2}}},
|
||||
{"metrics", {{"strength", {{"value", 91}, {"availability", {{"status", "available"}}}}},
|
||||
{"condition", {{"value", 0}}}}}});
|
||||
}
|
||||
squad_bundle["squad"] = {{"messageType", "snapshot"}, {"meta", meta},
|
||||
{"data", {{"kind", "squad"}, {"team", {{"id", "club:6"}}}, {"players", players}}}};
|
||||
squad_bundle["lineup"] = {{"messageType", "snapshot"}, {"meta", meta}, {"data", {{"kind", "lineup"}, {"teamId", "club:6"},
|
||||
{"order", order}, {"rows", role_rows}, {"positions", Json::array({{{"playerId", "player:0"}, {"depth", 19}, {"lane", 8}},
|
||||
{{"playerId", "player:1"}, {"depth", 0}, {"lane", 4}}})}, {"depthMax", 19}, {"laneMax", 8}}}};
|
||||
const auto source_bundle = squad_bundle;
|
||||
const auto projected = engine_lineup_projection(squad_bundle);
|
||||
require(projected.at("rows")[0].at("strength") == 91 && projected.at("rows")[0].at("condition") == 0 &&
|
||||
projected.at("rows")[0].at("goals").is_null() && projected.at("rows")[0].at("grade").is_null(),
|
||||
"projection invented catalogue/season values or discarded known zero");
|
||||
require(projected.at("rows")[2].at("status") == "Ersatzbank" && projected.at("rows")[3].at("status") == "—" &&
|
||||
projected.at("board").at("points")[0] == Json::array({19,8}), "roles/coordinate bounds inferred from demo rules");
|
||||
auto changed_order = order; std::swap(changed_order[0], changed_order[2]);
|
||||
const auto lineup_command = engine_lineup_command(squad_bundle, changed_order, "request:lineup");
|
||||
require(lineup_command.at("payload").at("order") == changed_order && lineup_command.at("owner").at("managerId") == "manager:99" &&
|
||||
lineup_command.at("expectedRevision") == "18446744073709551615" && squad_bundle == source_bundle,
|
||||
"lineup command lost complete identities/revision or changed read source");
|
||||
for (int fault = 0; fault < 6; ++fault) {
|
||||
auto bad_order = changed_order;
|
||||
if (fault == 0) bad_order[0] = bad_order[1];
|
||||
if (fault == 1) bad_order.erase(0);
|
||||
if (fault == 2) bad_order[0] = "player:foreign";
|
||||
if (fault == 3) bad_order[0] = 3;
|
||||
if (fault == 4) bad_order.push_back("player:extra");
|
||||
if (fault == 5) bad_order = Json::object();
|
||||
rejects([&] { engine_lineup_command(squad_bundle, bad_order, "request:lineup"); });
|
||||
}
|
||||
auto wrong_context = squad_bundle; wrong_context["squad"]["meta"]["stateRevision"] = "2";
|
||||
rejects([&] { engine_lineup_projection(wrong_context); });
|
||||
wrong_context = squad_bundle; wrong_context["lineup"]["data"]["teamId"] = "club:other";
|
||||
rejects([&] { engine_lineup_command(wrong_context, order, "request:lineup"); });
|
||||
auto hidden_metric = squad_bundle; hidden_metric["squad"]["data"]["players"][0]["metrics"]["strength"]["availability"]["status"] = "unavailable";
|
||||
require(engine_lineup_projection(hidden_metric).at("rows")[0].at("strength").is_null(), "unavailable metric exposed its stale numeric value");
|
||||
auto unknown_point = squad_bundle; unknown_point["lineup"]["data"]["positions"][0]["depth"] = -1;
|
||||
require(engine_lineup_projection(unknown_point).at("board").at("points")[0].is_null(), "unknown pitch position was fabricated");
|
||||
std::cout << "engine DTO, exact money, scope and booking tests passed\n";
|
||||
return 0;
|
||||
} catch (const std::exception &e) { std::cerr << e.what() << '\n'; return 1; }
|
||||
|
||||
Reference in new issue
Block a user