From 01538ef10866f38d850a94dcdd7944d730edbf45 Mon Sep 17 00:00:00 2001 From: Ed Hennis Date: Tue, 29 Apr 2025 11:03:43 -0400 Subject: [PATCH] Fix build errors --- include/xrpl/protocol/STObject.h | 6 ++--- include/xrpl/protocol/Units.h | 6 ++--- src/test/app/LoanBroker_test.cpp | 4 ++-- src/test/app/Loan_test.cpp | 2 +- src/test/jtx/TestHelpers.h | 2 +- src/test/jtx/amount.h | 35 +++++++++++++++++++++++++++-- src/test/jtx/sig.h | 2 +- src/xrpld/app/tx/detail/LoanSet.cpp | 2 +- 8 files changed, 44 insertions(+), 15 deletions(-) diff --git a/include/xrpl/protocol/STObject.h b/include/xrpl/protocol/STObject.h index 2f44e36990..2984378133 100644 --- a/include/xrpl/protocol/STObject.h +++ b/include/xrpl/protocol/STObject.h @@ -522,12 +522,12 @@ concept IsArithmeticNumber = std::is_arithmetic_v || std::is_same_v || std::is_same_v; template < typename U, - typename Value = U::value_type, - typename Unit = U::unit_type> + typename Value = typename U::value_type, + typename Unit = typename U::unit_type> concept IsArithmeticValueUnit = std::is_same_v> && IsArithmeticNumber && std::is_class_v; -template +template concept IsArithmeticST = !IsArithmeticValueUnit && IsArithmeticNumber; template concept IsArithmetic = diff --git a/include/xrpl/protocol/Units.h b/include/xrpl/protocol/Units.h index 1788456edb..e0a0dc4486 100644 --- a/include/xrpl/protocol/Units.h +++ b/include/xrpl/protocol/Units.h @@ -594,8 +594,7 @@ safe_cast(Src s) noexcept template constexpr std::enable_if_t< - std::is_integral_v && - std::is_integral_v, + std::is_integral_v && std::is_integral_v, Dest> safe_cast(Src s) noexcept { @@ -617,8 +616,7 @@ unsafe_cast(Src s) noexcept template constexpr std::enable_if_t< - std::is_integral_v && - std::is_integral_v, + std::is_integral_v && std::is_integral_v, Dest> unsafe_cast(Src s) noexcept { diff --git a/src/test/app/LoanBroker_test.cpp b/src/test/app/LoanBroker_test.cpp index 2620c7c200..ddcafeb133 100644 --- a/src/test/app/LoanBroker_test.cpp +++ b/src/test/app/LoanBroker_test.cpp @@ -329,7 +329,7 @@ class LoanBroker_test : public beast::unit_test::suite ? STAmount(env.current()->fees().base.value()) : vault.asset(0)); env.require(balance(alice, expectedBalance)); - env.require(balance(pseudoAccount, None(vault.asset.raw()))); + env.require(balance(pseudoAccount, vault.asset(none))); } } @@ -367,7 +367,7 @@ class LoanBroker_test : public beast::unit_test::suite MPTTester mptt{env, issuer, mptInitNoFund}; mptt.create( {.flags = tfMPTCanClawback | tfMPTCanTransfer | tfMPTCanLock}); - PrettyAsset const mptAsset = mptt.issuanceID(); + PrettyAsset const mptAsset = mptt["MPT"]; mptt.authorize({.account = alice}); mptt.authorize({.account = evan}); env(pay(issuer, alice, mptAsset(100'000))); diff --git a/src/test/app/Loan_test.cpp b/src/test/app/Loan_test.cpp index 836f588917..cd943bf335 100644 --- a/src/test/app/Loan_test.cpp +++ b/src/test/app/Loan_test.cpp @@ -80,9 +80,9 @@ class Loan_test : public beast::unit_test::suite setTx = env.jt( setTx, sig(sfCounterpartySignature, bob), ter(temDISABLED)); env(setTx); +#if 0 auto const loanKeylet = keylet::loan(alice.id(), keylet.key, env.seq(alice)); -#if 0 // Other Loan transactions are disabled, too. // 2. LoanDelete env(delete(alice, loanKeylet.key), diff --git a/src/test/jtx/TestHelpers.h b/src/test/jtx/TestHelpers.h index 51c15e101a..0d9cadcd47 100644 --- a/src/test/jtx/TestHelpers.h +++ b/src/test/jtx/TestHelpers.h @@ -205,7 +205,7 @@ protected: using base::value_; public: - using base::JTxField; + using JTxField::JTxField; OV value() const override diff --git a/src/test/jtx/amount.h b/src/test/jtx/amount.h index bc25103092..6ef07ee1e1 100644 --- a/src/test/jtx/amount.h +++ b/src/test/jtx/amount.h @@ -225,6 +225,12 @@ public: STAmount amount{asset_, v * scale_, 0, negative}; return {amount, ""}; } + + None + operator()(none_t) const + { + return {asset_}; + } }; //------------------------------------------------------------------------------ @@ -456,14 +462,32 @@ public: return issuanceID; } - /** Implicit conversion to MPTIssue. + /** Explicit conversion to MPTIssue or asset. + */ + ripple::MPTIssue + mptIssue() const + { + return MPTIssue{issuanceID}; + } + Asset + asset() const + { + return mptIssue(); + } + + /** Implicit conversion to MPTIssue or asset. This allows passing an MPT value where an MPTIssue is expected. */ operator ripple::MPTIssue() const { - return MPTIssue{issuanceID}; + return mptIssue(); + } + + operator PrettyAsset() const + { + return asset(); } template @@ -479,6 +503,13 @@ public: PrettyAmount operator()(detail::epsilon_multiple) const; + /** Returns None-of-Issue */ + None + operator()(none_t) const + { + return {mptIssue()}; + } + friend BookSpec operator~(MPT const& mpt) { diff --git a/src/test/jtx/sig.h b/src/test/jtx/sig.h index 6a73038c42..c101d9e491 100644 --- a/src/test/jtx/sig.h +++ b/src/test/jtx/sig.h @@ -35,9 +35,9 @@ class sig { private: bool manual_ = true; - std::optional account_; /// subField only supported with explicit account SField const* const subField = nullptr; + std::optional account_; static constexpr SField* const topLevel = nullptr; public: diff --git a/src/xrpld/app/tx/detail/LoanSet.cpp b/src/xrpld/app/tx/detail/LoanSet.cpp index 38554b31ab..9deca7c37e 100644 --- a/src/xrpld/app/tx/detail/LoanSet.cpp +++ b/src/xrpld/app/tx/detail/LoanSet.cpp @@ -241,7 +241,7 @@ LoanSet::doApply() auto const brokerSle = view.peek(keylet::loanbroker(brokerID)); if (!brokerSle) - tefBAD_LEDGER; // LCOV_EXCL_LINE + return tefBAD_LEDGER; // LCOV_EXCL_LINE auto const brokerOwner = brokerSle->at(sfOwner); auto const brokerOwnerSle = view.peek(keylet::account(brokerOwner));