8
8
#include "../toxcore/TCP_server.h"
9
9
#include "../toxcore/crypto_core.h"
10
10
#include "../toxcore/mono_time.h"
11
+ #include "../toxcore/net_profile.h"
11
12
#include "../toxcore/network.h"
12
13
#include "auto_test_support.h"
13
14
@@ -737,6 +738,9 @@ static void test_tcp_connection(void)
737
738
Mono_Time * mono_time = mono_time_new (mem , nullptr , nullptr );
738
739
Logger * logger = logger_new (mem );
739
740
741
+ Net_Profile * tcp_np = netprof_new (logger , mem );
742
+ ck_assert (tcp_np != nullptr );
743
+
740
744
tcp_data_callback_called = 0 ;
741
745
uint8_t self_public_key [CRYPTO_PUBLIC_KEY_SIZE ];
742
746
uint8_t self_secret_key [CRYPTO_SECRET_KEY_SIZE ];
@@ -747,12 +751,12 @@ static void test_tcp_connection(void)
747
751
TCP_Proxy_Info proxy_info ;
748
752
proxy_info .proxy_type = TCP_PROXY_NONE ;
749
753
crypto_new_keypair (rng , self_public_key , self_secret_key );
750
- TCP_Connections * tc_1 = new_tcp_connections (logger , mem , rng , ns , mono_time , self_secret_key , & proxy_info );
754
+ TCP_Connections * tc_1 = new_tcp_connections (logger , mem , rng , ns , mono_time , self_secret_key , & proxy_info , tcp_np );
751
755
ck_assert_msg (tc_1 != nullptr , "Failed to create TCP connections" );
752
756
ck_assert_msg (pk_equal (tcp_connections_public_key (tc_1 ), self_public_key ), "Wrong public key" );
753
757
754
758
crypto_new_keypair (rng , self_public_key , self_secret_key );
755
- TCP_Connections * tc_2 = new_tcp_connections (logger , mem , rng , ns , mono_time , self_secret_key , & proxy_info );
759
+ TCP_Connections * tc_2 = new_tcp_connections (logger , mem , rng , ns , mono_time , self_secret_key , & proxy_info , tcp_np );
756
760
ck_assert_msg (tc_2 != nullptr , "Failed to create TCP connections" );
757
761
ck_assert_msg (pk_equal (tcp_connections_public_key (tc_2 ), self_public_key ), "Wrong public key" );
758
762
@@ -811,6 +815,8 @@ static void test_tcp_connection(void)
811
815
ck_assert_msg (send_packet_tcp_connection (tc_1 , 0 , (const uint8_t * )"Gentoo" , 6 ) == -1 , "could send packet." );
812
816
ck_assert_msg (kill_tcp_connection_to (tc_2 , 0 ) == 0 , "could not kill connection to\n" );
813
817
818
+ netprof_kill (mem , tcp_np );
819
+
814
820
kill_tcp_server (tcp_s );
815
821
kill_tcp_connections (tc_1 );
816
822
kill_tcp_connections (tc_2 );
@@ -852,6 +858,9 @@ static void test_tcp_connection2(void)
852
858
Mono_Time * mono_time = mono_time_new (mem , nullptr , nullptr );
853
859
Logger * logger = logger_new (mem );
854
860
861
+ Net_Profile * tcp_np = netprof_new (logger , mem );
862
+ ck_assert (tcp_np != nullptr );
863
+
855
864
tcp_oobdata_callback_called = 0 ;
856
865
tcp_data_callback_called = 0 ;
857
866
@@ -864,12 +873,12 @@ static void test_tcp_connection2(void)
864
873
TCP_Proxy_Info proxy_info ;
865
874
proxy_info .proxy_type = TCP_PROXY_NONE ;
866
875
crypto_new_keypair (rng , self_public_key , self_secret_key );
867
- TCP_Connections * tc_1 = new_tcp_connections (logger , mem , rng , ns , mono_time , self_secret_key , & proxy_info );
876
+ TCP_Connections * tc_1 = new_tcp_connections (logger , mem , rng , ns , mono_time , self_secret_key , & proxy_info , tcp_np );
868
877
ck_assert_msg (tc_1 != nullptr , "Failed to create TCP connections" );
869
878
ck_assert_msg (pk_equal (tcp_connections_public_key (tc_1 ), self_public_key ), "Wrong public key" );
870
879
871
880
crypto_new_keypair (rng , self_public_key , self_secret_key );
872
- TCP_Connections * tc_2 = new_tcp_connections (logger , mem , rng , ns , mono_time , self_secret_key , & proxy_info );
881
+ TCP_Connections * tc_2 = new_tcp_connections (logger , mem , rng , ns , mono_time , self_secret_key , & proxy_info , tcp_np );
873
882
ck_assert_msg (tc_2 != nullptr , "Failed to create TCP connections" );
874
883
ck_assert_msg (pk_equal (tcp_connections_public_key (tc_2 ), self_public_key ), "Wrong public key" );
875
884
@@ -921,6 +930,8 @@ static void test_tcp_connection2(void)
921
930
ck_assert_msg (tcp_data_callback_called , "could not recv packet." );
922
931
ck_assert_msg (kill_tcp_connection_to (tc_1 , 0 ) == 0 , "could not kill connection to\n" );
923
932
933
+ netprof_kill (mem , tcp_np );
934
+
924
935
kill_tcp_server (tcp_s );
925
936
kill_tcp_connections (tc_1 );
926
937
kill_tcp_connections (tc_2 );
0 commit comments