From 0c16c2b09ac5652a022d2b273bd7b958faca727a Mon Sep 17 00:00:00 2001 From: evgeny Date: Tue, 6 Oct 2026 22:33:35 +0200 Subject: [PATCH] Wait for authenticated bootstrap transport before opening group requests --- tests/test_chat_poll_network.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/test_chat_poll_network.c b/tests/test_chat_poll_network.c index 79565545..586d1880 100644 --- a/tests/test_chat_poll_network.c +++ b/tests/test_chat_poll_network.c @@ -76,6 +76,19 @@ static int wait_ready(struct TOPO_PEER_REQUEST* handle) { DEBUG_ERROR(DEBUG_CATEGORY_CHAT_SYNC, "poll network: group readiness timeout phase=%d", topo_group_peer_phase(handle)); return 0; } +/* C открывает групповой запрос после входящего UP; до него адрес B ещё не получен. */ +static int wait_transport(struct NODE_CONN_DIRECT* ab, struct NODE_CONN_DIRECT* bc) { + struct ETCP_CONN *a = NULL, *b = NULL; + for (int i = 0; i < 3000; i++) { + a = node_conn_direct_get_conn(ab); b = node_conn_direct_get_conn(bc); + struct ETCP_CONN* c = instance_find_conn(nodes[2], nodes[1]->node_id); + if (a && b && c && a->initialized && b->initialized && c->initialized + && a->links_up && b->links_up && c->links_up) return 1; + uasync_poll(ua, 5); + } + DEBUG_ERROR(DEBUG_CATEGORY_CHAT_SYNC, "poll network: bootstrap timeout ab=%p bc=%p", (void*)a, (void*)b); return 0; +} + static sqlite3_int64 field(struct UTUN_INSTANCE* inst, const char* json, const char* path) { sqlite3_stmt* st = NULL; assert(sqlite3_prepare_v2(inst->topo_sqlite_db, "SELECT json_extract(?1,?2)", -1, &st, NULL) == SQLITE_OK); sqlite3_bind_text(st, 1, json, -1, SQLITE_STATIC); sqlite3_bind_text(st, 2, path, -1, SQLITE_STATIC); @@ -131,6 +144,7 @@ int main(void) { } seed_members(x, ed, owner_private); struct NODE_CONN_DIRECT* ab = connect_node(0, 1, ports[1]), *bc = connect_node(1, 2, ports[2]); + assert(wait_transport(ab, bc)); struct TOPO_PEER_REQUEST *groups[3] = {0}; uint64_t gid = strtoull(channel, NULL, 10); assert(topo_group_peer_open(topo_groups_find(nodes[0]->topo_groups, gid), nodes[1]->node_id, &groups[0]) == 0); assert(topo_group_peer_open(topo_groups_find(nodes[1]->topo_groups, gid), nodes[2]->node_id, &groups[1]) == 0);