Squashed 'external/toxcore/c-toxcore/' changes from 73d9b845a3..e2c01e457b
e2c01e457b refactor: Use enum-specific pack functions for enum values. afc472402b refactor: Factor out union pack switch from event packer. 6caa7ce4b1 cleanup: Move the 2-element array pack out of individual events. 687af81f20 cleanup: Remove empty test doing nothing. fcf5882428 test: Add printf log statement to group_moderation_test. b4d8826228 cleanup: Remove old type-ordered event getters. 8c35e0fefb feat: add ngc events 97bdd83937 refactor: Make event dispatch ordered by receive time. 001d00ab30 fix: dont resolve to ipv6 addresses when its disabled d3b935f63f fix(test): tests use ipv6 by default, even with USE_IPV6 set to 0 29fc5ea1f7 chore: add clangd files to .gitignore d30c81acbc refactor: Move file streaming test to its own file. acdc67387b fix(ci): window builds now build in parallel REVERT: 73d9b845a3 cleanup: Remove old type-ordered event getters. REVERT: b0840cc02d feat: add ngc events REVERT: 7df9a51349 refactor: Make event dispatch ordered by receive time. git-subtree-dir: external/toxcore/c-toxcore git-subtree-split: e2c01e457bfb8a59537175c8fe17ca9ab1c9e3e1
This commit is contained in:
@ -46,8 +46,9 @@ auto_test(crypto)
|
||||
#auto_test(dht) # Doesn't work with UNITY_BUILD.
|
||||
auto_test(dht_getnodes_api)
|
||||
auto_test(encryptsave)
|
||||
auto_test(file_transfer)
|
||||
auto_test(file_saving)
|
||||
auto_test(file_streaming)
|
||||
auto_test(file_transfer)
|
||||
auto_test(forwarding)
|
||||
auto_test(friend_connection)
|
||||
auto_test(friend_request)
|
||||
|
@ -15,6 +15,7 @@ TESTS = \
|
||||
crypto_test \
|
||||
encryptsave_test \
|
||||
file_saving_test \
|
||||
file_streaming_test \
|
||||
file_transfer_test \
|
||||
forwarding_test \
|
||||
friend_connection_test \
|
||||
@ -103,6 +104,10 @@ file_saving_test_SOURCES = ../auto_tests/file_saving_test.c
|
||||
file_saving_test_CFLAGS = $(AUTOTEST_CFLAGS)
|
||||
file_saving_test_LDADD = $(AUTOTEST_LDADD)
|
||||
|
||||
file_streaming_test_SOURCES = ../auto_tests/file_streaming_test.c
|
||||
file_streaming_test_CFLAGS = $(AUTOTEST_CFLAGS)
|
||||
file_streaming_test_LDADD = $(AUTOTEST_LDADD)
|
||||
|
||||
file_transfer_test_SOURCES = ../auto_tests/file_transfer_test.c
|
||||
file_transfer_test_CFLAGS = $(AUTOTEST_CFLAGS)
|
||||
file_transfer_test_LDADD = $(AUTOTEST_LDADD)
|
||||
|
@ -13,6 +13,10 @@
|
||||
#define ABORT_ON_LOG_ERROR true
|
||||
#endif
|
||||
|
||||
#ifndef USE_IPV6
|
||||
#define USE_IPV6 1
|
||||
#endif
|
||||
|
||||
Run_Auto_Options default_run_auto_options(void)
|
||||
{
|
||||
return (Run_Auto_Options) {
|
||||
@ -193,6 +197,7 @@ void reload(AutoTox *autotox)
|
||||
|
||||
struct Tox_Options *const options = tox_options_new(nullptr);
|
||||
ck_assert(options != nullptr);
|
||||
tox_options_set_ipv6_enabled(options, USE_IPV6);
|
||||
tox_options_set_savedata_type(options, TOX_SAVEDATA_TYPE_TOX_SAVE);
|
||||
tox_options_set_savedata_data(options, autotox->save_state, autotox->save_size);
|
||||
autotox->tox = tox_new_log(options, nullptr, &autotox->index);
|
||||
@ -214,6 +219,8 @@ static void initialise_autotox(struct Tox_Options *options, AutoTox *autotox, ui
|
||||
struct Tox_Options *default_opts = tox_options_new(nullptr);
|
||||
ck_assert(default_opts != nullptr);
|
||||
|
||||
tox_options_set_ipv6_enabled(default_opts, USE_IPV6);
|
||||
|
||||
if (options == nullptr) {
|
||||
options = default_opts;
|
||||
}
|
||||
@ -426,6 +433,7 @@ Tox *tox_new_log_lan(struct Tox_Options *options, Tox_Err_New *err, void *log_us
|
||||
|
||||
assert(log_options != nullptr);
|
||||
|
||||
tox_options_set_ipv6_enabled(log_options, USE_IPV6);
|
||||
tox_options_set_local_discovery_enabled(log_options, lan_discovery);
|
||||
// Use a higher start port for non-LAN-discovery tests so it's more likely for the LAN discovery
|
||||
// test to get the default port 33445.
|
||||
|
275
auto_tests/file_streaming_test.c
Normal file
275
auto_tests/file_streaming_test.c
Normal file
@ -0,0 +1,275 @@
|
||||
/* File transfer test: streaming version (no known size).
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "../testing/misc_tools.h"
|
||||
#include "../toxcore/ccompat.h"
|
||||
#include "../toxcore/tox.h"
|
||||
#include "../toxcore/util.h"
|
||||
#include "auto_test_support.h"
|
||||
#include "check_compat.h"
|
||||
|
||||
#ifndef USE_IPV6
|
||||
#define USE_IPV6 1
|
||||
#endif
|
||||
|
||||
#ifdef TOX_LOCALHOST
|
||||
#undef TOX_LOCALHOST
|
||||
#endif
|
||||
#if USE_IPV6
|
||||
#define TOX_LOCALHOST "::1"
|
||||
#else
|
||||
#define TOX_LOCALHOST "127.0.0.1"
|
||||
#endif
|
||||
|
||||
static void accept_friend_request(Tox *m, const uint8_t *public_key, const uint8_t *data, size_t length, void *userdata)
|
||||
{
|
||||
if (length == 7 && memcmp("Gentoo", data, 7) == 0) {
|
||||
tox_friend_add_norequest(m, public_key, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
static uint64_t size_recv;
|
||||
static uint64_t sending_pos;
|
||||
|
||||
static uint8_t file_cmp_id[TOX_FILE_ID_LENGTH];
|
||||
static uint32_t file_accepted;
|
||||
static uint64_t file_size;
|
||||
static void tox_file_receive(Tox *tox, uint32_t friend_number, uint32_t file_number, uint32_t kind, uint64_t filesize,
|
||||
const uint8_t *filename, size_t filename_length, void *userdata)
|
||||
{
|
||||
ck_assert_msg(kind == TOX_FILE_KIND_DATA, "bad kind");
|
||||
|
||||
ck_assert_msg(filename_length == sizeof("Gentoo.exe")
|
||||
&& memcmp(filename, "Gentoo.exe", sizeof("Gentoo.exe")) == 0, "bad filename");
|
||||
|
||||
uint8_t file_id[TOX_FILE_ID_LENGTH];
|
||||
|
||||
ck_assert_msg(tox_file_get_file_id(tox, friend_number, file_number, file_id, nullptr), "tox_file_get_file_id error");
|
||||
|
||||
ck_assert_msg(memcmp(file_id, file_cmp_id, TOX_FILE_ID_LENGTH) == 0, "bad file_id");
|
||||
|
||||
uint8_t empty[TOX_FILE_ID_LENGTH] = {0};
|
||||
|
||||
ck_assert_msg(memcmp(empty, file_cmp_id, TOX_FILE_ID_LENGTH) != 0, "empty file_id");
|
||||
|
||||
file_size = filesize;
|
||||
|
||||
if (filesize) {
|
||||
sending_pos = size_recv = 1337;
|
||||
|
||||
Tox_Err_File_Seek err_s;
|
||||
|
||||
ck_assert_msg(tox_file_seek(tox, friend_number, file_number, 1337, &err_s), "tox_file_seek error");
|
||||
|
||||
ck_assert_msg(err_s == TOX_ERR_FILE_SEEK_OK, "tox_file_seek wrong error");
|
||||
|
||||
} else {
|
||||
sending_pos = size_recv = 0;
|
||||
}
|
||||
|
||||
Tox_Err_File_Control error;
|
||||
|
||||
ck_assert_msg(tox_file_control(tox, friend_number, file_number, TOX_FILE_CONTROL_RESUME, &error),
|
||||
"tox_file_control failed. %i", error);
|
||||
++file_accepted;
|
||||
|
||||
Tox_Err_File_Seek err_s;
|
||||
|
||||
ck_assert_msg(!tox_file_seek(tox, friend_number, file_number, 1234, &err_s), "tox_file_seek no error");
|
||||
|
||||
ck_assert_msg(err_s == TOX_ERR_FILE_SEEK_DENIED, "tox_file_seek wrong error");
|
||||
}
|
||||
|
||||
static uint32_t sendf_ok;
|
||||
static void file_print_control(Tox *tox, uint32_t friend_number, uint32_t file_number, Tox_File_Control control,
|
||||
void *userdata)
|
||||
{
|
||||
/* First send file num is 0.*/
|
||||
if (file_number == 0 && control == TOX_FILE_CONTROL_RESUME) {
|
||||
sendf_ok = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static uint64_t max_sending;
|
||||
static bool m_send_reached;
|
||||
static uint8_t sending_num;
|
||||
static bool file_sending_done;
|
||||
static void tox_file_chunk_request(Tox *tox, uint32_t friend_number, uint32_t file_number, uint64_t position,
|
||||
size_t length, void *user_data)
|
||||
{
|
||||
ck_assert_msg(sendf_ok, "didn't get resume control");
|
||||
|
||||
ck_assert_msg(sending_pos == position, "bad position %lu", (unsigned long)position);
|
||||
|
||||
if (length == 0) {
|
||||
ck_assert_msg(!file_sending_done, "file sending already done");
|
||||
|
||||
file_sending_done = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
if (position + length > max_sending) {
|
||||
ck_assert_msg(!m_send_reached, "requested done file transfer");
|
||||
|
||||
length = max_sending - position;
|
||||
m_send_reached = 1;
|
||||
}
|
||||
|
||||
VLA(uint8_t, f_data, length);
|
||||
memset(f_data, sending_num, length);
|
||||
|
||||
Tox_Err_File_Send_Chunk error;
|
||||
tox_file_send_chunk(tox, friend_number, file_number, position, f_data, length, &error);
|
||||
|
||||
|
||||
ck_assert_msg(error == TOX_ERR_FILE_SEND_CHUNK_OK,
|
||||
"could not send chunk, error num=%d pos=%d len=%d", (int)error, (int)position, (int)length);
|
||||
|
||||
++sending_num;
|
||||
sending_pos += length;
|
||||
}
|
||||
|
||||
|
||||
static uint8_t num;
|
||||
static bool file_recv;
|
||||
static void write_file(Tox *tox, uint32_t friendnumber, uint32_t filenumber, uint64_t position, const uint8_t *data,
|
||||
size_t length, void *user_data)
|
||||
{
|
||||
ck_assert_msg(size_recv == position, "bad position");
|
||||
|
||||
if (length == 0) {
|
||||
file_recv = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
VLA(uint8_t, f_data, length);
|
||||
memset(f_data, num, length);
|
||||
++num;
|
||||
|
||||
ck_assert_msg(memcmp(f_data, data, length) == 0, "FILE_CORRUPTED");
|
||||
|
||||
size_recv += length;
|
||||
}
|
||||
|
||||
static void file_transfer_test(void)
|
||||
{
|
||||
printf("Starting test: few_clients\n");
|
||||
uint32_t index[] = { 1, 2, 3 };
|
||||
long long unsigned int cur_time = time(nullptr);
|
||||
Tox_Err_New t_n_error;
|
||||
Tox *tox1 = tox_new_log(nullptr, &t_n_error, &index[0]);
|
||||
ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "wrong error");
|
||||
Tox *tox2 = tox_new_log(nullptr, &t_n_error, &index[1]);
|
||||
ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "wrong error");
|
||||
Tox *tox3 = tox_new_log(nullptr, &t_n_error, &index[2]);
|
||||
ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "wrong error");
|
||||
|
||||
ck_assert_msg(tox1 && tox2 && tox3, "Failed to create 3 tox instances");
|
||||
|
||||
tox_callback_friend_request(tox2, accept_friend_request);
|
||||
uint8_t address[TOX_ADDRESS_SIZE];
|
||||
tox_self_get_address(tox2, address);
|
||||
uint32_t test = tox_friend_add(tox3, address, (const uint8_t *)"Gentoo", 7, nullptr);
|
||||
ck_assert_msg(test == 0, "Failed to add friend error code: %u", test);
|
||||
|
||||
uint8_t dht_key[TOX_PUBLIC_KEY_SIZE];
|
||||
tox_self_get_dht_id(tox1, dht_key);
|
||||
uint16_t dht_port = tox_self_get_udp_port(tox1, nullptr);
|
||||
|
||||
tox_bootstrap(tox2, TOX_LOCALHOST, dht_port, dht_key, nullptr);
|
||||
tox_bootstrap(tox3, TOX_LOCALHOST, dht_port, dht_key, nullptr);
|
||||
|
||||
printf("Waiting for toxes to come online\n");
|
||||
|
||||
do {
|
||||
tox_iterate(tox1, nullptr);
|
||||
tox_iterate(tox2, nullptr);
|
||||
tox_iterate(tox3, nullptr);
|
||||
|
||||
printf("Connections: self (%d, %d, %d), friends (%d, %d)\n",
|
||||
tox_self_get_connection_status(tox1),
|
||||
tox_self_get_connection_status(tox2),
|
||||
tox_self_get_connection_status(tox3),
|
||||
tox_friend_get_connection_status(tox2, 0, nullptr),
|
||||
tox_friend_get_connection_status(tox3, 0, nullptr));
|
||||
c_sleep(ITERATION_INTERVAL);
|
||||
} while (tox_self_get_connection_status(tox1) == TOX_CONNECTION_NONE ||
|
||||
tox_self_get_connection_status(tox2) == TOX_CONNECTION_NONE ||
|
||||
tox_self_get_connection_status(tox3) == TOX_CONNECTION_NONE ||
|
||||
tox_friend_get_connection_status(tox2, 0, nullptr) == TOX_CONNECTION_NONE ||
|
||||
tox_friend_get_connection_status(tox3, 0, nullptr) == TOX_CONNECTION_NONE);
|
||||
|
||||
printf("Starting file transfer test: 100MiB file.\n");
|
||||
|
||||
file_accepted = file_size = sendf_ok = size_recv = 0;
|
||||
file_recv = 0;
|
||||
max_sending = UINT64_MAX;
|
||||
uint64_t totalf_size = 100 * 1024 * 1024;
|
||||
|
||||
printf("Starting file streaming transfer test.\n");
|
||||
|
||||
file_sending_done = 0;
|
||||
file_accepted = 0;
|
||||
file_size = 0;
|
||||
sendf_ok = 0;
|
||||
size_recv = 0;
|
||||
file_recv = 0;
|
||||
tox_callback_file_recv_chunk(tox3, write_file);
|
||||
tox_callback_file_recv_control(tox2, file_print_control);
|
||||
tox_callback_file_chunk_request(tox2, tox_file_chunk_request);
|
||||
tox_callback_file_recv_control(tox3, file_print_control);
|
||||
tox_callback_file_recv(tox3, tox_file_receive);
|
||||
totalf_size = UINT64_MAX;
|
||||
Tox_File_Number fnum = tox_file_send(
|
||||
tox2, 0, TOX_FILE_KIND_DATA, totalf_size, nullptr,
|
||||
(const uint8_t *)"Gentoo.exe", sizeof("Gentoo.exe"), nullptr);
|
||||
ck_assert_msg(fnum != UINT32_MAX, "tox_new_file_sender fail");
|
||||
|
||||
Tox_Err_File_Get gfierr;
|
||||
ck_assert_msg(!tox_file_get_file_id(tox2, 1, fnum, file_cmp_id, &gfierr), "tox_file_get_file_id didn't fail");
|
||||
ck_assert_msg(gfierr == TOX_ERR_FILE_GET_FRIEND_NOT_FOUND, "wrong error");
|
||||
ck_assert_msg(!tox_file_get_file_id(tox2, 0, fnum + 1, file_cmp_id, &gfierr), "tox_file_get_file_id didn't fail");
|
||||
ck_assert_msg(gfierr == TOX_ERR_FILE_GET_NOT_FOUND, "wrong error");
|
||||
ck_assert_msg(tox_file_get_file_id(tox2, 0, fnum, file_cmp_id, &gfierr), "tox_file_get_file_id failed");
|
||||
ck_assert_msg(gfierr == TOX_ERR_FILE_GET_OK, "wrong error");
|
||||
|
||||
max_sending = 100 * 1024;
|
||||
m_send_reached = 0;
|
||||
|
||||
do {
|
||||
tox_iterate(tox1, nullptr);
|
||||
tox_iterate(tox2, nullptr);
|
||||
tox_iterate(tox3, nullptr);
|
||||
|
||||
uint32_t tox1_interval = tox_iteration_interval(tox1);
|
||||
uint32_t tox2_interval = tox_iteration_interval(tox2);
|
||||
uint32_t tox3_interval = tox_iteration_interval(tox3);
|
||||
|
||||
c_sleep(min_u32(tox1_interval, min_u32(tox2_interval, tox3_interval)));
|
||||
} while (!file_sending_done);
|
||||
|
||||
ck_assert_msg(sendf_ok && file_recv && m_send_reached && totalf_size == file_size && size_recv == max_sending
|
||||
&& sending_pos == size_recv && file_accepted == 1,
|
||||
"something went wrong in file transfer %u %u %u %u %u %u %u %lu %lu %lu %lu", sendf_ok, file_recv,
|
||||
m_send_reached, totalf_size == file_size, size_recv == max_sending, sending_pos == size_recv, file_accepted == 1,
|
||||
(unsigned long)totalf_size, (unsigned long)file_size,
|
||||
(unsigned long)size_recv, (unsigned long)sending_pos);
|
||||
|
||||
printf("file_transfer_test succeeded, took %llu seconds\n", time(nullptr) - cur_time);
|
||||
|
||||
tox_kill(tox1);
|
||||
tox_kill(tox2);
|
||||
tox_kill(tox3);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
setvbuf(stdout, nullptr, _IONBF, 0);
|
||||
file_transfer_test();
|
||||
return 0;
|
||||
}
|
@ -13,9 +13,14 @@
|
||||
#include "auto_test_support.h"
|
||||
#include "check_compat.h"
|
||||
|
||||
/* The Travis-CI container responds poorly to ::1 as a localhost address
|
||||
* You're encouraged to -D FORCE_TESTS_IPV6 on a local test */
|
||||
#ifdef FORCE_TESTS_IPV6
|
||||
#ifndef USE_IPV6
|
||||
#define USE_IPV6 1
|
||||
#endif
|
||||
|
||||
#ifdef TOX_LOCALHOST
|
||||
#undef TOX_LOCALHOST
|
||||
#endif
|
||||
#if USE_IPV6
|
||||
#define TOX_LOCALHOST "::1"
|
||||
#else
|
||||
#define TOX_LOCALHOST "127.0.0.1"
|
||||
@ -261,53 +266,6 @@ static void file_transfer_test(void)
|
||||
|
||||
printf("100MiB file sent in %lu seconds\n", (unsigned long)(time(nullptr) - f_time));
|
||||
|
||||
printf("Starting file streaming transfer test.\n");
|
||||
|
||||
file_sending_done = 0;
|
||||
file_accepted = 0;
|
||||
file_size = 0;
|
||||
sendf_ok = 0;
|
||||
size_recv = 0;
|
||||
file_recv = 0;
|
||||
tox_callback_file_recv_chunk(tox3, write_file);
|
||||
tox_callback_file_recv_control(tox2, file_print_control);
|
||||
tox_callback_file_chunk_request(tox2, tox_file_chunk_request);
|
||||
tox_callback_file_recv_control(tox3, file_print_control);
|
||||
tox_callback_file_recv(tox3, tox_file_receive);
|
||||
totalf_size = UINT64_MAX;
|
||||
fnum = tox_file_send(tox2, 0, TOX_FILE_KIND_DATA, totalf_size, nullptr,
|
||||
(const uint8_t *)"Gentoo.exe", sizeof("Gentoo.exe"), nullptr);
|
||||
ck_assert_msg(fnum != UINT32_MAX, "tox_new_file_sender fail");
|
||||
|
||||
ck_assert_msg(!tox_file_get_file_id(tox2, 1, fnum, file_cmp_id, &gfierr), "tox_file_get_file_id didn't fail");
|
||||
ck_assert_msg(gfierr == TOX_ERR_FILE_GET_FRIEND_NOT_FOUND, "wrong error");
|
||||
ck_assert_msg(!tox_file_get_file_id(tox2, 0, fnum + 1, file_cmp_id, &gfierr), "tox_file_get_file_id didn't fail");
|
||||
ck_assert_msg(gfierr == TOX_ERR_FILE_GET_NOT_FOUND, "wrong error");
|
||||
ck_assert_msg(tox_file_get_file_id(tox2, 0, fnum, file_cmp_id, &gfierr), "tox_file_get_file_id failed");
|
||||
ck_assert_msg(gfierr == TOX_ERR_FILE_GET_OK, "wrong error");
|
||||
|
||||
max_sending = 100 * 1024;
|
||||
m_send_reached = 0;
|
||||
|
||||
do {
|
||||
tox_iterate(tox1, nullptr);
|
||||
tox_iterate(tox2, nullptr);
|
||||
tox_iterate(tox3, nullptr);
|
||||
|
||||
uint32_t tox1_interval = tox_iteration_interval(tox1);
|
||||
uint32_t tox2_interval = tox_iteration_interval(tox2);
|
||||
uint32_t tox3_interval = tox_iteration_interval(tox3);
|
||||
|
||||
c_sleep(min_u32(tox1_interval, min_u32(tox2_interval, tox3_interval)));
|
||||
} while (!file_sending_done);
|
||||
|
||||
ck_assert_msg(sendf_ok && file_recv && m_send_reached && totalf_size == file_size && size_recv == max_sending
|
||||
&& sending_pos == size_recv && file_accepted == 1,
|
||||
"something went wrong in file transfer %u %u %u %u %u %u %u %lu %lu %lu %lu", sendf_ok, file_recv,
|
||||
m_send_reached, totalf_size == file_size, size_recv == max_sending, sending_pos == size_recv, file_accepted == 1,
|
||||
(unsigned long)totalf_size, (unsigned long)file_size,
|
||||
(unsigned long)size_recv, (unsigned long)sending_pos);
|
||||
|
||||
printf("starting file 0 transfer test.\n");
|
||||
|
||||
file_sending_done = 0;
|
||||
|
@ -247,7 +247,7 @@ static void handle_user(State *state, const char *peer_name, size_t peer_name_le
|
||||
}
|
||||
|
||||
static void group_mod_event_handler(Tox *tox, uint32_t group_number, uint32_t source_peer_id, uint32_t target_peer_id,
|
||||
Tox_Group_Mod_Event event, void *user_data)
|
||||
Tox_Group_Mod_Event mod_type, void *user_data)
|
||||
{
|
||||
AutoTox *autotox = (AutoTox *)user_data;
|
||||
ck_assert(autotox != nullptr);
|
||||
@ -275,7 +275,11 @@ static void group_mod_event_handler(Tox *tox, uint32_t group_number, uint32_t so
|
||||
Tox_Group_Role role = tox_group_peer_get_role(tox, group_number, target_peer_id, &q_err);
|
||||
ck_assert(q_err == TOX_ERR_GROUP_PEER_QUERY_OK);
|
||||
|
||||
switch (event) {
|
||||
fprintf(stderr, "tox%u: got moderator event %d (%s), role = %s\n",
|
||||
autotox->index, mod_type, tox_group_mod_event_to_string(mod_type),
|
||||
tox_group_role_to_string(role));
|
||||
|
||||
switch (mod_type) {
|
||||
case TOX_GROUP_MOD_EVENT_MODERATOR: {
|
||||
handle_mod(state, peer_name, peer_name_len, role);
|
||||
break;
|
||||
@ -298,7 +302,7 @@ static void group_mod_event_handler(Tox *tox, uint32_t group_number, uint32_t so
|
||||
}
|
||||
|
||||
default: {
|
||||
ck_assert_msg(0, "Got invalid moderator event %d", event);
|
||||
ck_assert_msg(0, "Got invalid moderator event %d", mod_type);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -14,12 +14,14 @@
|
||||
#include "auto_test_support.h"
|
||||
#include "check_compat.h"
|
||||
|
||||
/* The Travis-CI container responds poorly to ::1 as a localhost address
|
||||
* You're encouraged to -D FORCE_TESTS_IPV6 on a local test */
|
||||
#ifndef USE_IPV6
|
||||
#define USE_IPV6 1
|
||||
#endif
|
||||
|
||||
#ifdef TOX_LOCALHOST
|
||||
#undef TOX_LOCALHOST
|
||||
#endif
|
||||
#ifdef FORCE_TESTS_IPV6
|
||||
#if USE_IPV6
|
||||
#define TOX_LOCALHOST "::1"
|
||||
#else
|
||||
#define TOX_LOCALHOST "127.0.0.1"
|
||||
@ -74,6 +76,7 @@ static void reload_tox(Tox **tox, struct Tox_Options *const in_opts, void *user_
|
||||
}
|
||||
|
||||
struct Tox_Options *const options = (in_opts == nullptr) ? tox_options_new(nullptr) : in_opts;
|
||||
tox_options_set_ipv6_enabled(options, USE_IPV6);
|
||||
|
||||
tox_options_set_savedata_type(options, TOX_SAVEDATA_TYPE_TOX_SAVE);
|
||||
|
||||
@ -138,6 +141,7 @@ static void test_few_clients(void)
|
||||
time_t con_time = 0, cur_time = time(nullptr);
|
||||
|
||||
struct Tox_Options *opts1 = tox_options_new(nullptr);
|
||||
tox_options_set_ipv6_enabled(opts1, USE_IPV6);
|
||||
tox_options_set_tcp_port(opts1, TCP_RELAY_PORT);
|
||||
Tox_Err_New t_n_error;
|
||||
Tox *tox1 = tox_new_log(opts1, &t_n_error, &index[0]);
|
||||
@ -145,12 +149,14 @@ static void test_few_clients(void)
|
||||
tox_options_free(opts1);
|
||||
|
||||
struct Tox_Options *opts2 = tox_options_new(nullptr);
|
||||
tox_options_set_ipv6_enabled(opts2, USE_IPV6);
|
||||
tox_options_set_udp_enabled(opts2, false);
|
||||
tox_options_set_local_discovery_enabled(opts2, false);
|
||||
Tox *tox2 = tox_new_log(opts2, &t_n_error, &index[1]);
|
||||
ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "Failed to create tox instance: %d", t_n_error);
|
||||
|
||||
struct Tox_Options *opts3 = tox_options_new(nullptr);
|
||||
tox_options_set_ipv6_enabled(opts3, USE_IPV6);
|
||||
tox_options_set_local_discovery_enabled(opts3, false);
|
||||
Tox *tox3 = tox_new_log(opts3, &t_n_error, &index[2]);
|
||||
ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "Failed to create tox instance: %d", t_n_error);
|
||||
|
@ -13,9 +13,14 @@
|
||||
#include "auto_test_support.h"
|
||||
#include "check_compat.h"
|
||||
|
||||
/* The Travis-CI container responds poorly to ::1 as a localhost address
|
||||
* You're encouraged to -D FORCE_TESTS_IPV6 on a local test */
|
||||
#ifdef FORCE_TESTS_IPV6
|
||||
#ifndef USE_IPV6
|
||||
#define USE_IPV6 1
|
||||
#endif
|
||||
|
||||
#ifdef TOX_LOCALHOST
|
||||
#undef TOX_LOCALHOST
|
||||
#endif
|
||||
#if USE_IPV6
|
||||
#define TOX_LOCALHOST "::1"
|
||||
#else
|
||||
#define TOX_LOCALHOST "127.0.0.1"
|
||||
|
Reference in New Issue
Block a user