forked from Green-Sky/tomato
Squashed 'external/toxcore/c-toxcore/' changes from 640e6cace..e58eb27a8
e58eb27a8 fix(toxav): remove extra copy of video frame on encode Tested and works, but there might be alignment issues and other stuff. 206ea3530 refactor: Explicitly pass dependencies to constructors. 7cefa93cf fix(toxencryptsave): Wipe salt and passkey after usage. 7c3be2342 refactor: Add file/line to tox-bootstrapd logging. f84e8cdce refactor: Move loglogdata out of network.c. 390f7db06 refactor: Move random and memory OS-specifics to `os_*` files. REVERT: 640e6cace fix(toxav): remove extra copy of video frame on encode Tested and works, but there might be alignment issues and other stuff. git-subtree-dir: external/toxcore/c-toxcore git-subtree-split: e58eb27a84f9fa0cd996868e079f39e90a5c04b6
This commit is contained in:
@@ -10,6 +10,8 @@
|
||||
#include "../toxcore/mono_time.h"
|
||||
#include "../toxcore/net_profile.h"
|
||||
#include "../toxcore/network.h"
|
||||
#include "../toxcore/os_memory.h"
|
||||
#include "../toxcore/os_random.h"
|
||||
#include "auto_test_support.h"
|
||||
|
||||
#define NUM_PORTS 3
|
||||
|
||||
@@ -2,12 +2,10 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "../toxcore/announce.h"
|
||||
#include "../toxcore/tox.h"
|
||||
#include "../testing/misc_tools.h"
|
||||
#include "../toxcore/mono_time.h"
|
||||
#include "../toxcore/forwarding.h"
|
||||
#include "../toxcore/net_crypto.h"
|
||||
#include "../toxcore/util.h"
|
||||
#include "../toxcore/os_memory.h"
|
||||
#include "../toxcore/os_random.h"
|
||||
#include "auto_test_support.h"
|
||||
#include "check_compat.h"
|
||||
|
||||
@@ -66,9 +64,9 @@ static void test_store_data(void)
|
||||
ck_assert(net != nullptr);
|
||||
DHT *dht = new_dht(log, mem, rng, ns, mono_time, net, true, true);
|
||||
ck_assert(dht != nullptr);
|
||||
Forwarding *forwarding = new_forwarding(log, mem, rng, mono_time, dht);
|
||||
Forwarding *forwarding = new_forwarding(log, mem, rng, mono_time, dht, net);
|
||||
ck_assert(forwarding != nullptr);
|
||||
Announcements *announce = new_announcements(log, mem, rng, mono_time, forwarding);
|
||||
Announcements *announce = new_announcements(log, mem, rng, mono_time, forwarding, dht, net);
|
||||
ck_assert(announce != nullptr);
|
||||
|
||||
/* Just to prevent CI from complaining that set_synch_offset is unused: */
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../toxav/toxav.h"
|
||||
#include "../toxcore/os_random.h"
|
||||
#include "check_compat.h"
|
||||
|
||||
#define NUM_AV_GROUP_TOX 16
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <time.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../toxcore/os_random.h"
|
||||
#include "../toxcore/util.h"
|
||||
|
||||
#include "check_compat.h"
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../testing/misc_tools.h"
|
||||
#include "../toxcore/crypto_core.h"
|
||||
#include "../toxcore/net_crypto.h"
|
||||
#include "../toxcore/os_memory.h"
|
||||
#include "../toxcore/os_random.h"
|
||||
#include "check_compat.h"
|
||||
|
||||
static void rand_bytes(const Random *rng, uint8_t *b, size_t blen)
|
||||
|
||||
@@ -13,6 +13,10 @@
|
||||
#include "check_compat.h"
|
||||
|
||||
#define NUM_TOXES 30
|
||||
// Maximum number of iterations to wait for all nodes to be crawled. 5 should
|
||||
// be enough. We pick 10 in case things are slow. This makes the test take
|
||||
// less time in case it completely fails, so we can retry it.
|
||||
#define MAX_ITERATIONS 10
|
||||
|
||||
typedef struct Dht_Node {
|
||||
uint8_t public_key[TOX_DHT_NODE_PUBLIC_KEY_SIZE];
|
||||
@@ -132,9 +136,15 @@ static void test_dht_nodes_request(AutoTox *autotoxes)
|
||||
tox_dht_get_num_closelist_announce_capable(autotoxes[i].tox));
|
||||
}
|
||||
|
||||
while (!all_nodes_crawled(autotoxes, NUM_TOXES, public_key_list)) {
|
||||
bool success = false;
|
||||
for (size_t i = 0; i < MAX_ITERATIONS; ++i) {
|
||||
if (all_nodes_crawled(autotoxes, NUM_TOXES, public_key_list)) {
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
iterate_all_wait(autotoxes, NUM_TOXES, ITERATION_INTERVAL);
|
||||
}
|
||||
ck_assert_msg(success, "Failed to crawl all nodes within %d iterations", MAX_ITERATIONS);
|
||||
|
||||
for (size_t i = 0; i < NUM_TOXES; ++i) {
|
||||
State *state = (State *)autotoxes[i].state;
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "../testing/misc_tools.h"
|
||||
#include "../toxcore/ccompat.h"
|
||||
#include "../toxcore/crypto_core.h"
|
||||
#include "../toxcore/os_random.h"
|
||||
#include "../toxcore/tox.h"
|
||||
#include "../toxencryptsave/toxencryptsave.h"
|
||||
#include "auto_test_support.h"
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
#include "../toxcore/mono_time.h"
|
||||
#include "../toxcore/forwarding.h"
|
||||
#include "../toxcore/net_crypto.h"
|
||||
#include "../toxcore/util.h"
|
||||
#include "../toxcore/os_memory.h"
|
||||
#include "../toxcore/os_random.h"
|
||||
#include "auto_test_support.h"
|
||||
#include "check_compat.h"
|
||||
|
||||
@@ -131,12 +132,12 @@ static Forwarding_Subtox *new_forwarding_subtox(const Memory *mem, bool no_udp,
|
||||
ck_assert(subtox->tcp_np != nullptr);
|
||||
|
||||
const TCP_Proxy_Info inf = {{{{0}}}};
|
||||
subtox->c = new_net_crypto(subtox->log, mem, rng, ns, subtox->mono_time, subtox->dht, &inf, subtox->tcp_np);
|
||||
subtox->c = new_net_crypto(subtox->log, mem, rng, ns, subtox->mono_time, subtox->net, subtox->dht, &inf, subtox->tcp_np);
|
||||
|
||||
subtox->forwarding = new_forwarding(subtox->log, mem, rng, subtox->mono_time, subtox->dht);
|
||||
subtox->forwarding = new_forwarding(subtox->log, mem, rng, subtox->mono_time, subtox->dht, subtox->net);
|
||||
ck_assert(subtox->forwarding != nullptr);
|
||||
|
||||
subtox->announce = new_announcements(subtox->log, mem, rng, subtox->mono_time, subtox->forwarding);
|
||||
subtox->announce = new_announcements(subtox->log, mem, rng, subtox->mono_time, subtox->forwarding, subtox->dht, subtox->net);
|
||||
ck_assert(subtox->announce != nullptr);
|
||||
|
||||
return subtox;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#include "auto_test_support.h"
|
||||
#include "check_compat.h"
|
||||
#include "../toxcore/os_random.h"
|
||||
#include "../toxcore/util.h"
|
||||
|
||||
typedef struct State {
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include "auto_test_support.h"
|
||||
|
||||
#include "../toxcore/os_random.h"
|
||||
#include "../toxcore/tox.h"
|
||||
#include "../toxcore/util.h"
|
||||
|
||||
|
||||
@@ -5,14 +5,13 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "auto_test_support.h"
|
||||
#include "check_compat.h"
|
||||
|
||||
#include "../toxcore/os_random.h"
|
||||
#include "../toxcore/tox.h"
|
||||
#include "../toxcore/group_chats.h"
|
||||
|
||||
#define NUM_GROUP_TOXES 3
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "../toxcore/network.h"
|
||||
#include "../toxcore/os_memory.h"
|
||||
#include "check_compat.h"
|
||||
|
||||
#ifndef USE_IPV6
|
||||
|
||||
@@ -3,10 +3,12 @@
|
||||
|
||||
#include "../testing/misc_tools.h"
|
||||
#include "../toxcore/mono_time.h"
|
||||
#include "../toxcore/network.h"
|
||||
#include "../toxcore/onion.h"
|
||||
#include "../toxcore/onion_announce.h"
|
||||
#include "../toxcore/onion_client.h"
|
||||
#include "../toxcore/util.h"
|
||||
#include "../toxcore/os_memory.h"
|
||||
#include "../toxcore/os_random.h"
|
||||
#include "auto_test_support.h"
|
||||
#include "check_compat.h"
|
||||
|
||||
@@ -237,8 +239,10 @@ static void test_basic(void)
|
||||
Mono_Time *mono_time2 = mono_time_new(mem, nullptr, nullptr);
|
||||
|
||||
IP ip = get_loopback();
|
||||
Onion *onion1 = new_onion(log1, mem, mono_time1, rng, new_dht(log1, mem, rng, ns, mono_time1, new_networking(log1, mem, ns, &ip, 36567), true, false));
|
||||
Onion *onion2 = new_onion(log2, mem, mono_time2, rng, new_dht(log2, mem, rng, ns, mono_time2, new_networking(log2, mem, ns, &ip, 36568), true, false));
|
||||
Networking_Core *net1 = new_networking(log1, mem, ns, &ip, 36567);
|
||||
Onion *onion1 = new_onion(log1, mem, mono_time1, rng, new_dht(log1, mem, rng, ns, mono_time1, net1, true, false), net1);
|
||||
Networking_Core *net2 = new_networking(log2, mem, ns, &ip, 36568);
|
||||
Onion *onion2 = new_onion(log2, mem, mono_time2, rng, new_dht(log2, mem, rng, ns, mono_time2, net2, true, false), net2);
|
||||
ck_assert_msg((onion1 != nullptr) && (onion2 != nullptr), "Onion failed initializing.");
|
||||
networking_registerhandler(onion2->net, NET_PACKET_ANNOUNCE_REQUEST, &handle_test_1, onion2);
|
||||
|
||||
@@ -281,8 +285,8 @@ static void test_basic(void)
|
||||
do_onion(mono_time2, onion2);
|
||||
} while (handled_test_2 == 0);
|
||||
|
||||
Onion_Announce *onion1_a = new_onion_announce(log1, mem, rng, mono_time1, onion1->dht);
|
||||
Onion_Announce *onion2_a = new_onion_announce(log2, mem, rng, mono_time2, onion2->dht);
|
||||
Onion_Announce *onion1_a = new_onion_announce(log1, mem, rng, mono_time1, onion1->dht, onion1->net);
|
||||
Onion_Announce *onion2_a = new_onion_announce(log2, mem, rng, mono_time2, onion2->dht, onion2->net);
|
||||
networking_registerhandler(onion1->net, NET_PACKET_ANNOUNCE_RESPONSE, &handle_test_3, onion1);
|
||||
networking_registerhandler(onion1->net, NET_PACKET_ANNOUNCE_RESPONSE_OLD, &handle_test_3_old, onion1);
|
||||
ck_assert_msg((onion1_a != nullptr) && (onion2_a != nullptr), "Onion_Announce failed initializing.");
|
||||
@@ -334,7 +338,8 @@ static void test_basic(void)
|
||||
|
||||
Mono_Time *mono_time3 = mono_time_new(mem, nullptr, nullptr);
|
||||
|
||||
Onion *onion3 = new_onion(log3, mem, mono_time3, rng, new_dht(log3, mem, rng, ns, mono_time3, new_networking(log3, mem, ns, &ip, 36569), true, false));
|
||||
Networking_Core *net3 = new_networking(log3, mem, ns, &ip, 36569);
|
||||
Onion *onion3 = new_onion(log3, mem, mono_time3, rng, new_dht(log3, mem, rng, ns, mono_time3, net3, true, false), net3);
|
||||
ck_assert_msg((onion3 != nullptr), "Onion failed initializing.");
|
||||
|
||||
random_nonce(rng, nonce);
|
||||
@@ -359,7 +364,7 @@ static void test_basic(void)
|
||||
{
|
||||
Onion *onion = onion3;
|
||||
|
||||
Networking_Core *net = dht_get_net(onion->dht);
|
||||
Networking_Core *net = onion->net;
|
||||
DHT *dht = onion->dht;
|
||||
kill_onion(onion);
|
||||
kill_dht(dht);
|
||||
@@ -371,7 +376,7 @@ static void test_basic(void)
|
||||
{
|
||||
Onion *onion = onion2;
|
||||
|
||||
Networking_Core *net = dht_get_net(onion->dht);
|
||||
Networking_Core *net = onion->net;
|
||||
DHT *dht = onion->dht;
|
||||
kill_onion(onion);
|
||||
kill_dht(dht);
|
||||
@@ -383,7 +388,7 @@ static void test_basic(void)
|
||||
{
|
||||
Onion *onion = onion1;
|
||||
|
||||
Networking_Core *net = dht_get_net(onion->dht);
|
||||
Networking_Core *net = onion->net;
|
||||
DHT *dht = onion->dht;
|
||||
kill_onion(onion);
|
||||
kill_dht(dht);
|
||||
@@ -396,6 +401,7 @@ static void test_basic(void)
|
||||
typedef struct {
|
||||
Logger *log;
|
||||
Mono_Time *mono_time;
|
||||
Net_Crypto *nc;
|
||||
Net_Profile *tcp_np;
|
||||
Onion *onion;
|
||||
Onion_Announce *onion_a;
|
||||
@@ -449,7 +455,7 @@ static Onions *new_onions(const Memory *mem, const Random *rng, uint16_t port, u
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
on->onion = new_onion(on->log, mem, on->mono_time, rng, dht);
|
||||
on->onion = new_onion(on->log, mem, on->mono_time, rng, dht, net);
|
||||
|
||||
if (!on->onion) {
|
||||
kill_dht(dht);
|
||||
@@ -460,7 +466,7 @@ static Onions *new_onions(const Memory *mem, const Random *rng, uint16_t port, u
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
on->onion_a = new_onion_announce(on->log, mem, rng, on->mono_time, dht);
|
||||
on->onion_a = new_onion_announce(on->log, mem, rng, on->mono_time, dht, net);
|
||||
|
||||
if (!on->onion_a) {
|
||||
kill_onion(on->onion);
|
||||
@@ -486,7 +492,8 @@ static Onions *new_onions(const Memory *mem, const Random *rng, uint16_t port, u
|
||||
}
|
||||
|
||||
TCP_Proxy_Info inf = {{{{0}}}};
|
||||
on->onion_c = new_onion_client(on->log, mem, rng, on->mono_time, new_net_crypto(on->log, mem, rng, ns, on->mono_time, dht, &inf, on->tcp_np));
|
||||
on->nc = new_net_crypto(on->log, mem, rng, ns, on->mono_time, net, dht, &inf, on->tcp_np);
|
||||
on->onion_c = new_onion_client(on->log, mem, rng, on->mono_time, on->nc, dht, net);
|
||||
|
||||
if (!on->onion_c) {
|
||||
netprof_kill(mem, on->tcp_np);
|
||||
@@ -514,9 +521,9 @@ static void do_onions(Onions *on)
|
||||
|
||||
static void kill_onions(const Memory *mem, Onions *on)
|
||||
{
|
||||
Networking_Core *net = dht_get_net(on->onion->dht);
|
||||
Networking_Core *net = on->onion->net;
|
||||
DHT *dht = on->onion->dht;
|
||||
Net_Crypto *c = onion_get_net_crypto(on->onion_c);
|
||||
Net_Crypto *c = on->nc;
|
||||
kill_onion_client(on->onion_c);
|
||||
kill_onion_announce(on->onion_a);
|
||||
kill_onion(on->onion);
|
||||
@@ -640,9 +647,9 @@ static void test_announce(void)
|
||||
|
||||
printf("adding friend\n");
|
||||
int frnum_f = onion_addfriend(onions[NUM_FIRST]->onion_c,
|
||||
nc_get_self_public_key(onion_get_net_crypto(onions[NUM_LAST]->onion_c)));
|
||||
nc_get_self_public_key(onions[NUM_LAST]->nc));
|
||||
int frnum = onion_addfriend(onions[NUM_LAST]->onion_c,
|
||||
nc_get_self_public_key(onion_get_net_crypto(onions[NUM_FIRST]->onion_c)));
|
||||
nc_get_self_public_key(onions[NUM_FIRST]->nc));
|
||||
|
||||
onion_dht_pk_callback(onions[NUM_FIRST]->onion_c, frnum_f, &dht_pk_callback, onions[NUM_FIRST], NUM_FIRST);
|
||||
onion_dht_pk_callback(onions[NUM_LAST]->onion_c, frnum, &dht_pk_callback, onions[NUM_LAST], NUM_LAST);
|
||||
|
||||
@@ -6,13 +6,12 @@
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "../testing/misc_tools.h"
|
||||
#include "../toxcore/friend_connection.h"
|
||||
#include "../toxcore/os_random.h"
|
||||
#include "../toxcore/tox.h"
|
||||
#include "../toxcore/util.h"
|
||||
#include "check_compat.h"
|
||||
|
||||
#define TOX_COUNT 2
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "../testing/misc_tools.h"
|
||||
#include "../toxcore/ccompat.h"
|
||||
#include "../toxcore/crypto_core.h"
|
||||
#include "../toxcore/os_random.h"
|
||||
#include "../toxcore/tox.h"
|
||||
#include "auto_test_support.h"
|
||||
#include "check_compat.h"
|
||||
|
||||
@@ -2,14 +2,13 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "../testing/misc_tools.h"
|
||||
#include "../toxcore/crypto_core.h"
|
||||
#include "../toxcore/os_random.h"
|
||||
#include "../toxcore/tox.h"
|
||||
#include "../toxcore/util.h"
|
||||
#include "auto_test_support.h"
|
||||
#include "check_compat.h"
|
||||
|
||||
|
||||
@@ -2,14 +2,13 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "../testing/misc_tools.h"
|
||||
#include "../toxcore/crypto_core.h"
|
||||
#include "../toxcore/os_random.h"
|
||||
#include "../toxcore/tox.h"
|
||||
#include "../toxcore/util.h"
|
||||
#include "auto_test_support.h"
|
||||
#include "check_compat.h"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user