diff --git a/tests/test_chat_sync_stress.c b/tests/test_chat_sync_stress.c index 26756ca0..b632ee95 100644 --- a/tests/test_chat_sync_stress.c +++ b/tests/test_chat_sync_stress.c @@ -119,14 +119,18 @@ static int wait_for(const char* desc, int timeout_tb, uint64_t* elapsed_out) { return ok; } -/* db_sync-валидация требует, чтобы пир был мембером канала (peers_). */ +/* Изолированная фикстура db_sync: полное членство задано заранее; проверка join-подписей — в test_chat_join_e2e. */ static void seed_members(struct UTUN_INSTANCE* self, struct UTUN_INSTANCE* peer) { sqlite3* db = self ? self->topo_sqlite_db : NULL; if (!db || !peer || !peer->node_id) return; char ch_id[32]; snprintf(ch_id, sizeof(ch_id), "%u", INSTANCE_ID); uint8_t z32[32] = {0}, z64[64] = {0}; topo_node_sqlite_channel_put(db, ch_id, INSTANCE_NAME, 0, z32, NULL, z32, NULL, z64); - topo_node_sqlite_member_placeholder_put(db, ch_id, peer->node_id, z32, z32); + if (topo_node_sqlite_node_update_verified(db, peer->node_id, "stress peer", peer->my_keys.public_key, + peer->my_ed25519_pubkey, 1, 0) < 0 || topo_node_sqlite_member_block_put(db, ch_id, peer->node_id, z64, 1, + NULL, 0, peer->my_keys.public_key, peer->my_ed25519_pubkey, "{}", NULL, 0, z64) < 0) { + DEBUG_ERROR(DEBUG_CATEGORY_CHAT_SYNC, "stress member fixture failed peer=%016llx", (unsigned long long)peer->node_id); abort(); + } if (!topo_groups_find(self->topo_groups, INSTANCE_ID)) topo_groups_create_group(self->topo_groups, INSTANCE_ID, TOPO_GROUP_TYPE_CHAT, ch_id); } diff --git a/tests/test_db_sync.c b/tests/test_db_sync.c index 11e801e2..b435b0c2 100644 --- a/tests/test_db_sync.c +++ b/tests/test_db_sync.c @@ -193,8 +193,7 @@ static void remove_si(struct DB_SYNC_INSTANCE** psi) { if (*psi) { db_sync_instance_remove(*psi); *psi = NULL; } } -/* db_sync-валидация требует, чтобы пир был мембером канала (peers_). - * Тест db_sync работает в изоляции — создаём peers-таблицы и помечаем пиров мемберами. */ +/* Изолированная фикстура db_sync задаёт полное членство; join-подписи проверяет test_chat_join_e2e. */ static void seed_members(struct UTUN_INSTANCE* self, struct UTUN_INSTANCE** peers, int peer_count) { static const char* groups[] = { "1", "2", "30", "40", "70", "80" }; sqlite3* db = self ? self->topo_sqlite_db : NULL; @@ -202,9 +201,15 @@ static void seed_members(struct UTUN_INSTANCE* self, struct UTUN_INSTANCE** peer uint8_t z32[32] = {0}, z64[64] = {0}; for (unsigned gi = 0; gi < sizeof(groups) / sizeof(groups[0]); gi++) { topo_node_sqlite_channel_put(db, groups[gi], "test", 0, z32, NULL, z32, NULL, z64); - for (int i = 0; i < peer_count; i++) - if (peers[i] && peers[i]->node_id) - topo_node_sqlite_member_placeholder_put(db, groups[gi], peers[i]->node_id, z32, z32); + for (int i = 0; i < peer_count; i++) { + struct UTUN_INSTANCE* peer = peers[i]; + if (!peer || !peer->node_id) continue; + if (topo_node_sqlite_node_update_verified(db, peer->node_id, "sync peer", peer->my_keys.public_key, + peer->my_ed25519_pubkey, 1, 0) < 0 || topo_node_sqlite_member_block_put(db, groups[gi], peer->node_id, z64, 1, + NULL, 0, peer->my_keys.public_key, peer->my_ed25519_pubkey, "{}", NULL, 0, z64) < 0) { + DEBUG_ERROR(DEBUG_CATEGORY_CHAT_SYNC, "member fixture failed peer=%016llx", (unsigned long long)peer->node_id); abort(); + } + } uint64_t gid = strtoull(groups[gi], NULL, 10); if (!topo_groups_find(self->topo_groups, gid)) topo_groups_create_group(self->topo_groups, gid, TOPO_GROUP_TYPE_CHAT, groups[gi]);