Fix refactoring of retired fixUniversalNumber

This commit is contained in:
Gregory Tsipenyuk
2026-07-07 10:40:32 -04:00
parent 279fb85bc9
commit cd0d3bb5f9
2 changed files with 8 additions and 11 deletions

View File

@@ -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<MPTIssue>() && isFeatureEnabled(featureMPTokensV2, false) &&
getSTNumberSwitchover())
if (asset.holds<MPTIssue>() && 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<MPTIssue>() && isFeatureEnabled(featureMPTokensV2, false) &&
getSTNumberSwitchover())
if (asset.holds<MPTIssue>() && isFeatureEnabled(featureMPTokensV2, false))
{
// Match the multiply path above: Number performs the rounded
// operation, then STAmount materializes the final MPT amount using the

View File

@@ -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};