From e50ba58d87bbf8aec9a0b0f7b2ce78ba75bd7d72 Mon Sep 17 00:00:00 2001 From: Vlad <129996061+vvysokikh1@users.noreply.github.com> Date: Thu, 27 Mar 2025 23:40:36 +0000 Subject: [PATCH] test: enable compile time param to change reference fee value (#5159) Adds an extra CI pipeline to perform unit tests using different values for fees. --- cmake/RippledCore.cmake | 3 +++ cmake/RippledSettings.cmake | 6 ++++++ src/test/jtx/impl/envconfig.cpp | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/cmake/RippledCore.cmake b/cmake/RippledCore.cmake index 2d593599c..3563d6bfd 100644 --- a/cmake/RippledCore.cmake +++ b/cmake/RippledCore.cmake @@ -164,6 +164,9 @@ if(xrpld) add_executable(rippled) if(tests) target_compile_definitions(rippled PUBLIC ENABLE_TESTS) + target_compile_definitions(rippled PRIVATE + UNIT_TEST_REFERENCE_FEE=${UNIT_TEST_REFERENCE_FEE} + ) endif() target_include_directories(rippled PRIVATE diff --git a/cmake/RippledSettings.cmake b/cmake/RippledSettings.cmake index 58877e188..b2d7b0d9a 100644 --- a/cmake/RippledSettings.cmake +++ b/cmake/RippledSettings.cmake @@ -11,6 +11,12 @@ option(assert "Enables asserts, even in release builds" OFF) option(xrpld "Build xrpld" ON) option(tests "Build tests" ON) +if(tests) + # This setting allows making a separate workflow to test fees other than default 10 + if(NOT UNIT_TEST_REFERENCE_FEE) + set(UNIT_TEST_REFERENCE_FEE "10" CACHE STRING "") + endif() +endif() option(unity "Creates a build using UNITY support in cmake. This is the default" ON) if(unity) diff --git a/src/test/jtx/impl/envconfig.cpp b/src/test/jtx/impl/envconfig.cpp index bf79164fb..9f80c98b6 100644 --- a/src/test/jtx/impl/envconfig.cpp +++ b/src/test/jtx/impl/envconfig.cpp @@ -33,7 +33,7 @@ setupConfigForUnitTests(Config& cfg) using namespace jtx; // Default fees to old values, so tests don't have to worry about changes in // Config.h - cfg.FEES.reference_fee = 10; + cfg.FEES.reference_fee = UNIT_TEST_REFERENCE_FEE; cfg.FEES.account_reserve = XRP(200).value().xrp().drops(); cfg.FEES.owner_reserve = XRP(50).value().xrp().drops();