From 3fe697e1a9c66fef45130734dd1e07be12553e08 Mon Sep 17 00:00:00 2001 From: evgeny Date: Mon, 26 Oct 2026 17:24:22 +0100 Subject: [PATCH] Log history pause and await verified roots in empty peer fixtures --- src/chat/db_sync.c | 2 ++ tests/test_db_sync.c | 13 ++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/chat/db_sync.c b/src/chat/db_sync.c index 62ea2f74..fa0e7703 100644 --- a/src/chat/db_sync.c +++ b/src/chat/db_sync.c @@ -1112,6 +1112,8 @@ void db_sync_peer_set_paused(struct DB_SYNC_INSTANCE* si, uint64_t peer, int pau struct SI_PEER* p = si ? si_peer_add(si, peer) : NULL; if (!p) return; p->paused = !!paused; p->sync_state = 0; + DEBUG_INFO(DEBUG_CATEGORY_CHAT_SYNC, "history peer pause tbl=%s peer=%016llx paused=%u", + SI_TBL(si), (unsigned long long)peer, p->paused); if (paused) merkle_sync_cancel(si->db_sync->inst, MT_DATA_MESSAGES, peer, si->ns); else db_start_peer(si, peer); } diff --git a/tests/test_db_sync.c b/tests/test_db_sync.c index 82539003..d9d8d286 100644 --- a/tests/test_db_sync.c +++ b/tests/test_db_sync.c @@ -62,6 +62,7 @@ static char temp_dir[] = "/tmp/utun_dbsync_XXXXXX"; static char config_a[256], config_b[256], config_c[256]; static uint32_t ca_target, cb_target, cc_target; static uint64_t delivery_timestamp; +static int history_ready(struct DB_SYNC_INSTANCE* si); /* Оба сообщения одного автора в одной ms получают отдельные реальные ACK. */ static int cond_delivery(void) { @@ -185,9 +186,15 @@ static int _cond_cb(void) { return g_done_b && si_b && db_sync_count(si_b) == cb static int _cond_cc(void) { return g_done_c && si_c && db_sync_count(si_c) == cc_target; } static int _cond_both(void) { return _cond_ca() && _cond_cb(); } static int _cond_all(void) { return _cond_ca() && _cond_cb() && _cond_cc(); } -static int _cond_cb_count(void) { return si_b && db_sync_count(si_b) == cb_target; } -static int _cond_both_count(void) { return si_a && db_sync_count(si_a) == ca_target && si_b && db_sync_count(si_b) == cb_target; } -static int _cond_all_count(void) { return si_a && db_sync_count(si_a) == ca_target && si_b && db_sync_count(si_b) == cb_target && si_c && db_sync_count(si_c) == cc_target; } +static int _cond_cb_count(void) { return si_b && !history_ready(si_b) && db_sync_count(si_b) == cb_target; } +static int _cond_both_count(void) { + return si_a && si_b && !history_ready(si_a) && !history_ready(si_b) && + db_sync_count(si_a) == ca_target && db_sync_count(si_b) == cb_target; +} +static int _cond_all_count(void) { + return si_a && si_b && si_c && !history_ready(si_a) && !history_ready(si_b) && !history_ready(si_c) && + db_sync_count(si_a) == ca_target && db_sync_count(si_b) == cb_target && db_sync_count(si_c) == cc_target; +} static int insert_many(struct DB_SYNC_INSTANCE* si, struct UTUN_INSTANCE* inst, int start, int count) { char buf[128];