Skip to content

Commit

Permalink
fix: test with libsession-util not of libquic
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilb committed Jun 28, 2024
1 parent 0ebfa1d commit 156f340
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 16 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- main
- dev
- groups-chunk-2

concurrency:
group: ${{ github.workflow }}
Expand Down
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion libsession-util
Submodule libsession-util updated 80 files
+1 −1 .clang-format
+3 −1 .drone.jsonnet
+2 −1 .gitignore
+5 −3 .gitmodules
+16 −4 CMakeLists.txt
+25 −3 cmake/AddStaticBundleLib.cmake
+0 −41 cmake/StaticBuild.cmake
+26 −7 external/CMakeLists.txt
+0 −1 external/oxen-encoding
+1 −0 external/oxen-libquic
+33 −0 include/session/blinding.h
+21 −1 include/session/blinding.hpp
+6 −9 include/session/config.hpp
+27 −38 include/session/config/base.h
+56 −31 include/session/config/base.hpp
+0 −1 include/session/config/groups/info.h
+0 −2 include/session/config/groups/keys.hpp
+1 −2 include/session/config/profile_pic.hpp
+2 −1 include/session/config/protos.hpp
+1 −1 include/session/config/user_groups.hpp
+28 −0 include/session/file.hpp
+20 −0 include/session/log_level.h
+68 −0 include/session/logging.h
+107 −0 include/session/logging.hpp
+1 −1 include/session/multi_encrypt.hpp
+304 −0 include/session/network.h
+614 −0 include/session/network.hpp
+27 −40 include/session/onionreq/builder.h
+37 −26 include/session/onionreq/builder.hpp
+3 −0 include/session/onionreq/hop_encryption.hpp
+4 −3 include/session/onionreq/parser.hpp
+5 −0 include/session/onionreq/response_parser.hpp
+15 −0 include/session/platform.h
+11 −0 include/session/platform.hpp
+11 −0 include/session/random.hpp
+231 −0 include/session/sodium_array.hpp
+38 −251 include/session/util.hpp
+4 −0 proto/CMakeLists.txt
+18 −16 src/CMakeLists.txt
+83 −0 src/blinding.cpp
+5 −9 src/config.cpp
+118 −81 src/config/base.cpp
+6 −65 src/config/community.cpp
+18 −21 src/config/contacts.cpp
+77 −89 src/config/convo_info_volatile.cpp
+21 −19 src/config/groups/info.cpp
+148 −116 src/config/groups/keys.cpp
+19 −21 src/config/groups/members.cpp
+1 −1 src/config/internal.cpp
+0 −8 src/config/internal.hpp
+0 −1 src/config/protos.cpp
+46 −58 src/config/user_groups.cpp
+14 −13 src/config/user_profile.cpp
+1 −1 src/ed25519.cpp
+38 −0 src/file.cpp
+6 −1 src/hash.cpp
+98 −0 src/logging.cpp
+3,085 −0 src/network.cpp
+115 −22 src/onionreq/builder.cpp
+16 −4 src/onionreq/hop_encryption.cpp
+15 −7 src/onionreq/response_parser.cpp
+30 −0 src/random.cpp
+1 −1 src/session_encrypt.cpp
+23 −0 src/sodium_array.cpp
+81 −13 src/util.cpp
+22 −4 tests/CMakeLists.txt
+1 −1 tests/catch2_bt_format.hpp
+20 −0 tests/test_blinding.cpp
+1 −4 tests/test_config_convo_info_volatile.cpp
+0 −4 tests/test_config_user_groups.cpp
+2 −13 tests/test_config_userprofile.cpp
+9 −7 tests/test_configdata.cpp
+12 −12 tests/test_group_keys.cpp
+110 −0 tests/test_logging.cpp
+10 −6 tests/test_multi_encrypt.cpp
+584 −0 tests/test_network.cpp
+1 −0 tests/test_onionreq.cpp
+0 −2 utils/android.sh
+1 −2 utils/ios.sh
+0 −2 utils/static-bundle.sh
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"email": "[email protected]"
},
"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"
Expand Down
23 changes: 12 additions & 11 deletions src/base_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Napi::Object>()
.Get("log")
.As<Napi::Function>();
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<Napi::Object>()
// .Get("log")
// .As<Napi::Function>();
// consoleLog.Call({Napi::String::New(env, toLog)});
// };

return config;
});
Expand Down
51 changes: 49 additions & 2 deletions src/groups/meta_group_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,32 @@ namespace session::nodeapi {

MetaGroupWrapper::MetaGroupWrapper(const Napi::CallbackInfo& info) :
meta_group{std::move(MetaBaseWrapper::constructGroupWrapper(info, "MetaGroupWrapper"))},
Napi::ObjectWrap<MetaGroupWrapper>{info} {}
Napi::ObjectWrap<MetaGroupWrapper>{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<Napi::Object>().Get("log").As<Napi::Function>();
// 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<Napi::Object>().Get("log").As<Napi::Function>();
// 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<Napi::Object>().Get("log").As<Napi::Function>();
// consoleLog.Call({Napi::String::New(env, toLog)});
// };
}

void MetaGroupWrapper::Init(Napi::Env env, Napi::Object exports) {
MetaBaseWrapper::NoBaseClassInitHelper<MetaGroupWrapper>(
Expand Down Expand Up @@ -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;
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/user_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 156f340

Please sign in to comment.