Enable authenticated primitive life sessions
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m59s
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 (checks) (push) Canceled after 6m2s
Foundation / checks (network) (push) Canceled after 3m53s
Foundation / checks (client) (push) Canceled after 6m8s
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m59s
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 (checks) (push) Canceled after 6m2s
Foundation / checks (network) (push) Canceled after 3m53s
Foundation / checks (client) (push) Canceled after 6m8s
This commit is contained in:
@@ -388,6 +388,60 @@ struct FakeLedger final : ControlLedger {
|
||||
std::vector<std::uint64_t> renewed, released;
|
||||
};
|
||||
|
||||
void primitive_v5_session(const Files& f) {
|
||||
FakeLedger ledger;
|
||||
Harness h{f, 4, 64, &ledger, [](server::RegionSessionsConfig& c) {
|
||||
c.create_primitive_life = [](const AccountId& a, std::uint64_t generation,
|
||||
std::uint64_t request) {
|
||||
CHECK(a == account(0xA5) && generation == 1);
|
||||
return PrimitiveLifeOutcome{request, PrimitiveLifeResult::born, 77, 88};
|
||||
};
|
||||
c.query_primitive_life = [](const AccountId&, std::uint64_t,
|
||||
std::uint64_t request) {
|
||||
return PrimitiveLifeOutcome{request, PrimitiveLifeResult::unknown, 0, 0};
|
||||
};
|
||||
}};
|
||||
auto peer = h.raw();
|
||||
quic::ConnectionId id = 0;
|
||||
std::uint64_t session = 0, epoch = 0;
|
||||
bool sent_request = false;
|
||||
std::optional<PrimitiveLifeReceipt> receipt;
|
||||
std::optional<PrimitiveLifeOutcome> outcome;
|
||||
const auto end = Clock::now() + std::chrono::seconds{10};
|
||||
while (Clock::now() < end && !outcome) {
|
||||
h.pump();
|
||||
for (auto& e : peer->poll()) {
|
||||
if (e.kind == quic::EventKind::connected) {
|
||||
id = e.connection;
|
||||
CHECK(peer->send_message(
|
||||
id, encode_session(SessionHello{0, h.issuer.grant(account(0xA5), 1)},
|
||||
session_protocol_v5)));
|
||||
} else if (e.kind == quic::EventKind::message) {
|
||||
const auto decoded = decode_session(e.bytes);
|
||||
CHECK(decoded.has_value());
|
||||
if (const auto* welcome = std::get_if<SessionWelcome>(&*decoded)) {
|
||||
session = welcome->session;
|
||||
epoch = welcome->epoch;
|
||||
if (!sent_request) {
|
||||
sent_request = true;
|
||||
CHECK(peer->send_message(
|
||||
id, encode_session(PrimitiveLifeRequest{session, epoch, 42},
|
||||
session_protocol_v5)));
|
||||
}
|
||||
} else if (const auto* got = std::get_if<PrimitiveLifeReceipt>(&*decoded)) {
|
||||
receipt = *got;
|
||||
} else if (const auto* life = std::get_if<PrimitiveLifeOutcome>(&*decoded)) {
|
||||
outcome = *life;
|
||||
}
|
||||
}
|
||||
}
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds{1});
|
||||
}
|
||||
CHECK(receipt == PrimitiveLifeReceipt{42, AdmitStatus::admitted, 100});
|
||||
CHECK(outcome == PrimitiveLifeOutcome{42, PrimitiveLifeResult::born, 77, 88});
|
||||
CHECK(!ledger.claims.empty() && ledger.claims.back().account == account(0xA5));
|
||||
}
|
||||
|
||||
// M10.4: intentions, actions and their distinct answers against a simulated host.
|
||||
void intentions_and_actions(const Files& f) {
|
||||
Harness h{f};
|
||||
@@ -1209,6 +1263,7 @@ void storm(const Files& f) {
|
||||
int main() try {
|
||||
const auto files = credentials();
|
||||
login_rules(files);
|
||||
primitive_v5_session(files);
|
||||
limits(files);
|
||||
durable_control(files);
|
||||
intentions_and_actions(files);
|
||||
|
||||
Reference in New Issue
Block a user