diff --git a/auto_tests/conference_av_test.c b/auto_tests/conference_av_test.c index bf4adfe8a1..24163440a7 100644 --- a/auto_tests/conference_av_test.c +++ b/auto_tests/conference_av_test.c @@ -464,6 +464,6 @@ int main(void) { setvbuf(stdout, nullptr, _IONBF, 0); - run_auto_test(NUM_AV_GROUP_TOX, test_groupav, true); + run_auto_test(nullptr, NUM_AV_GROUP_TOX, test_groupav, true); return 0; } diff --git a/auto_tests/conference_double_invite_test.c b/auto_tests/conference_double_invite_test.c index 0e13fca83a..6d8c1aa38c 100644 --- a/auto_tests/conference_double_invite_test.c +++ b/auto_tests/conference_double_invite_test.c @@ -79,6 +79,6 @@ int main(void) { setvbuf(stdout, nullptr, _IONBF, 0); - run_auto_test(2, conference_double_invite_test, false); + run_auto_test(nullptr, 2, conference_double_invite_test, false); return 0; } diff --git a/auto_tests/conference_invite_merge_test.c b/auto_tests/conference_invite_merge_test.c index 0e285c1ef5..c44f13220b 100644 --- a/auto_tests/conference_invite_merge_test.c +++ b/auto_tests/conference_invite_merge_test.c @@ -237,6 +237,6 @@ int main(void) { setvbuf(stdout, nullptr, _IONBF, 0); - run_auto_test(NUM_INVITE_MERGE_TOX, conference_invite_merge_test, true); + run_auto_test(nullptr, NUM_INVITE_MERGE_TOX, conference_invite_merge_test, true); return 0; } diff --git a/auto_tests/conference_peer_nick_test.c b/auto_tests/conference_peer_nick_test.c index 1ab857789d..3f3399b16e 100644 --- a/auto_tests/conference_peer_nick_test.c +++ b/auto_tests/conference_peer_nick_test.c @@ -126,6 +126,6 @@ int main(void) { setvbuf(stdout, nullptr, _IONBF, 0); - run_auto_test(2, conference_peer_nick_test, false); + run_auto_test(nullptr, 2, conference_peer_nick_test, false); return 0; } diff --git a/auto_tests/conference_test.c b/auto_tests/conference_test.c index ac1bdaa8ec..cce9ad707f 100644 --- a/auto_tests/conference_test.c +++ b/auto_tests/conference_test.c @@ -431,6 +431,6 @@ int main(void) { setvbuf(stdout, nullptr, _IONBF, 0); - run_auto_test(NUM_GROUP_TOX, test_many_group, true); + run_auto_test(nullptr, NUM_GROUP_TOX, test_many_group, true); return 0; } diff --git a/auto_tests/friend_connection_test.c b/auto_tests/friend_connection_test.c index 6365df09c5..21c25b93f0 100644 --- a/auto_tests/friend_connection_test.c +++ b/auto_tests/friend_connection_test.c @@ -23,6 +23,6 @@ int main(void) { setvbuf(stdout, nullptr, _IONBF, 0); - run_auto_test(2, friend_connection_test, false); + run_auto_test(nullptr, 2, friend_connection_test, false); return 0; } diff --git a/auto_tests/lossless_packet_test.c b/auto_tests/lossless_packet_test.c index 63302d67f4..da0f6447a1 100644 --- a/auto_tests/lossless_packet_test.c +++ b/auto_tests/lossless_packet_test.c @@ -57,6 +57,6 @@ int main(void) { setvbuf(stdout, nullptr, _IONBF, 0); - run_auto_test(2, test_lossless_packet, false); + run_auto_test(nullptr, 2, test_lossless_packet, false); return 0; } diff --git a/auto_tests/lossy_packet_test.c b/auto_tests/lossy_packet_test.c index c4ca213d5a..0dcd50a499 100644 --- a/auto_tests/lossy_packet_test.c +++ b/auto_tests/lossy_packet_test.c @@ -53,6 +53,6 @@ int main(void) { setvbuf(stdout, nullptr, _IONBF, 0); - run_auto_test(2, test_lossy_packet, false); + run_auto_test(nullptr, 2, test_lossy_packet, false); return 0; } diff --git a/auto_tests/overflow_recvq_test.c b/auto_tests/overflow_recvq_test.c index 92e633cab1..0ab54f2408 100644 --- a/auto_tests/overflow_recvq_test.c +++ b/auto_tests/overflow_recvq_test.c @@ -58,6 +58,6 @@ int main(void) { setvbuf(stdout, nullptr, _IONBF, 0); - run_auto_test(3, net_crypto_overflow_test, false); + run_auto_test(nullptr, 3, net_crypto_overflow_test, false); return 0; } diff --git a/auto_tests/overflow_sendq_test.c b/auto_tests/overflow_sendq_test.c index 2c02ba0544..b96c6664ef 100644 --- a/auto_tests/overflow_sendq_test.c +++ b/auto_tests/overflow_sendq_test.c @@ -43,6 +43,6 @@ int main(void) { setvbuf(stdout, nullptr, _IONBF, 0); - run_auto_test(2, net_crypto_overflow_test, false); + run_auto_test(nullptr, 2, net_crypto_overflow_test, false); return 0; } diff --git a/auto_tests/reconnect_test.c b/auto_tests/reconnect_test.c index a0245ff5dc..f995b835cc 100644 --- a/auto_tests/reconnect_test.c +++ b/auto_tests/reconnect_test.c @@ -97,6 +97,6 @@ int main(void) { setvbuf(stdout, nullptr, _IONBF, 0); - run_auto_test(TOX_COUNT, test_reconnect, false); + run_auto_test(nullptr, TOX_COUNT, test_reconnect, false); return 0; } diff --git a/auto_tests/run_auto_test.h b/auto_tests/run_auto_test.h index 58ebf9cba0..76dd10f5a5 100644 --- a/auto_tests/run_auto_test.h +++ b/auto_tests/run_auto_test.h @@ -5,6 +5,28 @@ #include "../toxcore/Messenger.h" #include "../toxcore/mono_time.h" +// TCP relay keys, copied from tcp_relay_test.c +static uint8_t const mainnet_tcp_key1[] = { + 0x02, 0x80, 0x7C, 0xF4, 0xF8, 0xBB, 0x8F, 0xB3, + 0x90, 0xCC, 0x37, 0x94, 0xBD, 0xF1, 0xE8, 0x44, + 0x9E, 0x9A, 0x83, 0x92, 0xC5, 0xD3, 0xF2, 0x20, + 0x00, 0x19, 0xDA, 0x9F, 0x1E, 0x81, 0x2E, 0x46, +}; + +static uint8_t const mainnet_tcp_key2[] = { + 0x3F, 0x0A, 0x45, 0xA2, 0x68, 0x36, 0x7C, 0x1B, + 0xEA, 0x65, 0x2F, 0x25, 0x8C, 0x85, 0xF4, 0xA6, + 0x6D, 0xA7, 0x6B, 0xCA, 0xA6, 0x67, 0xA4, 0x9E, + 0x77, 0x0B, 0xCC, 0x49, 0x17, 0xAB, 0x6A, 0x25, +}; + +static uint8_t const testnet_tcp_key[] = { + 0x79, 0xCA, 0xDA, 0x49, 0x74, 0xB0, 0x92, 0x6F, + 0x28, 0x6F, 0x02, 0x5C, 0xD5, 0xFF, 0xDF, 0x3E, + 0x65, 0x4A, 0x37, 0x58, 0xC5, 0x3E, 0x02, 0x73, + 0xEC, 0xFC, 0x4D, 0x12, 0xC2, 0x1D, 0xCA, 0x48, +}; + static bool all_connected(uint32_t tox_count, Tox **toxes) { for (uint32_t i = 0; i < tox_count; i++) { @@ -108,7 +130,8 @@ static void wait_friend_connections(uint32_t tox_count, Tox **toxes, State *stat printf("tox clients connected\n"); } -static void run_auto_test(uint32_t tox_count, void test(Tox **toxes, State *state), bool chain) +static void run_auto_test(struct Tox_Options *options, uint32_t tox_count, void test(Tox **toxes, State *state), + bool chain) { printf("initialising %u toxes\n", tox_count); Tox **toxes = (Tox **)calloc(tox_count, sizeof(Tox *)); @@ -119,7 +142,7 @@ static void run_auto_test(uint32_t tox_count, void test(Tox **toxes, State *stat for (uint32_t i = 0; i < tox_count; i++) { state[i].index = i; - toxes[i] = tox_new_log(nullptr, nullptr, &state[i].index); + toxes[i] = tox_new_log(options, nullptr, &state[i].index); ck_assert_msg(toxes[i], "failed to create %u tox instances", i + 1); set_mono_time_callback(toxes[i], &state[i]); @@ -127,15 +150,33 @@ static void run_auto_test(uint32_t tox_count, void test(Tox **toxes, State *stat build_friend_graph(tox_count, chain, toxes); - printf("bootstrapping all toxes off toxes[0]\n"); - uint8_t dht_key[TOX_PUBLIC_KEY_SIZE]; - tox_self_get_dht_id(toxes[0], dht_key); - const uint16_t dht_port = tox_self_get_udp_port(toxes[0], nullptr); + const bool udp_enabled = options != nullptr ? tox_options_get_udp_enabled(options) : true; + Tox_Err_Bootstrap err; + + if (udp_enabled) { + printf("bootstrapping all toxes off toxes[0]\n"); + + uint8_t dht_key[TOX_PUBLIC_KEY_SIZE]; + tox_self_get_dht_id(toxes[0], dht_key); + const uint16_t dht_port = tox_self_get_udp_port(toxes[0], nullptr); + + for (uint32_t i = 1; i < tox_count; i++) { + tox_bootstrap(toxes[i], "localhost", dht_port, dht_key, &err); + ck_assert(err == TOX_ERR_BOOTSTRAP_OK); + } + } else { + printf("bootstrapping all toxes to tcp relays\n"); - for (uint32_t i = 1; i < tox_count; i++) { - Tox_Err_Bootstrap err; - tox_bootstrap(toxes[i], "localhost", dht_port, dht_key, &err); - ck_assert(err == TOX_ERR_BOOTSTRAP_OK); + for (uint32_t i = 0; i < tox_count; ++i) { + // tox_bootstrap(toxes[i], "78.46.73.141", 33445, mainnet_key1, nullptr); + // tox_bootstrap(toxes[i], "tox.initramfs.io", 33445, mainnet_key2, nullptr); + tox_bootstrap(toxes[i], "172.93.52.70", 33445, testnet_tcp_key, nullptr); + + // tox_add_tcp_relay(toxes[i], "78.46.73.141", 33445, mainnet_key1, &err); + // tox_add_tcp_relay(toxes[i], "tox.initramfs.io", 33445, mainnet_key2, &err); + tox_add_tcp_relay(toxes[i], "172.93.52.70", 33445, testnet_tcp_key, &err); + ck_assert_msg(err == TOX_ERR_BOOTSTRAP_OK, "%d", err); + } } wait_friend_connections(tox_count, toxes, state); diff --git a/auto_tests/send_message_test.c b/auto_tests/send_message_test.c index 42c07bdf23..4cacda56ae 100644 --- a/auto_tests/send_message_test.c +++ b/auto_tests/send_message_test.c @@ -57,6 +57,6 @@ int main(void) { setvbuf(stdout, nullptr, _IONBF, 0); - run_auto_test(2, send_message_test, false); + run_auto_test(nullptr, 2, send_message_test, false); return 0; } diff --git a/auto_tests/typing_test.c b/auto_tests/typing_test.c index 6ef3cbd19a..5ea1299b33 100644 --- a/auto_tests/typing_test.c +++ b/auto_tests/typing_test.c @@ -55,6 +55,6 @@ static void test_typing(Tox **toxes, State *state) int main(void) { setvbuf(stdout, nullptr, _IONBF, 0); - run_auto_test(2, test_typing, false); + run_auto_test(nullptr, 2, test_typing, false); return 0; }