diff --git a/tests/region_store_tests.cpp b/tests/region_store_tests.cpp index 123159f..e09176f 100644 --- a/tests/region_store_tests.cpp +++ b/tests/region_store_tests.cpp @@ -673,24 +673,42 @@ void cellular_v8_provisioning_declares_light() { CHECK(db->query("INSERT INTO evolution.life_allocators VALUES(9775,1000)", {}, 5s)); Sha256Digest digest{}; digest.fill(0xEE); - auto objects = FilesystemObjectStore::open(r.root, r.key, max_cellular_lives_bytes); - CHECK(objects); - auto made = - CellularRegionHost::create({r.key, 9, {}, digest, {digest}}, connect, std::move(*objects)); - CHECK(made); - auto host = std::move(*made); - CHECK(host->step().ready && host->state()); + const auto start = [&] { + auto objects = FilesystemObjectStore::open(r.root, r.key, max_cellular_lives_bytes); + CHECK(objects); + auto made = CellularRegionHost::create({r.key, 9, {}, digest, {digest}}, connect, + std::move(*objects)); + CHECK(made); + auto started = std::move(*made); + CHECK(started->step().ready && started->state()); + return started; + }; + auto host = start(); auto runtime = connect(); CHECK(runtime); Uuid account{}; account[0] = 0x8E; account.back() = 0x13; - const auto control = + const auto original = claim_account_control(**runtime, r.key, *host->authority(), account, 1, 1, 20'000ms, 5s); - CHECK(control); - const auto requested = host->create_primitive_life(account, control->generation, 5); + CHECK(original); + const auto requested = host->create_primitive_life(account, original->generation, 5); CHECK(requested.result == evo::network::PrimitiveLifeResult::pending && host->queued_births().size() == 1); + // The server restarts before publishing and the client loses request 5. Claiming + // control under the new lease epoch cancels the unpublished reservation (schema 17), + // so the account's new request is not refused for that lost life. + host->drain(); + host = start(); + CHECK(host->queued_births().empty()); + const auto control = + claim_account_control(**runtime, r.key, *host->authority(), account, 2, 2, 20'000ms, 5s); + CHECK(control); + CHECK(host->query_primitive_life(account, control->generation, 5).result == + evo::network::PrimitiveLifeResult::cancelled); + const auto relogin = host->create_primitive_life(account, control->generation, 6); + CHECK(relogin.result == evo::network::PrimitiveLifeResult::pending && + host->queued_births().size() == 1 && host->queued_births().front().request == 6); const std::vector births(host->queued_births().begin(), host->queued_births().end()); auto builder = CellularSessionBatchBuilder::create(*host->state(), host->committed()->head); CHECK(builder); @@ -717,7 +735,7 @@ void cellular_v8_provisioning_declares_light() { message += " sqlstate " + std::string(failure.store->cause.sqlstate.data(), 5); throw std::runtime_error(message); } - CHECK(host->query_primitive_life(account, control->generation, 5).result == + CHECK(host->query_primitive_life(account, control->generation, 6).result == evo::network::PrimitiveLifeResult::born); // The player's next ordinary session tick publishes too. std::vector baseline;