Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .github/workflows/artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ jobs:
if: contains(matrix.os, 'macos')
run: |
brew install ccache boost pkgconf qt@6 qrencode coreutils llvm
if [ "${BUILD_APP_TESTS}" = "ON" ]; then
brew install googletest
fi
llvm_prefix="$(brew --prefix llvm)"
echo "CC=${llvm_prefix}/bin/clang" >> "$GITHUB_ENV"
echo "CXX=${llvm_prefix}/bin/clang++" >> "$GITHUB_ENV"
Expand All @@ -48,9 +45,6 @@ jobs:
libboost-dev libsqlite3-dev libgl-dev libqrencode-dev \
qt6-base-dev qt6-tools-dev qt6-l10n-tools qt6-tools-dev-tools \
qt6-declarative-dev qml6-module-qt-labs-settings qml6-module-qtquick qml6-module-qtquick-controls qml6-module-qtquick-dialogs qml6-module-qtquick-layouts qml6-module-qtquick-templates qml6-module-qtqml
if [ "${BUILD_APP_TESTS}" = "ON" ]; then
sudo apt-get install -y libgtest-dev libgmock-dev
fi
echo "CCACHE_DIR=${{ runner.temp }}/ccache" >> "$GITHUB_ENV"

- name: Restore Ccache cache
Expand Down
8 changes: 0 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,6 @@ jobs:
libgl-dev \
libqrencode-dev

- name: Install test dependencies
if: env.BUILD_APP_TESTS == 'ON'
run: |
sudo apt-get update
sudo apt-get install -y \
libgtest-dev \
libgmock-dev

- name: Configure (CMake)
run: |
cmake -S . -B build -G Ninja \
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/depends-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,18 @@ jobs:
cmake -S . -B "${BUILD_DIR}" -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE="${PWD}/bitcoin/depends/${HOST}/toolchain.cmake" \
-DBUILD_APP_TESTS=OFF \
-DBUILD_APP_TESTS=ON \
-DBUILD_GUI=ON \
-DENABLE_WALLET=ON \
-DENABLE_IPC=OFF

- name: Build bitcoin-core-app
- name: Build
run: |
cmake --build "${BUILD_DIR}" --target bitcoin-core-app --parallel "${JOBS}"
cmake --build "${BUILD_DIR}" --parallel "${JOBS}"

- name: Run app tests
run: |
ctest --test-dir "${BUILD_DIR}" --output-on-failure --parallel "${JOBS}"

- name: Upload depends logs
uses: actions/upload-artifact@v4
Expand Down
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ project(BitcoinCoreApp
LANGUAGES CXX
)

include(CMakeDependentOption)

# Language setup
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT CMAKE_HOST_APPLE)
# We do not use the install_name_tool when cross-compiling for macOS.
Expand Down Expand Up @@ -53,6 +55,7 @@ set(USE_QRCODE TRUE)
# We need this libraries, can ignore the executable bitcoin-qt
set(BUILD_GUI ON)
set(ENABLE_WALLET ON)
cmake_dependent_option(BUILD_APP_TESTS "Build tests for the app" ON "BUILD_GUI" OFF)

# Bitcoin Core codebase
# Builds libraries: univalue, core_interface, bitcoin_node, bitcoin_wallet
Expand Down Expand Up @@ -193,7 +196,6 @@ target_link_libraries(bitcoin-core-app
)
qt6_import_qml_plugins(bitcoin-core-app)

option(BUILD_APP_TESTS "Build unit tests for the app" OFF)
if(BUILD_APP_TESTS)
include(CTest)
enable_testing()
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ In addition the following dependencies are required for the GUI and tests:

```
sudo apt install \
libgmock-dev \
libgtest-dev \
qt6-base-dev \
qt6-base-dev-tools \
qt6-tools-dev \
Expand Down
26 changes: 17 additions & 9 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,9 @@ cmake_minimum_required(VERSION 3.22)
# Tests for the QML/Qt6 app

find_package(Qt 6.2 MODULE REQUIRED COMPONENTS Core Gui Network Test Qml Quick QuickTest Widgets)
find_package(GTest REQUIRED)

if(NOT TARGET GTest::gmock)
message(FATAL_ERROR "GTest::gmock target is required for app unit tests. Ensure gmock is installed and exported by the active GTest package.")
endif()

add_executable(bitcoinqml_unit_tests
test_unit_tests_main.cpp
gmocktestfixture.h
test_bitcoinaddress.cpp
test_blockclockdial.cpp
test_bitcoinuri.cpp
Expand Down Expand Up @@ -70,7 +64,6 @@ target_link_libraries(bitcoinqml_unit_tests
bitcoin_common
bitcoin_util
bitcoin_node
GTest::gmock
Qt6::Core
Qt6::Gui
Qt6::Quick
Expand All @@ -79,7 +72,7 @@ target_link_libraries(bitcoinqml_unit_tests
Qt6::Widgets
)

add_test(NAME bitcoinqml_unit_tests COMMAND bitcoinqml_unit_tests -platform offscreen)
add_test(NAME bitcoinqml_unit_tests COMMAND bitcoinqml_unit_tests -platform minimal)

qt6_add_resources(QMLTESTS_QRC_CPP ${QML_QRC} qml/bitcoin_qmltests.qrc)

Expand Down Expand Up @@ -110,4 +103,19 @@ target_include_directories(bitcoinqml_qmltests
${CMAKE_CURRENT_SOURCE_DIR}/..
)

add_test(NAME bitcoinqml_qmltests COMMAND bitcoinqml_qmltests -platform offscreen)
add_test(NAME bitcoinqml_qmltests COMMAND bitcoinqml_qmltests -platform minimal)

get_target_property(qt_lib_type Qt6::Core TYPE)
if(qt_lib_type STREQUAL "STATIC_LIBRARY")
qt6_import_plugins(bitcoinqml_unit_tests INCLUDE Qt6::QMinimalIntegrationPlugin)
qt6_import_plugins(bitcoinqml_qmltests INCLUDE Qt6::QMinimalIntegrationPlugin)
qt6_import_qml_plugins(bitcoinqml_qmltests)
target_link_libraries(bitcoinqml_qmltests PRIVATE
Qt6::qtquickdialogsplugin
)
if(Qt6_VERSION VERSION_GREATER_EQUAL 6.5)
target_link_libraries(bitcoinqml_qmltests PRIVATE Qt6::qtqmlcoreplugin)
else()
target_link_libraries(bitcoinqml_qmltests PRIVATE Qt6::qmlsettingsplugin)
endif()
endif()
99 changes: 0 additions & 99 deletions test/gmocktestfixture.h

This file was deleted.

28 changes: 28 additions & 0 deletions test/mocks/callcounter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) 2026 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#ifndef BITCOIN_QML_TEST_MOCKS_CALLCOUNTER_H
#define BITCOIN_QML_TEST_MOCKS_CALLCOUNTER_H

#include <atomic>
#include <string_view>

class CallCounter
{
public:
explicit CallCounter(std::string_view name) : m_name{name} {}

CallCounter(const CallCounter&) = delete;
CallCounter& operator=(const CallCounter&) = delete;

int operator++() { return m_calls.fetch_add(1) + 1; }
int load() const { return m_calls.load(); }
std::string_view Name() const { return m_name; }

private:
std::atomic<int> m_calls{0};
const std::string_view m_name;
};

#endif // BITCOIN_QML_TEST_MOCKS_CALLCOUNTER_H
Loading
Loading