diff --git a/auto_tests/conference_test.c b/auto_tests/conference_test.c index b99b9af7..46b58224 100644 --- a/auto_tests/conference_test.c +++ b/auto_tests/conference_test.c @@ -106,7 +106,9 @@ group_test_restart: { TOX_ERR_GET_PORT error; - ck_assert_msg(tox_self_get_udp_port(toxes[0], &error) == 33445, "First Tox instance did not bind to udp port 33445.\n"); + const uint16_t port = tox_self_get_udp_port(toxes[0], &error); + ck_assert_msg(33445 <= port && port <= 33545, + "First Tox instance did not bind to udp port inside [33445, 33545].\n"); ck_assert_msg(error == TOX_ERR_GET_PORT_OK, "wrong error"); } diff --git a/auto_tests/tox_many_tcp_test.c b/auto_tests/tox_many_tcp_test.c index 510109ee..8234513c 100644 --- a/auto_tests/tox_many_tcp_test.c +++ b/auto_tests/tox_many_tcp_test.c @@ -74,7 +74,9 @@ START_TEST(test_many_clients_tcp) { TOX_ERR_GET_PORT error; - ck_assert_msg(tox_self_get_udp_port(toxes[0], &error) == 33445, "First Tox instance did not bind to udp port 33445.\n"); + uint16_t port = tox_self_get_udp_port(toxes[0], &error); + ck_assert_msg(33445 <= port && port <= 33545, + "First Tox instance did not bind to udp port inside [33445, 33545].\n"); ck_assert_msg(error == TOX_ERR_GET_PORT_OK, "wrong error"); ck_assert_msg(tox_self_get_tcp_port(toxes[0], &error) == TCP_RELAY_PORT, "First Tox instance did not bind to tcp port %u.\n", TCP_RELAY_PORT); @@ -176,7 +178,9 @@ START_TEST(test_many_clients_tcp_b) { TOX_ERR_GET_PORT error; - ck_assert_msg(tox_self_get_udp_port(toxes[0], &error) == 33445, "First Tox instance did not bind to udp port 33445.\n"); + uint16_t port = tox_self_get_udp_port(toxes[0], &error); + ck_assert_msg(33445 <= port && port <= 33545, + "First Tox instance did not bind to udp port inside [33445, 33545].\n"); ck_assert_msg(error == TOX_ERR_GET_PORT_OK, "wrong error"); ck_assert_msg(tox_self_get_tcp_port(toxes[0], &error) == TCP_RELAY_PORT, "First Tox instance did not bind to tcp port %u.\n", TCP_RELAY_PORT); diff --git a/auto_tests/tox_many_test.c b/auto_tests/tox_many_test.c index a34cfa8d..7ab0facc 100644 --- a/auto_tests/tox_many_test.c +++ b/auto_tests/tox_many_test.c @@ -50,7 +50,9 @@ START_TEST(test_many_clients) { TOX_ERR_GET_PORT error; - ck_assert_msg(tox_self_get_udp_port(toxes[0], &error) == 33445, "First Tox instance did not bind to udp port 33445.\n"); + uint16_t port = tox_self_get_udp_port(toxes[0], &error); + ck_assert_msg(33445 <= port && port <= 33545, + "First Tox instance did not bind to udp port inside [33445, 33545].\n"); ck_assert_msg(error == TOX_ERR_GET_PORT_OK, "wrong error"); } diff --git a/auto_tests/tox_one_test.c b/auto_tests/tox_one_test.c index 1b277d96..7a429ac8 100644 --- a/auto_tests/tox_one_test.c +++ b/auto_tests/tox_one_test.c @@ -127,7 +127,9 @@ START_TEST(test_one) { TOX_ERR_GET_PORT error; - ck_assert_msg(tox_self_get_udp_port(tox1, &error) == 33445, "First Tox instance did not bind to udp port 33445.\n"); + uint16_t port = tox_self_get_udp_port(tox1, &error); + ck_assert_msg(33445 <= port && port <= 33545, + "First Tox instance did not bind to udp port inside [33445, 33545].\n"); ck_assert_msg(error == TOX_ERR_GET_PORT_OK, "wrong error"); } diff --git a/auto_tests/tox_test.c b/auto_tests/tox_test.c index 06164194..32df1b57 100644 --- a/auto_tests/tox_test.c +++ b/auto_tests/tox_test.c @@ -331,19 +331,17 @@ START_TEST(test_few_clients) { TOX_ERR_GET_PORT error; - ck_assert_msg(tox_self_get_udp_port(tox1, &error) == 33445, "First Tox instance did not bind to udp port 33445.\n"); + uint16_t first_port = tox_self_get_udp_port(tox1, &error); + ck_assert_msg(33445 <= first_port && first_port <= 33545 - 2, + "First Tox instance did not bind to udp port inside [33445, 33543].\n"); ck_assert_msg(error == TOX_ERR_GET_PORT_OK, "wrong error"); - } - { - TOX_ERR_GET_PORT error; - ck_assert_msg(tox_self_get_udp_port(tox2, &error) == 33446, "Second Tox instance did not bind to udp port 33446.\n"); + ck_assert_msg(tox_self_get_udp_port(tox2, &error) == first_port + 1, + "Second Tox instance did not bind to udp port %d.\n", first_port + 1); ck_assert_msg(error == TOX_ERR_GET_PORT_OK, "wrong error"); - } - { - TOX_ERR_GET_PORT error; - ck_assert_msg(tox_self_get_udp_port(tox3, &error) == 33447, "Third Tox instance did not bind to udp port 33447.\n"); + ck_assert_msg(tox_self_get_udp_port(tox3, &error) == first_port + 2, + "Third Tox instance did not bind to udp port %d.\n", first_port + 2); ck_assert_msg(error == TOX_ERR_GET_PORT_OK, "wrong error"); }