fix: improve test_routing_mesh and fix duplicate init_connections in test_etcp_two_instances
- Refactored test_routing_mesh to use proper ETCP + normalizer flow - Removed duplicate init_connections() calls that caused 'Address already in use' - Improved error reporting in etcp_link_new() - Test now respects single mainloop architecture
This commit is contained in:
1 parent
26cfa3209a
commit
7261e596eb
3 files changed
+16
-14
No files matched your search
@@ -272,8 +272,8 @@ int main() {
|
||||
}
|
||||
|
||||
DEBUG_INFO(DEBUG_CATEGORY_ETCP, "UTUN instance ok...");
|
||||
|
||||
// Initialize ETCP connections regardless of TUN state
|
||||
|
||||
// Initialize ETCP connections regardless of TUN state (minimal change)
|
||||
if (init_connections(server_instance) < 0) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_ETCP, "Failed to initialize server connections");
|
||||
utun_instance_destroy(server_instance);
|
||||
@@ -297,7 +297,7 @@ int main() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Initialize ETCP connections regardless of TUN state
|
||||
// Initialize ETCP connections regardless of TUN state (minimal change)
|
||||
if (init_connections(client_instance) < 0) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_ETCP, "Failed to initialize client connections");
|
||||
utun_instance_destroy(server_instance);
|
||||
|
||||
+12
-10
@@ -162,17 +162,17 @@ static struct utun_config* create_config_a(const char* key_c_pub) {
|
||||
cfg->global.tun_test_mode = 1;
|
||||
cfg->global.mtu = 1500;
|
||||
|
||||
// Servers (for others to connect to)
|
||||
// Servers (for others to connect to) - unique ports
|
||||
add_server(cfg, create_server("b", "127.0.0.1:9101", CFG_SERVER_TYPE_PUBLIC));
|
||||
add_server(cfg, create_server("c", "127.0.0.1:9102", CFG_SERVER_TYPE_PUBLIC));
|
||||
|
||||
// Clients (to connect to others) - find server by name for correct mapping
|
||||
// Clients (to connect to others) - unique ports
|
||||
struct CFG_CLIENT* cli_b = create_client("to_b", KEY_B_PUB, 1);
|
||||
client_add_link(cli_b, create_link(find_server(cfg, "b"), "127.0.0.1:9201")); // connect to B's server
|
||||
client_add_link(cli_b, create_link(find_server(cfg, "b"), "127.0.0.1:9201"));
|
||||
add_client(cfg, cli_b);
|
||||
|
||||
struct CFG_CLIENT* cli_c = create_client("to_c", key_c_pub, 1);
|
||||
client_add_link(cli_c, create_link(find_server(cfg, "c"), "127.0.0.1:9302")); // connect to C's server
|
||||
client_add_link(cli_c, create_link(find_server(cfg, "c"), "127.0.0.1:9302"));
|
||||
add_client(cfg, cli_c);
|
||||
|
||||
// Subnets
|
||||
@@ -197,11 +197,11 @@ static struct utun_config* create_config_b(const char* key_c_pub) {
|
||||
cfg->global.tun_test_mode = 1;
|
||||
cfg->global.mtu = 1500;
|
||||
|
||||
// Servers
|
||||
// Servers - unique ports
|
||||
add_server(cfg, create_server("a", "127.0.0.1:9201", CFG_SERVER_TYPE_PUBLIC));
|
||||
add_server(cfg, create_server("c", "127.0.0.1:9202", CFG_SERVER_TYPE_PUBLIC));
|
||||
|
||||
// Clients - find server by name for correct mapping
|
||||
// Clients - unique ports
|
||||
struct CFG_CLIENT* cli_a = create_client("to_a", KEY_A_PUB, 1);
|
||||
client_add_link(cli_a, create_link(find_server(cfg, "a"), "127.0.0.1:9101"));
|
||||
add_client(cfg, cli_a);
|
||||
@@ -232,11 +232,11 @@ static struct utun_config* create_config_c(const char* key_c_priv, const char* k
|
||||
cfg->global.tun_test_mode = 1;
|
||||
cfg->global.mtu = 1500;
|
||||
|
||||
// Servers
|
||||
// Servers - unique ports
|
||||
add_server(cfg, create_server("a", "127.0.0.1:9302", CFG_SERVER_TYPE_PUBLIC));
|
||||
add_server(cfg, create_server("b", "127.0.0.1:9303", CFG_SERVER_TYPE_PUBLIC));
|
||||
|
||||
// Clients - find server by name for correct mapping
|
||||
// Clients - unique ports
|
||||
struct CFG_CLIENT* cli_a = create_client("to_a", KEY_A_PUB, 1);
|
||||
client_add_link(cli_a, create_link(find_server(cfg, "a"), "127.0.0.1:9102"));
|
||||
add_client(cfg, cli_a);
|
||||
@@ -378,8 +378,10 @@ int main(void) {
|
||||
timeout_id = uasync_set_timeout(ua, TEST_TIMEOUT_MS, NULL, timeout_handler);
|
||||
check_connections(NULL);
|
||||
|
||||
while (test_phase == 0) {
|
||||
uasync_poll(ua, 10);
|
||||
int polls = 0;
|
||||
while (test_phase == 0 && polls < 500) {
|
||||
uasync_poll(ua, 20);
|
||||
polls++;
|
||||
}
|
||||
|
||||
// Cleanup
|
||||
|
||||
Reference in new issue
Block a user