feat: implement safe leave, profile reset, and full game reset semantics

This commit is contained in:
2026-08-30 23:18:07 +03:00
parent c0c3c73c7a
commit a68023e684
16 changed files with 281 additions and 9 deletions
+18
View File
@@ -124,9 +124,27 @@ static void test_timeout_ping_and_command(void) {
assert(changed && !close && output_length == 0U && application.lifecycle.game.state.mode == MODE_BOT);
}
static void test_reset_notification_invalidates_authenticated_client(void) {
test_random_t random = {.value = 17U};
application_t application;
application_init(&application, (random_source_t){.next_u32 = next_random, .context = &random});
uint8_t player = 0;
assert(application_join(&application, ROLE_PLAYER_1, "Alice", &player) == LIFECYCLE_RESULT_OK);
sync_service_t service;
sync_service_init(&service, &application);
assert(sync_service_open(&service, 0, 0U));
hello(&service, 0, application.lifecycle.sessions.entries[player].token, 0U);
assert(game_lifecycle_reset(&application.lifecycle, player, 1U) == LIFECYCLE_RESULT_OK);
capture_t capture = {.fail_client = -1};
sync_service_broadcast(&service, capture_send, &capture);
assert(capture.sends[0] == 1U && strstr(capture.payloads[0], "\"type\":\"reset\"") != NULL);
assert(strstr(capture.payloads[0], "game_reset") != NULL && !service.connections[0].active);
}
int main(void) {
test_authentication_visibility_and_backpressure();
test_timeout_ping_and_command();
test_reset_notification_invalidates_authenticated_client();
puts("sync service tests passed");
return 0;
}