From a8d8613f2ccb56054dfc01768f4e86964077ff55 Mon Sep 17 00:00:00 2001 From: Green Sky Date: Fri, 8 Mar 2024 10:50:58 +0100 Subject: [PATCH] adopt to new toxcore master --- external/solanaceae_tox | 2 +- external/solanaceae_toxcore | 2 +- external/toxcore/CMakeLists.txt | 8 +- external/toxcore/mono_time_test.cc | 138 ----------------------------- src/tox_client.cpp | 3 + 5 files changed, 8 insertions(+), 145 deletions(-) delete mode 100644 external/toxcore/mono_time_test.cc diff --git a/external/solanaceae_tox b/external/solanaceae_tox index eeb57e1..4bd7235 160000 --- a/external/solanaceae_tox +++ b/external/solanaceae_tox @@ -1 +1 @@ -Subproject commit eeb57e137d08798bb08dc8de1f69abcabf0e0611 +Subproject commit 4bd7235a739dec020365d216509474f641029113 diff --git a/external/solanaceae_toxcore b/external/solanaceae_toxcore index fa4298d..49ab40a 160000 --- a/external/solanaceae_toxcore +++ b/external/solanaceae_toxcore @@ -1 +1 @@ -Subproject commit fa4298d790b2a2adf19435239b96664cc40a09a8 +Subproject commit 49ab40a1ba97e884bf43ab5f35cfb48fc51f91de diff --git a/external/toxcore/CMakeLists.txt b/external/toxcore/CMakeLists.txt index e1ace73..4887bb2 100644 --- a/external/toxcore/CMakeLists.txt +++ b/external/toxcore/CMakeLists.txt @@ -19,6 +19,8 @@ add_library(toxcore STATIC ${TOX_DIR}toxcore/ccompat.h ${TOX_DIR}toxcore/crypto_core.c ${TOX_DIR}toxcore/crypto_core.h + ${TOX_DIR}toxcore/crypto_core_pack.c + ${TOX_DIR}toxcore/crypto_core_pack.h ${TOX_DIR}toxcore/DHT.c ${TOX_DIR}toxcore/DHT.h ${TOX_DIR}toxcore/events/conference_connected.c @@ -27,6 +29,7 @@ add_library(toxcore STATIC ${TOX_DIR}toxcore/events/conference_peer_list_changed.c ${TOX_DIR}toxcore/events/conference_peer_name.c ${TOX_DIR}toxcore/events/conference_title.c + ${TOX_DIR}toxcore/events/dht_get_nodes_response.c ${TOX_DIR}toxcore/events/events_alloc.c ${TOX_DIR}toxcore/events/events_alloc.h ${TOX_DIR}toxcore/events/file_chunk_request.c @@ -209,8 +212,3 @@ add_executable(DHT_Bootstrap EXCLUDE_FROM_ALL ) target_link_libraries(DHT_Bootstrap toxcore) -add_executable(mono_time_test - ./mono_time_test.cc -) -target_link_libraries(mono_time_test toxcore) -target_compile_features(mono_time_test PUBLIC cxx_std_11) diff --git a/external/toxcore/mono_time_test.cc b/external/toxcore/mono_time_test.cc deleted file mode 100644 index d0afb4e..0000000 --- a/external/toxcore/mono_time_test.cc +++ /dev/null @@ -1,138 +0,0 @@ -#include "./c-toxcore/toxcore/mono_time.h" - -#ifdef NDEBUG - #undef NDEBUG - #include -#else - #include -#endif - -#include -#include -#include - -#define TEST(x, y) bool run_test_##x##y(void) - -#define ASSERT_NE(x, y) assert((x) != (y)) -#define EXPECT_GT(x, y) assert((x) > (y)) -#define EXPECT_FALSE(x) assert(!(x)) -#define EXPECT_TRUE(x) assert((x)) -#define EXPECT_EQ(x, y) assert((x) == (y)) - -TEST(MonoTime, UnixTimeIncreasesOverTime) -{ - const Memory *mem = system_memory(); - Mono_Time *mono_time = mono_time_new(mem, nullptr, nullptr); - ASSERT_NE(mono_time, nullptr); - - mono_time_update(mono_time); - uint64_t const start = mono_time_get(mono_time); - - while (start == mono_time_get(mono_time)) { - mono_time_update(mono_time); - } - - uint64_t const end = mono_time_get(mono_time); - EXPECT_GT(end, start); - - mono_time_free(mem, mono_time); - - return true; -} - -TEST(MonoTime, IsTimeout) -{ - const Memory *mem = system_memory(); - Mono_Time *mono_time = mono_time_new(mem, nullptr, nullptr); - ASSERT_NE(mono_time, nullptr); - - uint64_t const start = mono_time_get(mono_time); - EXPECT_FALSE(mono_time_is_timeout(mono_time, start, 1)); - - while (start == mono_time_get(mono_time)) { - mono_time_update(mono_time); - } - - EXPECT_TRUE(mono_time_is_timeout(mono_time, start, 1)); - - mono_time_free(mem, mono_time); - - return true; -} - -TEST(MonoTime, IsTimeoutReal) -{ - const Memory *mem = system_memory(); - Mono_Time *mono_time = mono_time_new(mem, nullptr, nullptr); - ASSERT_NE(mono_time, nullptr); - - uint64_t const start = mono_time_get(mono_time); - EXPECT_FALSE(mono_time_is_timeout(mono_time, start, 5)); - - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - mono_time_update(mono_time); - - // should still not have timed out (5sec) after sleeping ~20ms - EXPECT_FALSE(mono_time_is_timeout(mono_time, start, 5)); - - mono_time_free(mem, mono_time); - - return true; -} - -TEST(MonoTime, CustomTime) -{ - const Memory *mem = system_memory(); - Mono_Time *mono_time = mono_time_new(mem, nullptr, nullptr); - ASSERT_NE(mono_time, nullptr); - - uint64_t test_time = current_time_monotonic(mono_time) + 42137; - - mono_time_set_current_time_callback( - mono_time, [](void *user_data) { return *static_cast(user_data); }, &test_time); - mono_time_update(mono_time); - - EXPECT_EQ(current_time_monotonic(mono_time), test_time); - - uint64_t const start = mono_time_get(mono_time); - - test_time += 7000; - - mono_time_update(mono_time); - EXPECT_EQ(mono_time_get(mono_time) - start, 7); - - EXPECT_EQ(current_time_monotonic(mono_time), test_time); - - mono_time_free(mem, mono_time); - - return true; -} - -int main(int argc, char **argv) { - if (!run_test_MonoTimeUnixTimeIncreasesOverTime()) { - std::cerr << "MonoTimeUnixTimeIncreasesOverTime() failed\n"; - return -1; - } - std::cerr << "MonoTimeUnixTimeIncreasesOverTime() succeeded\n"; - - if (!run_test_MonoTimeIsTimeout()) { - std::cerr << "MonoTimeIsTimeout() failed\n"; - return -1; - } - std::cerr << "MonoTimeIsTimeout() succeeded\n"; - - if (!run_test_MonoTimeIsTimeoutReal()) { - std::cerr << "MonoTimeIsTimeoutReal() failed\n"; - return -1; - } - std::cerr << "MonoTimeIsTimeoutReal() succeeded\n"; - - if (!run_test_MonoTimeCustomTime()) { - std::cerr << "MonoTimeCustomTime() failed\n"; - return -1; - } - std::cerr << "MonoTimeCustomTime() succeeded\n"; - - return 0; -} - diff --git a/src/tox_client.cpp b/src/tox_client.cpp index e015a1d..7d62877 100644 --- a/src/tox_client.cpp +++ b/src/tox_client.cpp @@ -1,4 +1,5 @@ #include "./tox_client.hpp" +#include "toxcore/tox.h" // meh, change this #include @@ -67,6 +68,8 @@ ToxClient::ToxClient(std::string_view save_path, std::string_view save_password) } } + tox_options_set_experimental_groups_persistence(options, true); + TOX_ERR_NEW err_new; _tox = tox_new(options, &err_new); tox_options_free(options);