@@ -45,11 +45,11 @@ static uint16_t ports[NUM_PORTS] = {13215, 33445, 25643};
4545
4646static void test_basic (void )
4747{
48- const Random * rng = system_random ();
48+ const Random * rng = os_random ();
4949 ck_assert (rng != nullptr );
50- const Network * ns = system_network ();
50+ const Network * ns = os_network ();
5151 ck_assert (ns != nullptr );
52- const Memory * mem = system_memory ();
52+ const Memory * mem = os_memory ();
5353 ck_assert (mem != nullptr );
5454
5555 Mono_Time * mono_time = mono_time_new (mem , nullptr , nullptr );
@@ -266,13 +266,14 @@ static void kill_tcp_con(struct sec_TCP_con *con)
266266static int write_packet_tcp_test_connection (const Logger * logger , struct sec_TCP_con * con , const uint8_t * data ,
267267 uint16_t length )
268268{
269- VLA (uint8_t , packet , sizeof (uint16_t ) + length + CRYPTO_MAC_SIZE );
269+ const uint16_t packet_size = sizeof (uint16_t ) + length + CRYPTO_MAC_SIZE ;
270+ VLA (uint8_t , packet , packet_size );
270271
271272 uint16_t c_length = net_htons (length + CRYPTO_MAC_SIZE );
272273 memcpy (packet , & c_length , sizeof (uint16_t ));
273274 int len = encrypt_data_symmetric (con -> shared_key , con -> sent_nonce , data , length , packet + sizeof (uint16_t ));
274275
275- if ((unsigned int )len != (SIZEOF_VLA ( packet ) - sizeof (uint16_t ))) {
276+ if ((unsigned int )len != (packet_size - sizeof (uint16_t ))) {
276277 return -1 ;
277278 }
278279
@@ -282,7 +283,7 @@ static int write_packet_tcp_test_connection(const Logger *logger, struct sec_TCP
282283 localhost .ip = get_loopback ();
283284 localhost .port = 0 ;
284285
285- ck_assert_msg (net_send (con -> ns , logger , con -> sock , packet , SIZEOF_VLA ( packet ) , & localhost ) == SIZEOF_VLA ( packet ) ,
286+ ck_assert_msg (net_send (con -> ns , logger , con -> sock , packet , packet_size , & localhost ) == packet_size ,
286287 "Failed to send a packet." );
287288 return 0 ;
288289}
@@ -303,11 +304,11 @@ static int read_packet_sec_tcp(const Logger *logger, struct sec_TCP_con *con, ui
303304
304305static void test_some (void )
305306{
306- const Random * rng = system_random ();
307+ const Random * rng = os_random ();
307308 ck_assert (rng != nullptr );
308- const Network * ns = system_network ();
309+ const Network * ns = os_network ();
309310 ck_assert (ns != nullptr );
310- const Memory * mem = system_memory ();
311+ const Memory * mem = os_memory ();
311312 ck_assert (mem != nullptr );
312313
313314 Mono_Time * mono_time = mono_time_new (mem , nullptr , nullptr );
@@ -498,11 +499,11 @@ static int oob_data_callback(void *object, const uint8_t *public_key, const uint
498499
499500static void test_client (void )
500501{
501- const Random * rng = system_random ();
502+ const Random * rng = os_random ();
502503 ck_assert (rng != nullptr );
503- const Network * ns = system_network ();
504+ const Network * ns = os_network ();
504505 ck_assert (ns != nullptr );
505- const Memory * mem = system_memory ();
506+ const Memory * mem = os_memory ();
506507 ck_assert (mem != nullptr );
507508
508509 Logger * logger = logger_new ();
@@ -581,7 +582,7 @@ static void test_client(void)
581582 do_tcp_connection (logger , mono_time , conn2 , nullptr );
582583 c_sleep (50 );
583584
584- uint8_t data [5 ] = {1 , 2 , 3 , 4 , 5 };
585+ const uint8_t data [5 ] = {1 , 2 , 3 , 4 , 5 };
585586 memcpy (oob_pubkey , f2_public_key , CRYPTO_PUBLIC_KEY_SIZE );
586587 send_oob_packet (logger , conn2 , f_public_key , data , 5 );
587588 send_routing_request (logger , conn , f2_public_key );
@@ -632,11 +633,11 @@ static void test_client(void)
632633// Test how the client handles servers that don't respond.
633634static void test_client_invalid (void )
634635{
635- const Random * rng = system_random ();
636+ const Random * rng = os_random ();
636637 ck_assert (rng != nullptr );
637- const Network * ns = system_network ();
638+ const Network * ns = os_network ();
638639 ck_assert (ns != nullptr );
639- const Memory * mem = system_memory ();
640+ const Memory * mem = os_memory ();
640641 ck_assert (mem != nullptr );
641642
642643 Mono_Time * mono_time = mono_time_new (mem , nullptr , nullptr );
@@ -711,11 +712,11 @@ static int tcp_data_callback(void *object, int id, const uint8_t *data, uint16_t
711712
712713static void test_tcp_connection (void )
713714{
714- const Random * rng = system_random ();
715+ const Random * rng = os_random ();
715716 ck_assert (rng != nullptr );
716- const Network * ns = system_network ();
717+ const Network * ns = os_network ();
717718 ck_assert (ns != nullptr );
718- const Memory * mem = system_memory ();
719+ const Memory * mem = os_memory ();
719720 ck_assert (mem != nullptr );
720721
721722 Mono_Time * mono_time = mono_time_new (mem , nullptr , nullptr );
@@ -824,11 +825,11 @@ static int tcp_oobdata_callback(void *object, const uint8_t *public_key, unsigne
824825
825826static void test_tcp_connection2 (void )
826827{
827- const Random * rng = system_random ();
828+ const Random * rng = os_random ();
828829 ck_assert (rng != nullptr );
829- const Network * ns = system_network ();
830+ const Network * ns = os_network ();
830831 ck_assert (ns != nullptr );
831- const Memory * mem = system_memory ();
832+ const Memory * mem = os_memory ();
832833 ck_assert (mem != nullptr );
833834
834835 Mono_Time * mono_time = mono_time_new (mem , nullptr , nullptr );
0 commit comments