From f91a73718494f476f1dc4cf0632b0732b5c7889a Mon Sep 17 00:00:00 2001 From: Ed Hennis Date: Thu, 8 May 2025 18:28:01 -0400 Subject: [PATCH] Rename XRPL_ASSERT2 to XRPL_ASSERT_PARTS, and document it --- include/xrpl/beast/utility/instrumentation.h | 7 +++++-- src/xrpld/app/tx/detail/LoanPay.cpp | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/xrpl/beast/utility/instrumentation.h b/include/xrpl/beast/utility/instrumentation.h index eac828f94e..3594855eef 100644 --- a/include/xrpl/beast/utility/instrumentation.h +++ b/include/xrpl/beast/utility/instrumentation.h @@ -39,13 +39,16 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #endif #define XRPL_ASSERT ALWAYS_OR_UNREACHABLE -#define XRPL_ASSERT2(cond, location, message, ...) \ - XRPL_ASSERT(cond, location " : " message) +#define XRPL_ASSERT_PARTS(cond, function, description, ...) \ + XRPL_ASSERT(cond, function " : " description) // How to use the instrumentation macros: // // * XRPL_ASSERT if cond must be true but the line might not be reached during // fuzzing. Same like `assert` in normal use. +// * XRPL_ASSERT_PARTS is for convenience, and works like XRPL_ASSERT, but +// splits the message param into "function" and "description", then joins +// them with " : " before passing to XRPL_ASSERT. // * ALWAYS if cond must be true _and_ the line must be reached during fuzzing. // Same like `assert` in normal use. // * REACHABLE if the line must be reached during fuzzing diff --git a/src/xrpld/app/tx/detail/LoanPay.cpp b/src/xrpld/app/tx/detail/LoanPay.cpp index 40280b8d51..bf1ad9d296 100644 --- a/src/xrpld/app/tx/detail/LoanPay.cpp +++ b/src/xrpld/app/tx/detail/LoanPay.cpp @@ -230,7 +230,7 @@ LoanPay::doApply() // Move funds STAmount const paidToVault(asset, totalPaidToVault); STAmount const paidToBroker(asset, totalFee); - XRPL_ASSERT2( + XRPL_ASSERT_PARTS( paidToVault + paidToBroker == amount, "ripple::LoanPay::doApply", "correct payment totals");