diff options
Diffstat (limited to 'auto_tests')
-rw-r--r-- | auto_tests/TCP_test.c | 13 | ||||
-rw-r--r-- | auto_tests/network_test.c | 10 |
2 files changed, 12 insertions, 11 deletions
diff --git a/auto_tests/TCP_test.c b/auto_tests/TCP_test.c index 5c656541..898c5e08 100644 --- a/auto_tests/TCP_test.c +++ b/auto_tests/TCP_test.c | |||
@@ -35,7 +35,7 @@ START_TEST(test_basic) | |||
35 | Socket sock = net_socket(TOX_AF_INET6, TOX_SOCK_STREAM, TOX_PROTO_TCP); | 35 | Socket sock = net_socket(TOX_AF_INET6, TOX_SOCK_STREAM, TOX_PROTO_TCP); |
36 | IP_Port ip_port_loopback; | 36 | IP_Port ip_port_loopback; |
37 | ip_port_loopback.ip.family = TOX_AF_INET6; | 37 | ip_port_loopback.ip.family = TOX_AF_INET6; |
38 | ip_port_loopback.ip.ip6 = IP6_LOOPBACK; | 38 | ip_port_loopback.ip.ip6 = get_ip6_loopback(); |
39 | ip_port_loopback.port = net_htons(ports[rand() % NUM_PORTS]); | 39 | ip_port_loopback.port = net_htons(ports[rand() % NUM_PORTS]); |
40 | 40 | ||
41 | int ret = net_connect(sock, ip_port_loopback); | 41 | int ret = net_connect(sock, ip_port_loopback); |
@@ -135,8 +135,7 @@ static struct sec_TCP_con *new_TCP_con(TCP_Server *tcp_s) | |||
135 | IP_Port ip_port_loopback; | 135 | IP_Port ip_port_loopback; |
136 | ip_port_loopback.ip.family = TOX_AF_INET6; | 136 | ip_port_loopback.ip.family = TOX_AF_INET6; |
137 | ip_port_loopback.ip.ip6.uint64[0] = 0; | 137 | ip_port_loopback.ip.ip6.uint64[0] = 0; |
138 | ip_port_loopback.ip.ip6.uint64[1] = 0; | 138 | ip_port_loopback.ip.ip4 = get_ip4_loopback(); |
139 | ip_port_loopback.ip.ip6.uint8[15] = 1; // ::1 | ||
140 | ip_port_loopback.port = net_htons(ports[rand() % NUM_PORTS]); | 139 | ip_port_loopback.port = net_htons(ports[rand() % NUM_PORTS]); |
141 | 140 | ||
142 | int ret = net_connect(sock, ip_port_loopback); | 141 | int ret = net_connect(sock, ip_port_loopback); |
@@ -404,7 +403,7 @@ START_TEST(test_client) | |||
404 | 403 | ||
405 | ip_port_tcp_s.port = net_htons(ports[rand() % NUM_PORTS]); | 404 | ip_port_tcp_s.port = net_htons(ports[rand() % NUM_PORTS]); |
406 | ip_port_tcp_s.ip.family = TOX_AF_INET6; | 405 | ip_port_tcp_s.ip.family = TOX_AF_INET6; |
407 | ip_port_tcp_s.ip.ip6 = IP6_LOOPBACK; | 406 | ip_port_tcp_s.ip.ip6 = get_ip6_loopback(); |
408 | TCP_Client_Connection *conn = new_TCP_connection(ip_port_tcp_s, self_public_key, f_public_key, f_secret_key, 0); | 407 | TCP_Client_Connection *conn = new_TCP_connection(ip_port_tcp_s, self_public_key, f_public_key, f_secret_key, 0); |
409 | c_sleep(50); | 408 | c_sleep(50); |
410 | do_TCP_connection(conn, NULL); | 409 | do_TCP_connection(conn, NULL); |
@@ -502,7 +501,7 @@ START_TEST(test_client_invalid) | |||
502 | 501 | ||
503 | ip_port_tcp_s.port = net_htons(ports[rand() % NUM_PORTS]); | 502 | ip_port_tcp_s.port = net_htons(ports[rand() % NUM_PORTS]); |
504 | ip_port_tcp_s.ip.family = TOX_AF_INET6; | 503 | ip_port_tcp_s.ip.family = TOX_AF_INET6; |
505 | ip_port_tcp_s.ip.ip6 = IP6_LOOPBACK; | 504 | ip_port_tcp_s.ip.ip6 = get_ip6_loopback(); |
506 | TCP_Client_Connection *conn = new_TCP_connection(ip_port_tcp_s, self_public_key, f_public_key, f_secret_key, 0); | 505 | TCP_Client_Connection *conn = new_TCP_connection(ip_port_tcp_s, self_public_key, f_public_key, f_secret_key, 0); |
507 | c_sleep(50); | 506 | c_sleep(50); |
508 | do_TCP_connection(conn, NULL); | 507 | do_TCP_connection(conn, NULL); |
@@ -571,7 +570,7 @@ START_TEST(test_tcp_connection) | |||
571 | 570 | ||
572 | ip_port_tcp_s.port = net_htons(ports[rand() % NUM_PORTS]); | 571 | ip_port_tcp_s.port = net_htons(ports[rand() % NUM_PORTS]); |
573 | ip_port_tcp_s.ip.family = TOX_AF_INET6; | 572 | ip_port_tcp_s.ip.family = TOX_AF_INET6; |
574 | ip_port_tcp_s.ip.ip6 = IP6_LOOPBACK; | 573 | ip_port_tcp_s.ip.ip6 = get_ip6_loopback(); |
575 | 574 | ||
576 | int connection = new_tcp_connection_to(tc_1, tcp_connections_public_key(tc_2), 123); | 575 | int connection = new_tcp_connection_to(tc_1, tcp_connections_public_key(tc_2), 123); |
577 | ck_assert_msg(connection == 0, "Connection id wrong"); | 576 | ck_assert_msg(connection == 0, "Connection id wrong"); |
@@ -680,7 +679,7 @@ START_TEST(test_tcp_connection2) | |||
680 | 679 | ||
681 | ip_port_tcp_s.port = net_htons(ports[rand() % NUM_PORTS]); | 680 | ip_port_tcp_s.port = net_htons(ports[rand() % NUM_PORTS]); |
682 | ip_port_tcp_s.ip.family = TOX_AF_INET6; | 681 | ip_port_tcp_s.ip.family = TOX_AF_INET6; |
683 | ip_port_tcp_s.ip.ip6 = IP6_LOOPBACK; | 682 | ip_port_tcp_s.ip.ip6 = get_ip6_loopback(); |
684 | 683 | ||
685 | int connection = new_tcp_connection_to(tc_1, tcp_connections_public_key(tc_2), 123); | 684 | int connection = new_tcp_connection_to(tc_1, tcp_connections_public_key(tc_2), 123); |
686 | ck_assert_msg(connection == 0, "Connection id wrong"); | 685 | ck_assert_msg(connection == 0, "Connection id wrong"); |
diff --git a/auto_tests/network_test.c b/auto_tests/network_test.c index 200c04db..4713528d 100644 --- a/auto_tests/network_test.c +++ b/auto_tests/network_test.c | |||
@@ -38,7 +38,7 @@ START_TEST(test_addr_resolv_localhost) | |||
38 | 38 | ||
39 | char ip_str[IP_NTOA_LEN]; | 39 | char ip_str[IP_NTOA_LEN]; |
40 | ck_assert_msg(ip.family == TOX_AF_INET, "Expected family TOX_AF_INET, got %u.", ip.family); | 40 | ck_assert_msg(ip.family == TOX_AF_INET, "Expected family TOX_AF_INET, got %u.", ip.family); |
41 | const uint32_t loopback = net_htonl(IP4_LOOPBACK.uint32); | 41 | const uint32_t loopback = get_ip4_loopback().uint32; |
42 | ck_assert_msg(ip.ip4.uint32 == loopback, "Expected 127.0.0.1, got %s.", | 42 | ck_assert_msg(ip.ip4.uint32 == loopback, "Expected 127.0.0.1, got %s.", |
43 | ip_ntoa(&ip, ip_str, sizeof(ip_str))); | 43 | ip_ntoa(&ip, ip_str, sizeof(ip_str))); |
44 | 44 | ||
@@ -53,7 +53,8 @@ START_TEST(test_addr_resolv_localhost) | |||
53 | ck_assert_msg(res > 0, "Resolver failed: %u, %s (%x, %x)", errno, strerror(errno)); | 53 | ck_assert_msg(res > 0, "Resolver failed: %u, %s (%x, %x)", errno, strerror(errno)); |
54 | 54 | ||
55 | ck_assert_msg(ip.family == TOX_AF_INET6, "Expected family TOX_AF_INET6 (%u), got %u.", TOX_AF_INET6, ip.family); | 55 | ck_assert_msg(ip.family == TOX_AF_INET6, "Expected family TOX_AF_INET6 (%u), got %u.", TOX_AF_INET6, ip.family); |
56 | ck_assert_msg(!memcmp(&ip.ip6, &IP6_LOOPBACK, sizeof(IP6)), "Expected ::1, got %s.", | 56 | IP6 ip6_loopback = get_ip6_loopback(); |
57 | ck_assert_msg(!memcmp(&ip.ip6, &ip6_loopback, sizeof(IP6)), "Expected ::1, got %s.", | ||
57 | ip_ntoa(&ip, ip_str, sizeof(ip_str))); | 58 | ip_ntoa(&ip, ip_str, sizeof(ip_str))); |
58 | 59 | ||
59 | if (localhost_split) { | 60 | if (localhost_split) { |
@@ -69,7 +70,7 @@ START_TEST(test_addr_resolv_localhost) | |||
69 | ck_assert_msg(res > 0, "Resolver failed: %u, %s (%x, %x)", errno, strerror(errno)); | 70 | ck_assert_msg(res > 0, "Resolver failed: %u, %s (%x, %x)", errno, strerror(errno)); |
70 | 71 | ||
71 | ck_assert_msg(ip.family == TOX_AF_INET6, "Expected family TOX_AF_INET6 (%u), got %u.", TOX_AF_INET6, ip.family); | 72 | ck_assert_msg(ip.family == TOX_AF_INET6, "Expected family TOX_AF_INET6 (%u), got %u.", TOX_AF_INET6, ip.family); |
72 | ck_assert_msg(!memcmp(&ip.ip6, &IP6_LOOPBACK, sizeof(IP6)), "Expected ::1, got %s.", | 73 | ck_assert_msg(!memcmp(&ip.ip6, &ip6_loopback, sizeof(IP6)), "Expected ::1, got %s.", |
73 | ip_ntoa(&ip, ip_str, sizeof(ip_str))); | 74 | ip_ntoa(&ip, ip_str, sizeof(ip_str))); |
74 | 75 | ||
75 | ck_assert_msg(extra.family == TOX_AF_INET, "Expected family TOX_AF_INET (%u), got %u.", TOX_AF_INET, extra.family); | 76 | ck_assert_msg(extra.family == TOX_AF_INET, "Expected family TOX_AF_INET (%u), got %u.", TOX_AF_INET, extra.family); |
@@ -127,7 +128,8 @@ START_TEST(test_ip_equal) | |||
127 | ck_assert_msg(res != 0, "ip_equal( {TOX_AF_INET, 127.0.0.1}, {TOX_AF_INET6, ::ffff:127.0.0.1} ): " | 128 | ck_assert_msg(res != 0, "ip_equal( {TOX_AF_INET, 127.0.0.1}, {TOX_AF_INET6, ::ffff:127.0.0.1} ): " |
128 | "expected result != 0, got 0."); | 129 | "expected result != 0, got 0."); |
129 | 130 | ||
130 | memcpy(&ip2.ip6, &IP6_LOOPBACK, sizeof(IP6)); | 131 | IP6 ip6_loopback = get_ip6_loopback(); |
132 | memcpy(&ip2.ip6, &ip6_loopback, sizeof(IP6)); | ||
131 | res = ip_equal(&ip1, &ip2); | 133 | res = ip_equal(&ip1, &ip2); |
132 | ck_assert_msg(res == 0, "ip_equal( {TOX_AF_INET, 127.0.0.1}, {TOX_AF_INET6, ::1} ): expected result 0, got %u.", res); | 134 | ck_assert_msg(res == 0, "ip_equal( {TOX_AF_INET, 127.0.0.1}, {TOX_AF_INET6, ::1} ): expected result 0, got %u.", res); |
133 | 135 | ||