summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--auto_tests/TCP_test.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/auto_tests/TCP_test.c b/auto_tests/TCP_test.c
index 92205e52..7eabd984 100644
--- a/auto_tests/TCP_test.c
+++ b/auto_tests/TCP_test.c
@@ -508,6 +508,33 @@ START_TEST(test_client_invalid)
508} 508}
509END_TEST 509END_TEST
510 510
511#include "../toxcore/TCP_connection.h"
512
513START_TEST(test_tcp_connection)
514{
515 uint8_t self_public_key[crypto_box_PUBLICKEYBYTES];
516 uint8_t self_secret_key[crypto_box_SECRETKEYBYTES];
517 crypto_box_keypair(self_public_key, self_secret_key);
518 TCP_Server *tcp_s = new_TCP_server(1, NUM_PORTS, ports, self_secret_key, NULL);
519 ck_assert_msg(memcmp(tcp_s->public_key, self_public_key, crypto_box_PUBLICKEYBYTES) == 0, "Wrong public key");
520
521 TCP_Proxy_Info proxy_info;
522 proxy_info.proxy_type = TCP_PROXY_NONE;
523 crypto_box_keypair(self_public_key, self_secret_key);
524 TCP_Connections *tc_1 = new_tcp_connections(self_secret_key, &proxy_info);
525 ck_assert_msg(memcmp(tc_1->self_public_key, self_public_key, crypto_box_PUBLICKEYBYTES) == 0, "Wrong public key");
526
527 crypto_box_keypair(self_public_key, self_secret_key);
528 TCP_Connections *tc_2 = new_tcp_connections(self_secret_key, &proxy_info);
529 ck_assert_msg(memcmp(tc_2->self_public_key, self_public_key, crypto_box_PUBLICKEYBYTES) == 0, "Wrong public key");
530
531
532 kill_TCP_server(tcp_s);
533 kill_tcp_connections(tc_1);
534 kill_tcp_connections(tc_2);
535}
536END_TEST
537
511Suite *TCP_suite(void) 538Suite *TCP_suite(void)
512{ 539{
513 Suite *s = suite_create("TCP"); 540 Suite *s = suite_create("TCP");
@@ -516,6 +543,7 @@ Suite *TCP_suite(void)
516 DEFTESTCASE_SLOW(some, 10); 543 DEFTESTCASE_SLOW(some, 10);
517 DEFTESTCASE_SLOW(client, 10); 544 DEFTESTCASE_SLOW(client, 10);
518 DEFTESTCASE_SLOW(client_invalid, 15); 545 DEFTESTCASE_SLOW(client_invalid, 15);
546 DEFTESTCASE_SLOW(tcp_connection, 20);
519 return s; 547 return s;
520} 548}
521 549