From 240cbd100e2d288936086d3dac39a690e4af18b3 Mon Sep 17 00:00:00 2001 From: SChernykh <15806605+SChernykh@users.noreply.github.com> Date: Sat, 26 Jul 2025 12:17:04 +0200 Subject: [PATCH] Removed unused code from tests, tweaked build scripts --- .github/workflows/c-cpp.yml | 2 +- scripts/release/build_all.sh | 22 +++++++++------ scripts/release/freebsd_aarch64/build.sh | 2 +- scripts/release/freebsd_x64/build.sh | 2 +- scripts/release/linux_aarch64/build.sh | 2 +- scripts/release/linux_riscv64/build.sh | 2 +- scripts/release/linux_x64/build.sh | 2 +- scripts/release/macos_aarch64/build.sh | 2 +- scripts/release/macos_x64/build.sh | 2 +- scripts/release/source/build.sh | 2 +- scripts/release/windows_x64/build.sh | 2 +- src/util.cpp | 7 +++++ tests/CMakeLists.txt | 35 +----------------------- tests/src/main.cpp | 12 ++++++++ 14 files changed, 43 insertions(+), 53 deletions(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 6fe4858..b2fa088 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -13,7 +13,7 @@ on: jobs: build-alpine-static: - timeout-minutes: 60 + timeout-minutes: 90 runs-on: ubuntu-latest strategy: diff --git a/scripts/release/build_all.sh b/scripts/release/build_all.sh index b4c74b5..9ce1309 100755 --- a/scripts/release/build_all.sh +++ b/scripts/release/build_all.sh @@ -11,12 +11,16 @@ if [ $? -ne 0 ]; then images/ubuntu/build.sh fi -gnome-terminal --tab -- freebsd_aarch64/build.sh $1 -gnome-terminal --tab -- freebsd_x64/build.sh $1 -gnome-terminal --tab -- linux_aarch64/build.sh $1 -gnome-terminal --tab -- linux_riscv64/build.sh $1 -gnome-terminal --tab -- linux_x64/build.sh $1 -gnome-terminal --tab -- windows_x64/build.sh $1 -gnome-terminal --tab -- macos_aarch64/build.sh $1 -gnome-terminal --tab -- macos_x64/build.sh $1 -gnome-terminal --tab -- source/build.sh $1 +N=$(($(nproc)-1)) +N1=$(($N/2)) +N2=$(($N1+1)) + +gnome-terminal --tab -- freebsd_aarch64/build.sh $1 0-$N1 +gnome-terminal --tab -- freebsd_x64/build.sh $1 $N2-$N +gnome-terminal --tab -- linux_aarch64/build.sh $1 0-$N1 +gnome-terminal --tab -- linux_riscv64/build.sh $1 $N2-$N +gnome-terminal --tab -- linux_x64/build.sh $1 0-$N1 +gnome-terminal --tab -- windows_x64/build.sh $1 $N2-$N +gnome-terminal --tab -- macos_aarch64/build.sh $1 0-$N1 +gnome-terminal --tab -- macos_x64/build.sh $1 $N2-$N +gnome-terminal --tab -- source/build.sh $1 0-$N1 diff --git a/scripts/release/freebsd_aarch64/build.sh b/scripts/release/freebsd_aarch64/build.sh index c4778aa..0a4cb07 100755 --- a/scripts/release/freebsd_aarch64/build.sh +++ b/scripts/release/freebsd_aarch64/build.sh @@ -4,7 +4,7 @@ cd "$(dirname "$0")" -docker build --build-arg P2POOL_VERSION=$1 -t p2pool_freebsd_aarch64_build_$1 . +docker build --cpuset-cpus $2 --build-arg P2POOL_VERSION=$1 -t p2pool_freebsd_aarch64_build_$1 . docker create --name p2pool_freebsd_aarch64_build_$1_container p2pool_freebsd_aarch64_build_$1:latest docker cp p2pool_freebsd_aarch64_build_$1_container:/p2pool/build/p2pool-$1-freebsd-aarch64.tar.gz ../p2pool-$1-freebsd-aarch64.tar.gz diff --git a/scripts/release/freebsd_x64/build.sh b/scripts/release/freebsd_x64/build.sh index 5826277..49480df 100755 --- a/scripts/release/freebsd_x64/build.sh +++ b/scripts/release/freebsd_x64/build.sh @@ -4,7 +4,7 @@ cd "$(dirname "$0")" -docker build --build-arg P2POOL_VERSION=$1 -t p2pool_freebsd_x64_build_$1 . +docker build --cpuset-cpus $2 --build-arg P2POOL_VERSION=$1 -t p2pool_freebsd_x64_build_$1 . docker create --name p2pool_freebsd_x64_build_$1_container p2pool_freebsd_x64_build_$1:latest docker cp p2pool_freebsd_x64_build_$1_container:/p2pool/build/p2pool-$1-freebsd-x64.tar.gz ../p2pool-$1-freebsd-x64.tar.gz diff --git a/scripts/release/linux_aarch64/build.sh b/scripts/release/linux_aarch64/build.sh index ed8d66b..f54619b 100755 --- a/scripts/release/linux_aarch64/build.sh +++ b/scripts/release/linux_aarch64/build.sh @@ -4,7 +4,7 @@ cd "$(dirname "$0")" -docker build --build-arg P2POOL_VERSION=$1 -t p2pool_ubuntu_aarch64_build_$1 . +docker build --cpuset-cpus $2 --build-arg P2POOL_VERSION=$1 -t p2pool_ubuntu_aarch64_build_$1 . docker create --name p2pool_ubuntu_aarch64_build_$1_container p2pool_ubuntu_aarch64_build_$1:latest docker cp p2pool_ubuntu_aarch64_build_$1_container:/p2pool/build/p2pool-$1-linux-aarch64.tar.gz ../p2pool-$1-linux-aarch64.tar.gz diff --git a/scripts/release/linux_riscv64/build.sh b/scripts/release/linux_riscv64/build.sh index e47e165..5470bc2 100755 --- a/scripts/release/linux_riscv64/build.sh +++ b/scripts/release/linux_riscv64/build.sh @@ -4,7 +4,7 @@ cd "$(dirname "$0")" -docker build --build-arg P2POOL_VERSION=$1 -t p2pool_ubuntu_riscv64_build_$1 . +docker build --cpuset-cpus $2 --build-arg P2POOL_VERSION=$1 -t p2pool_ubuntu_riscv64_build_$1 . docker create --name p2pool_ubuntu_riscv64_build_$1_container p2pool_ubuntu_riscv64_build_$1:latest docker cp p2pool_ubuntu_riscv64_build_$1_container:/p2pool/build/p2pool-$1-linux-riscv64.tar.gz ../p2pool-$1-linux-riscv64.tar.gz diff --git a/scripts/release/linux_x64/build.sh b/scripts/release/linux_x64/build.sh index 5503a6f..670d5a0 100755 --- a/scripts/release/linux_x64/build.sh +++ b/scripts/release/linux_x64/build.sh @@ -4,7 +4,7 @@ cd "$(dirname "$0")" -docker build --build-arg P2POOL_VERSION=$1 -t p2pool_linux_x64_build_$1 . +docker build --cpuset-cpus $2 --build-arg P2POOL_VERSION=$1 -t p2pool_linux_x64_build_$1 . docker create --name p2pool_linux_x64_build_$1_container p2pool_linux_x64_build_$1:latest docker cp p2pool_linux_x64_build_$1_container:/p2pool/build/p2pool-$1-linux-x64.tar.gz ../p2pool-$1-linux-x64.tar.gz diff --git a/scripts/release/macos_aarch64/build.sh b/scripts/release/macos_aarch64/build.sh index 4e874c9..0244d1e 100755 --- a/scripts/release/macos_aarch64/build.sh +++ b/scripts/release/macos_aarch64/build.sh @@ -4,7 +4,7 @@ cd "$(dirname "$0")" -docker build --build-arg P2POOL_VERSION=$1 -t p2pool_macos_aarch64_build_$1 . +docker build --cpuset-cpus $2 --build-arg P2POOL_VERSION=$1 -t p2pool_macos_aarch64_build_$1 . docker create --name p2pool_macos_aarch64_build_$1_container p2pool_macos_aarch64_build_$1:latest docker cp p2pool_macos_aarch64_build_$1_container:/p2pool/build/p2pool-$1-macos-aarch64.tar.gz ../p2pool-$1-macos-aarch64.tar.gz diff --git a/scripts/release/macos_x64/build.sh b/scripts/release/macos_x64/build.sh index a36fbf2..9bfbbff 100755 --- a/scripts/release/macos_x64/build.sh +++ b/scripts/release/macos_x64/build.sh @@ -4,7 +4,7 @@ cd "$(dirname "$0")" -docker build --build-arg P2POOL_VERSION=$1 -t p2pool_macos_x64_build_$1 . +docker build --cpuset-cpus $2 --build-arg P2POOL_VERSION=$1 -t p2pool_macos_x64_build_$1 . docker create --name p2pool_macos_x64_build_$1_container p2pool_macos_x64_build_$1:latest docker cp p2pool_macos_x64_build_$1_container:/p2pool/build/p2pool-$1-macos-x64.tar.gz ../p2pool-$1-macos-x64.tar.gz diff --git a/scripts/release/source/build.sh b/scripts/release/source/build.sh index b39fd93..9ad2593 100755 --- a/scripts/release/source/build.sh +++ b/scripts/release/source/build.sh @@ -4,7 +4,7 @@ cd "$(dirname "$0")" -docker build --build-arg P2POOL_VERSION=$1 -t p2pool_source_build_$1 . +docker build --cpuset-cpus $2 --build-arg P2POOL_VERSION=$1 -t p2pool_source_build_$1 . docker create --name p2pool_source_build_$1_container p2pool_source_build_$1:latest docker cp p2pool_source_build_$1_container:/p2pool_source-$1.tar.xz ../p2pool_source-$1.tar.xz diff --git a/scripts/release/windows_x64/build.sh b/scripts/release/windows_x64/build.sh index 93a0073..be0da4b 100755 --- a/scripts/release/windows_x64/build.sh +++ b/scripts/release/windows_x64/build.sh @@ -4,7 +4,7 @@ cd "$(dirname "$0")" -docker build --build-arg P2POOL_VERSION=$1 -t p2pool_windows_x64_build_$1 . +docker build --cpuset-cpus $2 --build-arg P2POOL_VERSION=$1 -t p2pool_windows_x64_build_$1 . docker create --name p2pool_windows_x64_build_$1_container p2pool_windows_x64_build_$1:latest docker cp p2pool_windows_x64_build_$1_container:/p2pool/build/p2pool-$1-windows-x64.zip ../p2pool-$1-windows-x64.zip diff --git a/src/util.cpp b/src/util.cpp index 3cd58de..7e80b3b 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -40,7 +40,10 @@ #include #endif +#ifndef P2POOL_UNIT_TESTS #include +#endif + #include #ifdef HAVE_GLIBC @@ -75,7 +78,9 @@ const char* VERSION = "v" STR2(P2POOL_VERSION_MAJOR) "." STR2(P2POOL_VERSION_MIN std::string p2pool_version() { +#ifndef P2POOL_UNIT_TESTS const curl_version_info_data* curl_version_data = curl_version_info(CURLVERSION_NOW); +#endif int zmq_major, zmq_minor, zmq_patch; zmq_version(&zmq_major, &zmq_minor, &zmq_patch); @@ -91,7 +96,9 @@ std::string p2pool_version() #ifdef WITH_GRPC << " - grpc " << GRPC_CPP_VERSION_STRING << '\n' #endif +#ifndef P2POOL_UNIT_TESTS << " - libcurl " << (curl_version_data ? curl_version_data->version : "unknown") << '\n' +#endif << " - libuv " << uv_version_string() << '\n' << " - libzmq " << zmq_major << '.' << zmq_minor << '.' << zmq_patch << '\n' #ifdef WITH_UPNP diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 59bf471..d1424ff 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -36,11 +36,6 @@ else() endif() add_definitions(-DWITH_RANDOMX) - -add_subdirectory(cmake/ssl) -include_directories(../external/src/grpc/third_party/boringssl-with-bazel/src/include) -add_definitions(-DWITH_TLS) - add_definitions(-DWITH_MERGE_MINING_DONATION) add_definitions(-DP2POOL_UNIT_TESTS) @@ -72,13 +67,10 @@ set(SOURCES ../src/block_template.cpp ../src/console_commands.cpp ../src/crypto.cpp - ../src/json_rpc_request.cpp ../src/keccak.cpp ../src/log.cpp ../src/memory_leak_debug.cpp ../src/mempool.cpp - ../src/merge_mining_client.cpp - ../src/merge_mining_client_json_rpc.cpp ../src/merkle.cpp ../src/miner.cpp ../src/p2p_server.cpp @@ -90,7 +82,6 @@ set(SOURCES ../src/side_chain.cpp ../src/stratum_server.cpp ../src/tcp_server.cpp - ../src/tls.cpp ../src/util.cpp ../src/wallet.cpp ../src/zmq_reader.cpp @@ -103,16 +94,6 @@ if (AMD64) endif() endif() -if (NOT ((CMAKE_CXX_COMPILER_ID MATCHES MSVC) OR STATIC_BINARY OR STATIC_LIBS)) - include(FindCURL) -endif() - -if (CURL_INCLUDE_DIRS) - include_directories(${CURL_INCLUDE_DIRS}) -else() - include_directories(../external/src/curl/include) -endif() - if ((CMAKE_CXX_COMPILER_ID MATCHES MSVC) OR STATIC_BINARY OR STATIC_LIBS) set(UV_INCLUDE_DIR ../external/src/libuv/include) set(ZMQ_INCLUDE_DIR ../external/src/libzmq/include) @@ -140,7 +121,6 @@ if (WIN32) if ((CMAKE_CXX_COMPILER_ID MATCHES GNU) OR (CMAKE_CXX_COMPILER_ID MATCHES Clang)) set(LIBS ${LIBS} bcrypt) endif() - add_definitions(-DCURL_STATICLIB) elseif (NOT APPLE) set(LIBS ${LIBS} pthread) endif() @@ -150,24 +130,13 @@ if (STATIC_LIBS) set(ZMQ_LIBRARY_DEBUG "${CMAKE_SOURCE_DIR}/../external/src/libzmq/build/lib/libzmq.a") set(UV_LIBRARY_DEBUG "${CMAKE_SOURCE_DIR}/../external/src/libuv/build/libuv.a") set(UV_LIBRARY "${CMAKE_SOURCE_DIR}/../external/src/libuv/build/libuv.a") - set(CURL_LIBRARY_DEBUG "${CMAKE_SOURCE_DIR}/../external/src/curl/lib/.libs/libcurl.a") - set(CURL_LIBRARY "${CMAKE_SOURCE_DIR}/../external/src/curl/lib/.libs/libcurl.a") else() if (CMAKE_CXX_COMPILER_ID MATCHES MSVC) - find_library(CURL_LIBRARY_DEBUG NAMES libcurl-d PATHS "../external/lib/libcurl_tls/Debug") - find_library(CURL_LIBRARY NAMES libcurl PATHS "../external/lib/libcurl_tls/Release") elseif (CMAKE_CXX_COMPILER_ID MATCHES GNU OR CMAKE_CXX_COMPILER_ID MATCHES Clang) find_library(ZMQ_LIBRARY_DEBUG NAMES zmq libzmq.a) find_library(ZMQ_LIBRARY NAMES zmq libzmq.a) find_library(UV_LIBRARY_DEBUG NAMES uv libuv.a) find_library(UV_LIBRARY NAMES uv libuv.a) - if (WIN32) - find_library(CURL_LIBRARY_DEBUG NAMES libcurl.a PATHS "../external/src/curl/lib/.libs" NO_DEFAULT_PATH) - find_library(CURL_LIBRARY NAMES libcurl.a PATHS "../external/src/curl/lib/.libs" NO_DEFAULT_PATH) - else() - find_library(CURL_LIBRARY_DEBUG NAMES curl) - find_library(CURL_LIBRARY NAMES curl) - endif() find_library(SODIUM_LIBRARY sodium) endif() @@ -194,8 +163,6 @@ if(APPLE) set(LIBS ${LIBS} ${FOUNDATION_LIB} ${CORE_FOUNDATION_LIB} ${SYSTEM_CONFIGURATION_LIB}) endif() -set(LIBS ${LIBS} ssl crypto) - add_definitions(/DZMQ_STATIC /DP2POOL_LOG_DISABLE) include(CheckCXXSourceCompiles) @@ -214,7 +181,7 @@ endif() add_definitions("-DRAPIDJSON_PARSE_DEFAULT_FLAGS=kParseTrailingCommasFlag") add_executable(${CMAKE_PROJECT_NAME} ${HEADERS} ${SOURCES}) -target_link_libraries(${CMAKE_PROJECT_NAME} debug ${ZMQ_LIBRARY_DEBUG} debug ${UV_LIBRARY_DEBUG} debug ${CURL_LIBRARY_DEBUG} optimized ${ZMQ_LIBRARY} optimized ${UV_LIBRARY} optimized ${CURL_LIBRARY} ${LIBS}) +target_link_libraries(${CMAKE_PROJECT_NAME} debug ${ZMQ_LIBRARY_DEBUG} debug ${UV_LIBRARY_DEBUG} optimized ${ZMQ_LIBRARY} optimized ${UV_LIBRARY} ${LIBS}) add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/src/crypto_tests.txt" $) add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/src/block.dat" $) add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/src/sidechain_dump.dat.xz" $) diff --git a/tests/src/main.cpp b/tests/src/main.cpp index ba79e30..7d89ca4 100644 --- a/tests/src/main.cpp +++ b/tests/src/main.cpp @@ -18,11 +18,23 @@ #include "common.h" #include "util.h" #include "pool_block.h" +#include "json_rpc_request.h" +#include "merge_mining_client.h" #include "gtest/gtest.h" void p2pool_usage() {} +namespace p2pool { + +IMergeMiningClient* IMergeMiningClient::create(p2pool*, const std::string&, const std::string&) noexcept { return nullptr; } + +namespace JSONRPCRequest { + void Call(const std::string&, int, const std::string&, const std::string&, const std::string&, bool, const std::string&, CallbackBase*, CallbackBase*, uv_loop_t*) {} +} + +} + using namespace p2pool; int main(int argc, char** argv)