tests: use independent ports for radio and call topologies

This commit is contained in:
evgeny committed 2026-10-10 15:45:38 +02:00
1 parent ce8144b79e
commit 91909fbb1e
3 files changed
+29 -27

No files matched your search

+7 -8
View File
@@ -31,6 +31,7 @@
#include "../lib/mem.h"
#include "../lib/platform_compat.h"
#include "test_utils.h"
#include "test_net.h"
#include <sqlite3.h>
#define OPENSSL_API_COMPAT 0x10100000L
@@ -114,7 +115,6 @@ struct call_shared {
uint8_t ch_x_pub[32], ch_ed_pub[32], ch_ed_priv[32], ch_sig[64];
uint64_t nid[2];
uint8_t x_pub[2][32], x_priv[2][32], ed_pub[2][32];
int port[2];
};
static struct call_shared g_sh;
@@ -175,14 +175,13 @@ static int wf(const char* p, const char* f, ...) {
/* ── генерация данных сценария + конфигов ── */
static void fill_shared(int base_port) {
static void fill_shared(void) {
memset(&g_sh, 0, sizeof(g_sh));
for (int i = 0; i < 2; i++) {
gen_x25519(g_sh.x_pub[i], g_sh.x_priv[i]);
sc_derive_ed25519_pubkey(g_sh.x_priv[i], g_sh.ed_pub[i]);
g_sh.nid[i] = sc_derive_node_id_from_pubkey(g_sh.x_pub[i]);
g_sh.port[i] = base_port + i * 1000;
}
{ uint8_t ch_x_priv[32]; gen_x25519(g_sh.ch_x_pub, ch_x_priv); }
@@ -213,18 +212,17 @@ static void write_configs(const char* dir) {
/* B → A (клиент к A) */
char apub[65]; to_hex(g_sh.x_pub[IDX_A], 32, apub);
snprintf(client, sizeof(client),
"[client: to_a]\npeer_public_key=%s\nlink=s1:127.0.0.1:%d\n",
apub, g_sh.port[IDX_A]);
"[client: to_a]\npeer_public_key=%s\nlink=s1:127.0.0.1:0\n", apub);
}
wf(path,
"[global]\ntun_ip=10.97.%d.1/24\ntun_ifname=tun%d0\ndb_path=%s/db%s\n"
"my_private_key=%s\nmy_public_key=%s\n"
"[server: s1]\naddr=127.0.0.1:%d\ntype=public\n"
"[server: s1]\naddr=127.0.0.1:0\ntype=public\n"
"%s"
"[chatserver]\nstorage_autoload=0\n[allowed_keys]\nallow_all=1\n",
i, i, dir, i == IDX_A ? "a" : "b",
priv, pub, g_sh.port[i], client);
priv, pub, client);
}
}
@@ -514,7 +512,7 @@ int main(int argc, char** argv) {
if (test_mkdtemp(dir) != 0) { fprintf(stderr, "mkdtemp failed\n"); return 1; }
test_setenv("UTUN_TEST_DIR", dir, 1);
fill_shared(56000 + (getpid() % 2000));
fill_shared();
write_configs(dir);
printf("=== test_call ===\n"); fflush(stdout);
@@ -542,6 +540,7 @@ int main(int argc, char** argv) {
uasync_destroy(ua, 0);
return 1;
}
test_etcp_set_peer(t.inst[IDX_B], "to_a", t.inst[IDX_A], "s1");
utun_instance_init(t.inst[IDX_A]);
utun_instance_init(t.inst[IDX_B]);