Fix Vault unit tests

This commit is contained in:
Bronek Kozicki
2025-01-17 15:46:26 +00:00
parent 375614d7ec
commit c325b6c7f5
4 changed files with 16 additions and 14 deletions

View File

@@ -556,6 +556,7 @@ STAmount::operator=(Number const& number)
mIsNegative = number.mantissa() < 0; mIsNegative = number.mantissa() < 0;
mValue = mIsNegative ? -number.mantissa() : number.mantissa(); mValue = mIsNegative ? -number.mantissa() : number.mantissa();
mOffset = number.exponent(); mOffset = number.exponent();
canonicalize();
return *this; return *this;
} }

View File

@@ -276,6 +276,7 @@ STAmount::xrp() const
"Cannot return non-native STAmount as XRPAmount"); "Cannot return non-native STAmount as XRPAmount");
auto drops = static_cast<XRPAmount::value_type>(mValue); auto drops = static_cast<XRPAmount::value_type>(mValue);
XRPL_ASSERT(mOffset == 0, "ripple::STAmount::xrp : amount is canonical");
if (mIsNegative) if (mIsNegative)
drops = -drops; drops = -drops;
@@ -305,6 +306,7 @@ STAmount::mpt() const
Throw<std::logic_error>("Cannot return STAmount as MPTAmount"); Throw<std::logic_error>("Cannot return STAmount as MPTAmount");
auto value = static_cast<MPTAmount::value_type>(mValue); auto value = static_cast<MPTAmount::value_type>(mValue);
XRPL_ASSERT(mOffset == 0, "ripple::STAmount::mpt : amount is canonical");
if (mIsNegative) if (mIsNegative)
value = -value; value = -value;

View File

@@ -175,13 +175,12 @@ class Vault_test : public beast::unit_test::suite
env(tx, ter(tecNO_PERMISSION)); env(tx, ter(tecNO_PERMISSION));
} }
// TODO: Fix this {
// { testcase("delete empty vault");
// testcase("delete empty vault"); auto tx = vault.del({.owner = owner, .id = keylet.key});
// auto tx = vault.del({.owner = owner, .id = keylet.key}); env(tx);
// env(tx); BEAST_EXPECT(!env.le(keylet));
// BEAST_EXPECT(!env.le(keylet)); }
// }
} }
TEST_CASE(Sequences) TEST_CASE(Sequences)

View File

@@ -107,14 +107,14 @@ VaultClawback::doApply()
vault->at(sfAssetAvailable) -= assets; vault->at(sfAssetAvailable) -= assets;
view().update(vault); view().update(vault);
// auto const& vaultAccount = vault->at(sfAccount); auto const& vaultAccount = vault->at(sfAccount);
// // Transfer shares from holder to vault. // Transfer shares from holder to vault.
// if (auto ter = accountSend(view(), holder, vaultAccount, shares, j_)) if (auto ter = accountSend(view(), holder, vaultAccount, shares, j_))
// return ter; return ter;
// // Transfer assets from vault to issuer. // Transfer assets from vault to issuer.
// if (auto ter = accountSend(view(), vaultAccount, account_, assets, j_)) if (auto ter = accountSend(view(), vaultAccount, account_, assets, j_))
// return ter; return ter;
return tesSUCCESS; return tesSUCCESS;
} }