Skip to content

Commit

Permalink
refactor: Add mem module to allow tests to override allocators.
Browse files Browse the repository at this point in the history
This will allow us to do more interesting things with memory allocation
within toxcore, and allow fuzzers to explore various allocation failure
paths.
  • Loading branch information
iphydf committed Aug 24, 2023
1 parent 8ed47f3 commit 5e7a651
Show file tree
Hide file tree
Showing 80 changed files with 1,138 additions and 607 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ set(toxcore_SOURCES
toxcore/logger.h
toxcore/Messenger.c
toxcore/Messenger.h
toxcore/mem.c
toxcore/mem.h
toxcore/mono_time.c
toxcore/mono_time.h
toxcore/net_crypto.c
Expand Down Expand Up @@ -434,6 +436,7 @@ unit_test(toxcore bin_pack)
unit_test(toxcore crypto_core)
unit_test(toxcore group_announce)
unit_test(toxcore group_moderation)
unit_test(toxcore mem)
unit_test(toxcore mono_time)
unit_test(toxcore ping_array)
unit_test(toxcore tox)
Expand Down
99 changes: 62 additions & 37 deletions auto_tests/TCP_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,22 @@ static uint16_t ports[NUM_PORTS] = {13215, 33445, 25643};

static void test_basic(void)
{
Mono_Time *mono_time = mono_time_new(nullptr, nullptr);
const Random *rng = system_random();
ck_assert(rng != nullptr);
const Network *ns = system_network();
ck_assert(ns != nullptr);
const Memory *mem = system_memory();
ck_assert(mem != nullptr);

Check warning on line 53 in auto_tests/TCP_test.c

View check run for this annotation

Codecov / codecov/patch

auto_tests/TCP_test.c#L50-L53

Added lines #L50 - L53 were not covered by tests

Mono_Time *mono_time = mono_time_new(mem, nullptr, nullptr);

Check warning on line 55 in auto_tests/TCP_test.c

View check run for this annotation

Codecov / codecov/patch

auto_tests/TCP_test.c#L55

Added line #L55 was not covered by tests
Logger *logger = logger_new();
logger_callback_log(logger, print_debug_logger, nullptr, nullptr);

// Attempt to create a new TCP_Server instance.
uint8_t self_public_key[CRYPTO_PUBLIC_KEY_SIZE];
uint8_t self_secret_key[CRYPTO_SECRET_KEY_SIZE];
crypto_new_keypair(rng, self_public_key, self_secret_key);
const Network *ns = system_network();
TCP_Server *tcp_s = new_TCP_server(logger, rng, ns, USE_IPV6, NUM_PORTS, ports, self_secret_key, nullptr, nullptr);
TCP_Server *tcp_s = new_TCP_server(logger, mem, rng, ns, USE_IPV6, NUM_PORTS, ports, self_secret_key, nullptr, nullptr);

Check warning on line 63 in auto_tests/TCP_test.c

View check run for this annotation

Codecov / codecov/patch

auto_tests/TCP_test.c#L63

Added line #L63 was not covered by tests
ck_assert_msg(tcp_s != nullptr, "Failed to create a TCP relay server.");
ck_assert_msg(tcp_server_listen_count(tcp_s) == NUM_PORTS,
"Failed to bind a TCP relay server to all %d attempted ports.", NUM_PORTS);
Expand All @@ -70,7 +74,7 @@ static void test_basic(void)
for (uint8_t i = 0; i < NUM_PORTS; i++) {
sock = net_socket(ns, net_family_ipv6(), TOX_SOCK_STREAM, TOX_PROTO_TCP);
localhost.port = net_htons(ports[i]);
bool ret = net_connect(logger, sock, &localhost);
bool ret = net_connect(mem, logger, sock, &localhost);

Check warning on line 77 in auto_tests/TCP_test.c

View check run for this annotation

Codecov / codecov/patch

auto_tests/TCP_test.c#L77

Added line #L77 was not covered by tests
ck_assert_msg(ret, "Failed to connect to created TCP relay server on port %d (%d).", ports[i], errno);

// Leave open one connection for the next test.
Expand Down Expand Up @@ -184,30 +188,32 @@ static void test_basic(void)
kill_TCP_server(tcp_s);

logger_kill(logger);
mono_time_free(mono_time);
mono_time_free(mem, mono_time);

Check warning on line 191 in auto_tests/TCP_test.c

View check run for this annotation

Codecov / codecov/patch

auto_tests/TCP_test.c#L191

Added line #L191 was not covered by tests
}

struct sec_TCP_con {
Socket sock;
const Network *ns;
const Memory *mem;
uint8_t public_key[CRYPTO_PUBLIC_KEY_SIZE];
uint8_t recv_nonce[CRYPTO_NONCE_SIZE];
uint8_t sent_nonce[CRYPTO_NONCE_SIZE];
uint8_t shared_key[CRYPTO_SHARED_KEY_SIZE];
};

static struct sec_TCP_con *new_TCP_con(const Logger *logger, const Random *rng, const Network *ns, TCP_Server *tcp_s, Mono_Time *mono_time)
static struct sec_TCP_con *new_TCP_con(const Logger *logger, const Memory *mem, const Random *rng, const Network *ns, TCP_Server *tcp_s, Mono_Time *mono_time)

Check warning on line 204 in auto_tests/TCP_test.c

View check run for this annotation

Codecov / codecov/patch

auto_tests/TCP_test.c#L204

Added line #L204 was not covered by tests
{
struct sec_TCP_con *sec_c = (struct sec_TCP_con *)malloc(sizeof(struct sec_TCP_con));
ck_assert(sec_c != nullptr);
sec_c->ns = ns;
sec_c->mem = mem;

Check warning on line 209 in auto_tests/TCP_test.c

View check run for this annotation

Codecov / codecov/patch

auto_tests/TCP_test.c#L209

Added line #L209 was not covered by tests
Socket sock = net_socket(ns, net_family_ipv6(), TOX_SOCK_STREAM, TOX_PROTO_TCP);

IP_Port localhost;
localhost.ip = get_loopback();
localhost.port = net_htons(ports[random_u32(rng) % NUM_PORTS]);

bool ok = net_connect(logger, sock, &localhost);
bool ok = net_connect(mem, logger, sock, &localhost);

Check warning on line 216 in auto_tests/TCP_test.c

View check run for this annotation

Codecov / codecov/patch

auto_tests/TCP_test.c#L216

Added line #L216 was not covered by tests
ck_assert_msg(ok, "Failed to connect to the test TCP relay server.");

uint8_t f_secret_key[CRYPTO_SECRET_KEY_SIZE];
Expand Down Expand Up @@ -297,22 +303,26 @@ static int read_packet_sec_TCP(const Logger *logger, struct sec_TCP_con *con, ui

static void test_some(void)
{
Mono_Time *mono_time = mono_time_new(nullptr, nullptr);
const Random *rng = system_random();
ck_assert(rng != nullptr);
Logger *logger = logger_new();
const Network *ns = system_network();
ck_assert(ns != nullptr);
const Memory *mem = system_memory();
ck_assert(mem != nullptr);

Check warning on line 311 in auto_tests/TCP_test.c

View check run for this annotation

Codecov / codecov/patch

auto_tests/TCP_test.c#L309-L311

Added lines #L309 - L311 were not covered by tests

Mono_Time *mono_time = mono_time_new(mem, nullptr, nullptr);
Logger *logger = logger_new();

Check warning on line 314 in auto_tests/TCP_test.c

View check run for this annotation

Codecov / codecov/patch

auto_tests/TCP_test.c#L313-L314

Added lines #L313 - L314 were not covered by tests

uint8_t self_public_key[CRYPTO_PUBLIC_KEY_SIZE];
uint8_t self_secret_key[CRYPTO_SECRET_KEY_SIZE];
crypto_new_keypair(rng, self_public_key, self_secret_key);
TCP_Server *tcp_s = new_TCP_server(logger, rng, ns, USE_IPV6, NUM_PORTS, ports, self_secret_key, nullptr, nullptr);
TCP_Server *tcp_s = new_TCP_server(logger, mem, rng, ns, USE_IPV6, NUM_PORTS, ports, self_secret_key, nullptr, nullptr);

Check warning on line 319 in auto_tests/TCP_test.c

View check run for this annotation

Codecov / codecov/patch

auto_tests/TCP_test.c#L319

Added line #L319 was not covered by tests
ck_assert_msg(tcp_s != nullptr, "Failed to create TCP relay server");
ck_assert_msg(tcp_server_listen_count(tcp_s) == NUM_PORTS, "Failed to bind to all ports.");

struct sec_TCP_con *con1 = new_TCP_con(logger, rng, ns, tcp_s, mono_time);
struct sec_TCP_con *con2 = new_TCP_con(logger, rng, ns, tcp_s, mono_time);
struct sec_TCP_con *con3 = new_TCP_con(logger, rng, ns, tcp_s, mono_time);
struct sec_TCP_con *con1 = new_TCP_con(logger, mem, rng, ns, tcp_s, mono_time);
struct sec_TCP_con *con2 = new_TCP_con(logger, mem, rng, ns, tcp_s, mono_time);
struct sec_TCP_con *con3 = new_TCP_con(logger, mem, rng, ns, tcp_s, mono_time);

Check warning on line 325 in auto_tests/TCP_test.c

View check run for this annotation

Codecov / codecov/patch

auto_tests/TCP_test.c#L323-L325

Added lines #L323 - L325 were not covered by tests

uint8_t requ_p[1 + CRYPTO_PUBLIC_KEY_SIZE];
requ_p[0] = TCP_PACKET_ROUTING_REQUEST;
Expand Down Expand Up @@ -402,7 +412,7 @@ static void test_some(void)
kill_TCP_con(con3);

logger_kill(logger);
mono_time_free(mono_time);
mono_time_free(mem, mono_time);

Check warning on line 415 in auto_tests/TCP_test.c

View check run for this annotation

Codecov / codecov/patch

auto_tests/TCP_test.c#L415

Added line #L415 was not covered by tests
}

static int response_callback_good;
Expand Down Expand Up @@ -488,16 +498,20 @@ static int oob_data_callback(void *object, const uint8_t *public_key, const uint

static void test_client(void)
{
Mono_Time *mono_time = mono_time_new(nullptr, nullptr);
const Random *rng = system_random();
ck_assert(rng != nullptr);
const Network *ns = system_network();
ck_assert(ns != nullptr);
const Memory *mem = system_memory();
ck_assert(mem != nullptr);

Check warning on line 506 in auto_tests/TCP_test.c

View check run for this annotation

Codecov / codecov/patch

auto_tests/TCP_test.c#L503-L506

Added lines #L503 - L506 were not covered by tests

Logger *logger = logger_new();
Mono_Time *mono_time = mono_time_new(mem, nullptr, nullptr);

Check warning on line 509 in auto_tests/TCP_test.c

View check run for this annotation

Codecov / codecov/patch

auto_tests/TCP_test.c#L509

Added line #L509 was not covered by tests

uint8_t self_public_key[CRYPTO_PUBLIC_KEY_SIZE];
uint8_t self_secret_key[CRYPTO_SECRET_KEY_SIZE];
crypto_new_keypair(rng, self_public_key, self_secret_key);
const Network *ns = system_network();
TCP_Server *tcp_s = new_TCP_server(logger, rng, ns, USE_IPV6, NUM_PORTS, ports, self_secret_key, nullptr, nullptr);
TCP_Server *tcp_s = new_TCP_server(logger, mem, rng, ns, USE_IPV6, NUM_PORTS, ports, self_secret_key, nullptr, nullptr);

Check warning on line 514 in auto_tests/TCP_test.c

View check run for this annotation

Codecov / codecov/patch

auto_tests/TCP_test.c#L514

Added line #L514 was not covered by tests
ck_assert_msg(tcp_s != nullptr, "Failed to create a TCP relay server.");
ck_assert_msg(tcp_server_listen_count(tcp_s) == NUM_PORTS, "Failed to bind the relay server to all ports.");

Expand All @@ -509,8 +523,7 @@ static void test_client(void)
ip_port_tcp_s.port = net_htons(ports[random_u32(rng) % NUM_PORTS]);
ip_port_tcp_s.ip = get_loopback();

TCP_Client_Connection *conn = new_TCP_connection(logger, mono_time, rng, ns, &ip_port_tcp_s, self_public_key, f_public_key,
f_secret_key, nullptr);
TCP_Client_Connection *conn = new_TCP_connection(logger, mem, mono_time, rng, ns, &ip_port_tcp_s, self_public_key, f_public_key, f_secret_key, nullptr);

Check warning on line 526 in auto_tests/TCP_test.c

View check run for this annotation

Codecov / codecov/patch

auto_tests/TCP_test.c#L526

Added line #L526 was not covered by tests
do_TCP_connection(logger, mono_time, conn, nullptr);
c_sleep(50);

Expand Down Expand Up @@ -544,7 +557,7 @@ static void test_client(void)
uint8_t f2_secret_key[CRYPTO_SECRET_KEY_SIZE];
crypto_new_keypair(rng, f2_public_key, f2_secret_key);
ip_port_tcp_s.port = net_htons(ports[random_u32(rng) % NUM_PORTS]);
TCP_Client_Connection *conn2 = new_TCP_connection(logger, mono_time, rng, ns, &ip_port_tcp_s, self_public_key, f2_public_key,
TCP_Client_Connection *conn2 = new_TCP_connection(logger, mem, mono_time, rng, ns, &ip_port_tcp_s, self_public_key, f2_public_key,

Check warning on line 560 in auto_tests/TCP_test.c

View check run for this annotation

Codecov / codecov/patch

auto_tests/TCP_test.c#L560

Added line #L560 was not covered by tests
f2_secret_key, nullptr);

// The client should call this function (defined earlier) during the routing process.
Expand Down Expand Up @@ -613,17 +626,21 @@ static void test_client(void)
kill_TCP_connection(conn2);

logger_kill(logger);
mono_time_free(mono_time);
mono_time_free(mem, mono_time);

Check warning on line 629 in auto_tests/TCP_test.c

View check run for this annotation

Codecov / codecov/patch

auto_tests/TCP_test.c#L629

Added line #L629 was not covered by tests
}

// Test how the client handles servers that don't respond.
static void test_client_invalid(void)
{
Mono_Time *mono_time = mono_time_new(nullptr, nullptr);
const Random *rng = system_random();
ck_assert(rng != nullptr);
Logger *logger = logger_new();
const Network *ns = system_network();
ck_assert(ns != nullptr);
const Memory *mem = system_memory();
ck_assert(mem != nullptr);

Check warning on line 640 in auto_tests/TCP_test.c

View check run for this annotation

Codecov / codecov/patch

auto_tests/TCP_test.c#L638-L640

Added lines #L638 - L640 were not covered by tests

Mono_Time *mono_time = mono_time_new(mem, nullptr, nullptr);
Logger *logger = logger_new();

Check warning on line 643 in auto_tests/TCP_test.c

View check run for this annotation

Codecov / codecov/patch

auto_tests/TCP_test.c#L642-L643

Added lines #L642 - L643 were not covered by tests

uint8_t self_public_key[CRYPTO_PUBLIC_KEY_SIZE];
uint8_t self_secret_key[CRYPTO_SECRET_KEY_SIZE];
Expand All @@ -636,7 +653,7 @@ static void test_client_invalid(void)

ip_port_tcp_s.port = net_htons(ports[random_u32(rng) % NUM_PORTS]);
ip_port_tcp_s.ip = get_loopback();
TCP_Client_Connection *conn = new_TCP_connection(logger, mono_time, rng, ns, &ip_port_tcp_s,
TCP_Client_Connection *conn = new_TCP_connection(logger, mem, mono_time, rng, ns, &ip_port_tcp_s,

Check warning on line 656 in auto_tests/TCP_test.c

View check run for this annotation

Codecov / codecov/patch

auto_tests/TCP_test.c#L656

Added line #L656 was not covered by tests
self_public_key, f_public_key, f_secret_key, nullptr);

// Run the client's main loop but not the server.
Expand All @@ -663,7 +680,7 @@ static void test_client_invalid(void)
kill_TCP_connection(conn);

logger_kill(logger);
mono_time_free(mono_time);
mono_time_free(mem, mono_time);

Check warning on line 683 in auto_tests/TCP_test.c

View check run for this annotation

Codecov / codecov/patch

auto_tests/TCP_test.c#L683

Added line #L683 was not covered by tests
}

#include "../toxcore/TCP_connection.h"
Expand Down Expand Up @@ -694,27 +711,31 @@ static int tcp_data_callback(void *object, int id, const uint8_t *data, uint16_t

static void test_tcp_connection(void)
{
Mono_Time *mono_time = mono_time_new(nullptr, nullptr);
Logger *logger = logger_new();
const Random *rng = system_random();
ck_assert(rng != nullptr);
const Network *ns = system_network();
ck_assert(ns != nullptr);
const Memory *mem = system_memory();
ck_assert(mem != nullptr);

Check warning on line 719 in auto_tests/TCP_test.c

View check run for this annotation

Codecov / codecov/patch

auto_tests/TCP_test.c#L717-L719

Added lines #L717 - L719 were not covered by tests

Mono_Time *mono_time = mono_time_new(mem, nullptr, nullptr);
Logger *logger = logger_new();

Check warning on line 722 in auto_tests/TCP_test.c

View check run for this annotation

Codecov / codecov/patch

auto_tests/TCP_test.c#L721-L722

Added lines #L721 - L722 were not covered by tests

tcp_data_callback_called = 0;
uint8_t self_public_key[CRYPTO_PUBLIC_KEY_SIZE];
uint8_t self_secret_key[CRYPTO_SECRET_KEY_SIZE];
crypto_new_keypair(rng, self_public_key, self_secret_key);
TCP_Server *tcp_s = new_TCP_server(logger, rng, ns, USE_IPV6, NUM_PORTS, ports, self_secret_key, nullptr, nullptr);
TCP_Server *tcp_s = new_TCP_server(logger, mem, rng, ns, USE_IPV6, NUM_PORTS, ports, self_secret_key, nullptr, nullptr);

Check warning on line 728 in auto_tests/TCP_test.c

View check run for this annotation

Codecov / codecov/patch

auto_tests/TCP_test.c#L728

Added line #L728 was not covered by tests
ck_assert_msg(pk_equal(tcp_server_public_key(tcp_s), self_public_key), "Wrong public key");

TCP_Proxy_Info proxy_info;
proxy_info.proxy_type = TCP_PROXY_NONE;
crypto_new_keypair(rng, self_public_key, self_secret_key);
TCP_Connections *tc_1 = new_tcp_connections(logger, rng, ns, mono_time, self_secret_key, &proxy_info);
TCP_Connections *tc_1 = new_tcp_connections(logger, mem, rng, ns, mono_time, self_secret_key, &proxy_info);

Check warning on line 734 in auto_tests/TCP_test.c

View check run for this annotation

Codecov / codecov/patch

auto_tests/TCP_test.c#L734

Added line #L734 was not covered by tests
ck_assert_msg(pk_equal(tcp_connections_public_key(tc_1), self_public_key), "Wrong public key");

crypto_new_keypair(rng, self_public_key, self_secret_key);
TCP_Connections *tc_2 = new_tcp_connections(logger, rng, ns, mono_time, self_secret_key, &proxy_info);
TCP_Connections *tc_2 = new_tcp_connections(logger, mem, rng, ns, mono_time, self_secret_key, &proxy_info);

Check warning on line 738 in auto_tests/TCP_test.c

View check run for this annotation

Codecov / codecov/patch

auto_tests/TCP_test.c#L738

Added line #L738 was not covered by tests
ck_assert_msg(pk_equal(tcp_connections_public_key(tc_2), self_public_key), "Wrong public key");

IP_Port ip_port_tcp_s;
Expand Down Expand Up @@ -777,7 +798,7 @@ static void test_tcp_connection(void)
kill_tcp_connections(tc_2);

logger_kill(logger);
mono_time_free(mono_time);
mono_time_free(mem, mono_time);

Check warning on line 801 in auto_tests/TCP_test.c

View check run for this annotation

Codecov / codecov/patch

auto_tests/TCP_test.c#L801

Added line #L801 was not covered by tests
}

static bool tcp_oobdata_callback_called;
Expand All @@ -803,29 +824,33 @@ static int tcp_oobdata_callback(void *object, const uint8_t *public_key, unsigne

static void test_tcp_connection2(void)
{
Mono_Time *mono_time = mono_time_new(nullptr, nullptr);
Logger *logger = logger_new();
const Random *rng = system_random();
ck_assert(rng != nullptr);
const Network *ns = system_network();
ck_assert(ns != nullptr);
const Memory *mem = system_memory();
ck_assert(mem != nullptr);

Check warning on line 832 in auto_tests/TCP_test.c

View check run for this annotation

Codecov / codecov/patch

auto_tests/TCP_test.c#L830-L832

Added lines #L830 - L832 were not covered by tests

Mono_Time *mono_time = mono_time_new(mem, nullptr, nullptr);
Logger *logger = logger_new();

Check warning on line 835 in auto_tests/TCP_test.c

View check run for this annotation

Codecov / codecov/patch

auto_tests/TCP_test.c#L834-L835

Added lines #L834 - L835 were not covered by tests

tcp_oobdata_callback_called = 0;
tcp_data_callback_called = 0;

uint8_t self_public_key[CRYPTO_PUBLIC_KEY_SIZE];
uint8_t self_secret_key[CRYPTO_SECRET_KEY_SIZE];
crypto_new_keypair(rng, self_public_key, self_secret_key);
TCP_Server *tcp_s = new_TCP_server(logger, rng, ns, USE_IPV6, NUM_PORTS, ports, self_secret_key, nullptr, nullptr);
TCP_Server *tcp_s = new_TCP_server(logger, mem, rng, ns, USE_IPV6, NUM_PORTS, ports, self_secret_key, nullptr, nullptr);

Check warning on line 843 in auto_tests/TCP_test.c

View check run for this annotation

Codecov / codecov/patch

auto_tests/TCP_test.c#L843

Added line #L843 was not covered by tests
ck_assert_msg(pk_equal(tcp_server_public_key(tcp_s), self_public_key), "Wrong public key");

TCP_Proxy_Info proxy_info;
proxy_info.proxy_type = TCP_PROXY_NONE;
crypto_new_keypair(rng, self_public_key, self_secret_key);
TCP_Connections *tc_1 = new_tcp_connections(logger, rng, ns, mono_time, self_secret_key, &proxy_info);
TCP_Connections *tc_1 = new_tcp_connections(logger, mem, rng, ns, mono_time, self_secret_key, &proxy_info);

Check warning on line 849 in auto_tests/TCP_test.c

View check run for this annotation

Codecov / codecov/patch

auto_tests/TCP_test.c#L849

Added line #L849 was not covered by tests
ck_assert_msg(pk_equal(tcp_connections_public_key(tc_1), self_public_key), "Wrong public key");

crypto_new_keypair(rng, self_public_key, self_secret_key);
TCP_Connections *tc_2 = new_tcp_connections(logger, rng, ns, mono_time, self_secret_key, &proxy_info);
TCP_Connections *tc_2 = new_tcp_connections(logger, mem, rng, ns, mono_time, self_secret_key, &proxy_info);

Check warning on line 853 in auto_tests/TCP_test.c

View check run for this annotation

Codecov / codecov/patch

auto_tests/TCP_test.c#L853

Added line #L853 was not covered by tests
ck_assert_msg(pk_equal(tcp_connections_public_key(tc_2), self_public_key), "Wrong public key");

IP_Port ip_port_tcp_s;
Expand Down Expand Up @@ -881,7 +906,7 @@ static void test_tcp_connection2(void)
kill_tcp_connections(tc_2);

logger_kill(logger);
mono_time_free(mono_time);
mono_time_free(mem, mono_time);

Check warning on line 909 in auto_tests/TCP_test.c

View check run for this annotation

Codecov / codecov/patch

auto_tests/TCP_test.c#L909

Added line #L909 was not covered by tests
}

static void TCP_suite(void)
Expand Down
13 changes: 8 additions & 5 deletions auto_tests/announce_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,17 @@ static void test_store_data(void)
ck_assert(rng != nullptr);
const Network *ns = system_network();
ck_assert(ns != nullptr);
const Memory *mem = system_memory();
ck_assert(mem != nullptr);

Check warning on line 58 in auto_tests/announce_test.c

View check run for this annotation

Codecov / codecov/patch

auto_tests/announce_test.c#L57-L58

Added lines #L57 - L58 were not covered by tests

Logger *log = logger_new();
ck_assert(log != nullptr);
logger_callback_log(log, print_debug_logger, nullptr, nullptr);
Mono_Time *mono_time = mono_time_new(nullptr, nullptr);
Networking_Core *net = new_networking_no_udp(log, ns);
DHT *dht = new_dht(log, rng, ns, mono_time, net, true, true);
Mono_Time *mono_time = mono_time_new(mem, nullptr, nullptr);
Networking_Core *net = new_networking_no_udp(log, mem, ns);
DHT *dht = new_dht(log, mem, rng, ns, mono_time, net, true, true);

Check warning on line 65 in auto_tests/announce_test.c

View check run for this annotation

Codecov / codecov/patch

auto_tests/announce_test.c#L63-L65

Added lines #L63 - L65 were not covered by tests
Forwarding *forwarding = new_forwarding(log, rng, mono_time, dht);
Announcements *announce = new_announcements(log, rng, mono_time, forwarding);
Announcements *announce = new_announcements(log, mem, rng, mono_time, forwarding);

Check warning on line 67 in auto_tests/announce_test.c

View check run for this annotation

Codecov / codecov/patch

auto_tests/announce_test.c#L67

Added line #L67 was not covered by tests
ck_assert(announce != nullptr);

/* Just to prevent CI from complaining that set_synch_offset is unused: */
Expand Down Expand Up @@ -103,7 +106,7 @@ static void test_store_data(void)
kill_forwarding(forwarding);
kill_dht(dht);
kill_networking(net);
mono_time_free(mono_time);
mono_time_free(mem, mono_time);

Check warning on line 109 in auto_tests/announce_test.c

View check run for this annotation

Codecov / codecov/patch

auto_tests/announce_test.c#L109

Added line #L109 was not covered by tests
logger_kill(log);
}

Expand Down
Loading

0 comments on commit 5e7a651

Please sign in to comment.