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;
mValue = mIsNegative ? -number.mantissa() : number.mantissa();
mOffset = number.exponent();
canonicalize();
return *this;
}

View File

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

View File

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

View File

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