feat: verify multi-client reset recovery and document the emergency workflow
This commit is contained in:
@@ -128,11 +128,32 @@ static void test_leave_and_full_reset(void) {
|
||||
assert(game_lifecycle_reset(&lifecycle, player_1, reset_game_id) == LIFECYCLE_RESULT_FORBIDDEN_ROLE);
|
||||
}
|
||||
|
||||
static void test_fifty_mixed_recovery_cycles(void) {
|
||||
test_random_t random = {.value = 41U};
|
||||
game_lifecycle_t lifecycle = new_lifecycle(&random);
|
||||
for (uint8_t cycle = 0; cycle < 50U; ++cycle) {
|
||||
uint8_t player = kSessionCapacity;
|
||||
assert(game_lifecycle_join(&lifecycle, ROLE_AUTO_PLAYER, "Alice", &player) == LIFECYCLE_RESULT_OK && player == 0U);
|
||||
const uint32_t game_id = lifecycle.game.state.game_id;
|
||||
if (cycle % 3U == 0U) {
|
||||
assert(game_lifecycle_leave(&lifecycle, player) == LIFECYCLE_RESULT_OK);
|
||||
} else if (cycle % 3U == 1U) {
|
||||
assert(game_lifecycle_configure(&lifecycle, player, game_id, MODE_BOT) == LIFECYCLE_RESULT_OK);
|
||||
assert(game_lifecycle_start(&lifecycle, player, game_id) == LIFECYCLE_RESULT_OK);
|
||||
assert(game_lifecycle_leave(&lifecycle, player) == LIFECYCLE_RESULT_OK);
|
||||
} else {
|
||||
assert(game_lifecycle_reset(&lifecycle, player, game_id) == LIFECYCLE_RESULT_OK);
|
||||
}
|
||||
assert(lifecycle.game.state.phase == PHASE_LOBBY && !lifecycle.sessions.entries[0].occupied);
|
||||
}
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
test_capacity_sanitize_and_resume();
|
||||
test_human_lifecycle_and_guards();
|
||||
test_bot_lifecycle_and_stale_actions();
|
||||
test_leave_and_full_reset();
|
||||
test_fifty_mixed_recovery_cycles();
|
||||
puts("game lifecycle tests passed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user