From cd0d3bb5f903e7155b6df9b20b934f8bc858a381 Mon Sep 17 00:00:00 2001 From: Gregory Tsipenyuk Date: Tue, 7 Jul 2026 10:40:32 -0400 Subject: [PATCH] Fix refactoring of retired fixUniversalNumber --- src/libxrpl/protocol/STAmount.cpp | 6 ++---- src/test/protocol/STAmount_test.cpp | 13 ++++++------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/libxrpl/protocol/STAmount.cpp b/src/libxrpl/protocol/STAmount.cpp index 5c4aef0724..0d222b66a6 100644 --- a/src/libxrpl/protocol/STAmount.cpp +++ b/src/libxrpl/protocol/STAmount.cpp @@ -1527,8 +1527,7 @@ mulRoundImpl(STAmount const& v1, STAmount const& v2, Asset const& asset, bool ro bool const resultNegative = v1.negative() != v2.negative(); - if (asset.holds() && isFeatureEnabled(featureMPTokensV2, false) && - getSTNumberSwitchover()) + if (asset.holds() && isFeatureEnabled(featureMPTokensV2, false)) { // MPT DEX can combine 63-bit MPT amounts with IOU-shaped transfer // rates. Use Number arithmetic under MPTokensV2 so the rounded @@ -1630,8 +1629,7 @@ divRoundImpl(STAmount const& num, STAmount const& den, Asset const& asset, bool bool const resultNegative = (num.negative() != den.negative()); - if (asset.holds() && isFeatureEnabled(featureMPTokensV2, false) && - getSTNumberSwitchover()) + if (asset.holds() && isFeatureEnabled(featureMPTokensV2, false)) { // Match the multiply path above: Number performs the rounded // operation, then STAmount materializes the final MPT amount using the diff --git a/src/test/protocol/STAmount_test.cpp b/src/test/protocol/STAmount_test.cpp index c8a4421780..fb09dfc75a 100644 --- a/src/test/protocol/STAmount_test.cpp +++ b/src/test/protocol/STAmount_test.cpp @@ -1060,7 +1060,7 @@ public: return Rules{mptV2 ? kMptV2Features : kNoFeatures}; }; - auto throwsOverflow = [&](auto&& f) { + auto throwsOverflow = [&](auto&& f, bool expected = true) { bool threw = false; try { @@ -1070,12 +1070,11 @@ public: { threw = true; } - BEAST_EXPECT(threw); + BEAST_EXPECT(threw == expected); }; { CurrentTransactionRulesGuard const rg(rules(false)); - NumberSO const numberSO{true}; throwsOverflow([&] { (void)multiplyRound(largeAmount, transferRate, asset, true); }); throwsOverflow([&] { (void)divideRound(scaledAmount, transferRate, asset, true); }); @@ -1083,15 +1082,15 @@ public: { CurrentTransactionRulesGuard const rg(rules(true)); - NumberSO const numberSO{false}; - throwsOverflow([&] { (void)multiplyRound(largeAmount, transferRate, asset, true); }); - throwsOverflow([&] { (void)divideRound(scaledAmount, transferRate, asset, true); }); + throwsOverflow( + [&] { (void)multiplyRound(largeAmount, transferRate, asset, true); }, false); + throwsOverflow( + [&] { (void)divideRound(scaledAmount, transferRate, asset, true); }, false); } { CurrentTransactionRulesGuard const rg(rules(true)); - NumberSO const numberSO{true}; STAmount const one{asset, 1}; STAmount const two{asset, 2};