From f92077e601e97af24de8eadbd59c2b56a6c2400f Mon Sep 17 00:00:00 2001 From: evgeny Date: Mon, 26 Oct 2026 17:55:50 +0100 Subject: [PATCH] Isolate stream wake state and require full roots in sync stress --- tests/test_chat_sync_stress.c | 9 +++++++-- tests/test_stream_service.c | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/test_chat_sync_stress.c b/tests/test_chat_sync_stress.c index 6884b926..24932748 100644 --- a/tests/test_chat_sync_stress.c +++ b/tests/test_chat_sync_stress.c @@ -99,16 +99,21 @@ static void cleanup_temp_configs(void) { static void test_timeout(void* arg) { (void)arg; test_phase = 2; } +static int histories_match(void) { + uint8_t a[32], b[32]; + return db_sync_count(si_a) == expected_total && db_sync_count(si_b) == expected_total + && db_sync_read_root(si_a, a) == 0 && db_sync_read_root(si_b, b) == 0 && !memcmp(a, b, 32); +} static int wait_for(const char* desc, int timeout_tb, uint64_t* elapsed_out) { uint64_t start = get_time_tb(); uint32_t ca0 = si_a ? db_sync_count(si_a) : 0, cb0 = si_b ? db_sync_count(si_b) : 0; DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "SYNC_START %s A=%u B=%u expect=%u", desc, ca0, cb0, expected_total); - while ((db_sync_count(si_a) != expected_total || db_sync_count(si_b) != expected_total) + while (!histories_match() && (get_time_tb() - start) < (uint64_t)timeout_tb && test_phase == 0) uasync_poll(ua, POLL_INTERVAL_MS); uint32_t ca = si_a ? db_sync_count(si_a) : 0, cb = si_b ? db_sync_count(si_b) : 0; uint64_t elapsed = (get_time_tb() - start) / 10; - int ok = (ca == expected_total && cb == expected_total); + int ok = histories_match(); if (ok) DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "SYNC_DONE %s A=%u B=%u %llums", desc, ca, cb, (unsigned long long)elapsed); else { diff --git a/tests/test_stream_service.c b/tests/test_stream_service.c index a7654bb9..92210e91 100644 --- a/tests/test_stream_service.c +++ b/tests/test_stream_service.c @@ -2314,6 +2314,8 @@ static void test_partial_bootstrap_and_end(void) { static void test_sources_after_wake(void) { debug_level_t level = g_debug_config.category_levels[DEBUG_CATEGORY_KEEPALIVE]; debug_set_category_level(DEBUG_CATEGORY_KEEPALIVE, DEBUG_LEVEL_INFO); + /* Предыдущий recovery оставляет центральный mobile-узел в standby; здесь спит только проверяемый получатель. */ + CHECK(utun_set_client_activity(nodes[0], CLIENT_ACTIVITY_ACTIVE) == 0); CHECK(utun_set_client_activity(nodes[2], 1) == 0); /* Каналы стенда внесены напрямую в БД после init; ждём первого обновления кеша chat_sync (5 с). */ test_clock_run_for(ua, 51000);