From 156f340ae05e1ba94c0bd87c8a63b9d3654c96bb Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Fri, 28 Jun 2024 13:39:17 +1000 Subject: [PATCH] fix: test with libsession-util not of libquic --- .github/workflows/test.yml | 1 + CMakeLists.txt | 14 +++++++++ libsession-util | 2 +- package.json | 2 +- src/base_config.hpp | 23 +++++++------- src/groups/meta_group_wrapper.cpp | 51 +++++++++++++++++++++++++++++-- src/user_config.cpp | 2 +- 7 files changed, 79 insertions(+), 16 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e371f2e..11e6872 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,6 +5,7 @@ on: branches: - main - dev + - groups-chunk-2 concurrency: group: ${{ github.workflow }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c3ba33..bc8cdb9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,20 @@ set(CMAKE_POLICY_DEFAULT_CMP0069 NEW) set(VERBOSE ON) +# Detect the number of processors +include(ProcessorCount) +ProcessorCount(N) + +# Set a default value in case the detection fails +if(NOT N EQUAL 0) + set(CMAKE_BUILD_PARALLEL_LEVEL ${N}) +else() + set(CMAKE_BUILD_PARALLEL_LEVEL 4) # Fallback to 16 if detection fails +endif() +# set(CMAKE_BUILD_PARALLEL_LEVEL 32) +message(STATUS "Number of processors detected: ${N}") + + add_definitions(-DNAPI_VERSION=8) set(CMAKE_CONFIGURATION_TYPES Release) diff --git a/libsession-util b/libsession-util index 20c0667..47b6920 160000 --- a/libsession-util +++ b/libsession-util @@ -1 +1 @@ -Subproject commit 20c06674d85369c2d12261582dd36a9f21504233 +Subproject commit 47b6920c5c0862bac39180ac95bf11981ba0bdb5 diff --git a/package.json b/package.json index ac5073e..ee5391b 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "email": "team@oxen.io" }, "scripts": { - "install": "cmake-js compile --runtime=electron --runtime-version=25.8.4 -p16 --CDSUBMODULE_CHECK=OFF --CDLOCAL_MIRROR=https://oxen.rocks/deps --CDENABLE_ONIONREQ=OFF" + "install": "cmake-js compile --runtime=electron --runtime-version=25.8.4 --CDLOCAL_MIRROR=https://oxen.rocks/deps --CDENABLE_ONIONREQ=OFF" }, "devDependencies": { "clang-format": "^1.8.0" diff --git a/src/base_config.hpp b/src/base_config.hpp index 6eeebdb..5119cb2 100644 --- a/src/base_config.hpp +++ b/src/base_config.hpp @@ -106,17 +106,18 @@ class ConfigBaseImpl { Napi::Env env = info.Env(); - config->logger = [env, class_name](session::config::LogLevel, std::string_view x) { - std::string toLog = - "libsession-util:" + std::string(class_name) + ": " + std::string(x) + "\n"; - - Napi::Function consoleLog = env.Global() - .Get("console") - .As() - .Get("log") - .As(); - consoleLog.Call({Napi::String::New(env, toLog)}); - }; + // config->logger = [env, class_name](session::config::LogLevel, std::string_view x) { + // std::string toLog = + // "libsession-util:" + std::string(class_name) + ": " + std::string(x) + + // "\n"; + + // Napi::Function consoleLog = env.Global() + // .Get("console") + // .As() + // .Get("log") + // .As(); + // consoleLog.Call({Napi::String::New(env, toLog)}); + // }; return config; }); diff --git a/src/groups/meta_group_wrapper.cpp b/src/groups/meta_group_wrapper.cpp index b35c766..fee8087 100644 --- a/src/groups/meta_group_wrapper.cpp +++ b/src/groups/meta_group_wrapper.cpp @@ -11,7 +11,32 @@ namespace session::nodeapi { MetaGroupWrapper::MetaGroupWrapper(const Napi::CallbackInfo& info) : meta_group{std::move(MetaBaseWrapper::constructGroupWrapper(info, "MetaGroupWrapper"))}, - Napi::ObjectWrap{info} {} + Napi::ObjectWrap{info} { + auto env = info.Env(); + // this->meta_group->members->logger = [env](session::config::LogLevel, std::string_view x) { + // std::string toLog = "libsession-util:MetaGroup:Member: " + std::string(x) + "\n"; + + // Napi::Function consoleLog = + // env.Global().Get("console").As().Get("log").As(); + // consoleLog.Call({Napi::String::New(env, toLog)}); + // }; + // this->meta_group->info->logger = [env](session::config::LogLevel, std::string_view x) { + // std::string toLog = "libsession-util:MetaGroup:Info: " + std::string(x) + "\n"; + + // Napi::Function consoleLog = + // env.Global().Get("console").As().Get("log").As(); + // consoleLog.Call({Napi::String::New(env, toLog)}); + // }; + // this->meta_group->keys->logger = [env]( + // session::config::LogLevel, + // std::string_view x) { + // std::string toLog = "libsession-util:MetaGroup:Keys: " + std::string(x) + "\n"; + + // Napi::Function consoleLog = + // env.Global().Get("console").As().Get("log").As(); + // consoleLog.Call({Napi::String::New(env, toLog)}); + // }; +} void MetaGroupWrapper::Init(Napi::Env env, Napi::Object exports) { MetaBaseWrapper::NoBaseClassInitHelper( @@ -445,9 +470,31 @@ Napi::Value MetaGroupWrapper::memberSetInvited(const Napi::CallbackInfo& info) { auto pubkeyHex = toCppString(info[0], __PRETTY_FUNCTION__); auto failed = toCppBoolean(info[1], __PRETTY_FUNCTION__); auto m = this->meta_group->members->get_or_construct(pubkeyHex); + + // this->meta_group->members->log( + // session::config::LogLevel::warning, + // "libsession-util before: needsDump? " + + // std::string(this->needsDump(info) ? "true" : "false")); + // this->meta_group->members->log( + // session::config::LogLevel::warning, + // "libsession-util before: invite_failed of " + std::string(pubkeyHex) + + // " val: " + std::string(m.invite_failed() ? "true" : "false")); m.set_invited(failed); this->meta_group->members->set(m); - return this->meta_group->members->get_or_construct(m.session_id); + // this->meta_group->members->log( + // session::config::LogLevel::warning, + // "libsession-util after: invite_failed of " + std::string(pubkeyHex) + + // " val: " + std::string(m.invite_failed() ? "true" : "false")); + auto refreshed = this->meta_group->members->get_or_construct(m.session_id); + // this->meta_group->members->log( + // session::config::LogLevel::warning, + // "libsession-util refreshed: invite_failed of " + std::string(pubkeyHex) + + // " val: " + std::string(refreshed.invite_failed() ? "true" : "false")); + // this->meta_group->members->log( + // session::config::LogLevel::warning, + // "libsession-util after: needsDump? of " + + // std::string(this->needsDump(info) ? "true" : "false")); + return refreshed; }); } diff --git a/src/user_config.cpp b/src/user_config.cpp index 600eea5..4508ead 100644 --- a/src/user_config.cpp +++ b/src/user_config.cpp @@ -9,7 +9,7 @@ namespace session::nodeapi { -using config::LogLevel; +// using config::LogLevel; using config::UserProfile; void UserConfigWrapper::Init(Napi::Env env, Napi::Object exports) {