88#include "../toxcore/TCP_server.h"
99#include "../toxcore/crypto_core.h"
1010#include "../toxcore/mono_time.h"
11+ #include "../toxcore/net_profile.h"
1112#include "../toxcore/network.h"
1213#include "auto_test_support.h"
1314
@@ -737,6 +738,9 @@ static void test_tcp_connection(void)
737738 Mono_Time * mono_time = mono_time_new (mem , nullptr , nullptr );
738739 Logger * logger = logger_new (mem );
739740
741+ Net_Profile * tcp_np = netprof_new (logger , mem );
742+ ck_assert (tcp_np != nullptr );
743+
740744 tcp_data_callback_called = 0 ;
741745 uint8_t self_public_key [CRYPTO_PUBLIC_KEY_SIZE ];
742746 uint8_t self_secret_key [CRYPTO_SECRET_KEY_SIZE ];
@@ -747,12 +751,12 @@ static void test_tcp_connection(void)
747751 TCP_Proxy_Info proxy_info ;
748752 proxy_info .proxy_type = TCP_PROXY_NONE ;
749753 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 );
751755 ck_assert_msg (tc_1 != nullptr , "Failed to create TCP connections" );
752756 ck_assert_msg (pk_equal (tcp_connections_public_key (tc_1 ), self_public_key ), "Wrong public key" );
753757
754758 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 );
756760 ck_assert_msg (tc_2 != nullptr , "Failed to create TCP connections" );
757761 ck_assert_msg (pk_equal (tcp_connections_public_key (tc_2 ), self_public_key ), "Wrong public key" );
758762
@@ -815,6 +819,8 @@ static void test_tcp_connection(void)
815819 kill_tcp_connections (tc_1 );
816820 kill_tcp_connections (tc_2 );
817821
822+ netprof_kill (mem , tcp_np );
823+
818824 logger_kill (logger );
819825 mono_time_free (mem , mono_time );
820826}
@@ -852,6 +858,9 @@ static void test_tcp_connection2(void)
852858 Mono_Time * mono_time = mono_time_new (mem , nullptr , nullptr );
853859 Logger * logger = logger_new (mem );
854860
861+ Net_Profile * tcp_np = netprof_new (logger , mem );
862+ ck_assert (tcp_np != nullptr );
863+
855864 tcp_oobdata_callback_called = 0 ;
856865 tcp_data_callback_called = 0 ;
857866
@@ -864,12 +873,12 @@ static void test_tcp_connection2(void)
864873 TCP_Proxy_Info proxy_info ;
865874 proxy_info .proxy_type = TCP_PROXY_NONE ;
866875 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 );
868877 ck_assert_msg (tc_1 != nullptr , "Failed to create TCP connections" );
869878 ck_assert_msg (pk_equal (tcp_connections_public_key (tc_1 ), self_public_key ), "Wrong public key" );
870879
871880 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 );
873882 ck_assert_msg (tc_2 != nullptr , "Failed to create TCP connections" );
874883 ck_assert_msg (pk_equal (tcp_connections_public_key (tc_2 ), self_public_key ), "Wrong public key" );
875884
@@ -921,6 +930,8 @@ static void test_tcp_connection2(void)
921930 ck_assert_msg (tcp_data_callback_called , "could not recv packet." );
922931 ck_assert_msg (kill_tcp_connection_to (tc_1 , 0 ) == 0 , "could not kill connection to\n" );
923932
933+ netprof_kill (mem , tcp_np );
934+
924935 kill_tcp_server (tcp_s );
925936 kill_tcp_connections (tc_1 );
926937 kill_tcp_connections (tc_2 );
0 commit comments