Enable durable cellular session actions
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (checks) (push) Failing after 37s
Foundation / checks (ecs) (push) Successful in 1m53s
Foundation / checks (postgres) (push) Failing after 50s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (network) (push) Canceled after 2m38s
Foundation / checks (tsan) (push) Canceled after 22s
Foundation / checks (client) (push) Canceled after 3m18s
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (checks) (push) Failing after 37s
Foundation / checks (ecs) (push) Successful in 1m53s
Foundation / checks (postgres) (push) Failing after 50s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (network) (push) Canceled after 2m38s
Foundation / checks (tsan) (push) Canceled after 22s
Foundation / checks (client) (push) Canceled after 3m18s
This commit is contained in:
+97
-2
@@ -439,7 +439,16 @@ void cellular_v6_session(const Files& f) {
|
||||
CHECK(!client->set_interest(SessionInterest{})); // No M10 probe view in cellular v6.
|
||||
CHECK(client->view() == nullptr);
|
||||
h.server->set_default_interest({0, 0, 0, 1});
|
||||
h.source = [](const SessionInterest&) { return ReplicationSource{.identity = world_id}; };
|
||||
h.source = [](const SessionInterest&) {
|
||||
return ReplicationSource{.identity = world_id,
|
||||
.field_revision = 0,
|
||||
.organism_revision = 0,
|
||||
.mask = 0,
|
||||
.environment = {},
|
||||
.organisms = {},
|
||||
.markers = {},
|
||||
.marker_area = {}};
|
||||
};
|
||||
h.pump();
|
||||
CHECK(client->view() == nullptr); // Default M10 snapshots are withheld too.
|
||||
CHECK(!client->send_intention(101, 0, 0));
|
||||
@@ -470,6 +479,90 @@ void cellular_v6_session(const Files& f) {
|
||||
CHECK(refused->close_reason() == SessionCloseReason::unsupported_version);
|
||||
}
|
||||
|
||||
void cellular_v7_action_session(const Files& f) {
|
||||
struct ActionLedgerFake final : ActionLedger {
|
||||
AccountId owner{};
|
||||
std::uint64_t id{};
|
||||
std::optional<DurableActionRecord> record;
|
||||
std::expected<std::optional<ActionOutcome>, ActionLedgerError>
|
||||
find(const AccountId& account_id, std::uint64_t action_id) override {
|
||||
if (record && owner == account_id && id == action_id)
|
||||
return std::optional<ActionOutcome>{record->outcome};
|
||||
return std::optional<ActionOutcome>{};
|
||||
}
|
||||
std::expected<std::optional<DurableActionRecord>, ActionLedgerError>
|
||||
find_record(const AccountId& account_id, std::uint64_t action_id) override {
|
||||
return owner == account_id && id == action_id ? record
|
||||
: std::optional<DurableActionRecord>{};
|
||||
}
|
||||
} actions;
|
||||
FakeLedger control;
|
||||
Harness h{f, 4, 64, &control, [&](server::RegionSessionsConfig& c) {
|
||||
c.actions = &actions;
|
||||
c.accept_cellular_actions = true;
|
||||
}};
|
||||
const auto alice = account(0xA8);
|
||||
auto client = h.connect(h.issuer.grant(alice, 1), session_protocol_v7);
|
||||
CHECK(h.settled(*client) && client->state() == RegionSessionState::established);
|
||||
CHECK(!client->send_action(88, ActionKind::probe, 101));
|
||||
CHECK(client->send_cellular_action(88, 101, 0, 0));
|
||||
std::vector<ActionReceipt> receipts;
|
||||
CHECK(h.until([&] { return !(receipts = client->take_action_receipts()).empty(); }));
|
||||
CHECK(receipts.front() == ActionReceipt{88, AdmitStatus::admitted, 100, 101});
|
||||
const auto carried = h.server->carry(101);
|
||||
CHECK(carried.size() == 1 && carried.front().account == alice &&
|
||||
carried.front().action_id == 88 && carried.front().tick == 101 &&
|
||||
carried.front().kind == ActionKind::cellular && carried.front().cellular_input ==
|
||||
std::optional{encode_cellular_action_input({101, 0, 0, false, 0, 0})});
|
||||
actions.owner = alice;
|
||||
actions.id = 88;
|
||||
actions.record = DurableActionRecord{
|
||||
ActionOutcome{88, ActionResult::committed, 101, 1}, carried.front().cellular_input};
|
||||
h.server->committed(carried, 1);
|
||||
std::vector<ActionOutcome> outcomes;
|
||||
CHECK(h.until([&] { return !(outcomes = client->take_action_outcomes()).empty(); }));
|
||||
CHECK(outcomes.front() == ActionOutcome{88, ActionResult::committed, 101, 1});
|
||||
|
||||
// Exact retry returns the same final outcome. Reusing the key with changed bytes is refused.
|
||||
CHECK(client->send_cellular_action(88, 101, 0, 0));
|
||||
CHECK(h.until([&] { return !(receipts = client->take_action_receipts()).empty(); }));
|
||||
CHECK(receipts.front().status == AdmitStatus::duplicate);
|
||||
CHECK(h.until([&] { return !(outcomes = client->take_action_outcomes()).empty(); }));
|
||||
CHECK(outcomes.front() == ActionOutcome{88, ActionResult::committed, 101, 1});
|
||||
CHECK(client->send_cellular_action(88, 101, 1, 0));
|
||||
CHECK(h.until([&] { return !(receipts = client->take_action_receipts()).empty(); }));
|
||||
CHECK(receipts.front().status == AdmitStatus::invalid_action);
|
||||
|
||||
// A fresh session host resolves the same action from durable result and input bytes.
|
||||
client->close();
|
||||
CHECK(h.until([&] { return client->state() == RegionSessionState::closed; }));
|
||||
Harness restarted{f, 4, 64, &control, [&](server::RegionSessionsConfig& c) {
|
||||
c.actions = &actions;
|
||||
c.accept_cellular_actions = true;
|
||||
}};
|
||||
auto reconnected = restarted.connect(restarted.issuer.grant(alice, 2),
|
||||
session_protocol_v7);
|
||||
CHECK(restarted.settled(*reconnected) &&
|
||||
reconnected->state() == RegionSessionState::established);
|
||||
CHECK(reconnected->send_cellular_action(88, 101, 0, 0));
|
||||
CHECK(restarted.until(
|
||||
[&] { return !(receipts = reconnected->take_action_receipts()).empty(); }));
|
||||
CHECK(receipts.front().status == AdmitStatus::duplicate);
|
||||
CHECK(restarted.until(
|
||||
[&] { return !(outcomes = reconnected->take_action_outcomes()).empty(); }));
|
||||
CHECK(outcomes.front() == ActionOutcome{88, ActionResult::committed, 101, 1});
|
||||
CHECK(reconnected->send_cellular_action(88, 101, 1, 0));
|
||||
CHECK(restarted.until(
|
||||
[&] { return !(receipts = reconnected->take_action_receipts()).empty(); }));
|
||||
CHECK(receipts.front().status == AdmitStatus::invalid_action);
|
||||
|
||||
Harness refused{f, 4, 64, &control};
|
||||
auto unsupported = refused.connect(refused.issuer.grant(account(0xA9), 1),
|
||||
session_protocol_v7);
|
||||
CHECK(refused.settled(*unsupported) && unsupported->state() == RegionSessionState::closed &&
|
||||
unsupported->close_reason() == SessionCloseReason::unsupported_version);
|
||||
}
|
||||
|
||||
// M10.4: intentions, actions and their distinct answers against a simulated host.
|
||||
void intentions_and_actions(const Files& f) {
|
||||
Harness h{f};
|
||||
@@ -507,7 +600,8 @@ void intentions_and_actions(const Files& f) {
|
||||
CHECK(outcomes[0].result == ActionResult::pending);
|
||||
CHECK(h.server->carry(102).empty());
|
||||
const auto carried = h.server->carry(103);
|
||||
CHECK(carried.size() == 1 && carried[0] == CarriedAction{alice, 7, 103, ActionKind::probe});
|
||||
CHECK(carried.size() == 1 &&
|
||||
carried[0] == CarriedAction{alice, 7, 103, ActionKind::probe, std::nullopt});
|
||||
h.server->committed(carried, 4);
|
||||
CHECK(h.until([&] { return !(outcomes = a->take_action_outcomes()).empty(); }));
|
||||
CHECK(outcomes[0] == ActionOutcome{7, ActionResult::committed_no_effect, 103, 4});
|
||||
@@ -1293,6 +1387,7 @@ int main() try {
|
||||
login_rules(files);
|
||||
primitive_v5_session(files);
|
||||
cellular_v6_session(files);
|
||||
cellular_v7_action_session(files);
|
||||
limits(files);
|
||||
durable_control(files);
|
||||
intentions_and_actions(files);
|
||||
|
||||
Reference in New Issue
Block a user