mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-18 18:15:50 +00:00
Compare commits
4 Commits
ximinez/fi
...
Bronek/Vau
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8a75beffc2 | ||
|
|
23e9ec5e4b | ||
|
|
ec683f2743 | ||
|
|
27dd73ca91 |
@@ -2446,6 +2446,47 @@ class Vault_test : public beast::unit_test::suite
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
testIOURounding()
|
||||
{
|
||||
using namespace test::jtx;
|
||||
testcase("IOU rounding");
|
||||
|
||||
Account const issuer{"issuer"};
|
||||
Account const owner{"owner"};
|
||||
auto const IOU = issuer["IOU"];
|
||||
Env env{*this};
|
||||
Vault vault{env};
|
||||
|
||||
env.fund(XRP(1'000), issuer, owner);
|
||||
env.close();
|
||||
|
||||
env(trust(owner, IOU(1'000)));
|
||||
env(pay(issuer, owner, IOU(118.75)));
|
||||
env.close();
|
||||
|
||||
auto [tx, vaultKeylet] =
|
||||
vault.create({.owner = owner, .asset = IOU.asset()});
|
||||
tx[sfScale] = 1;
|
||||
env(tx);
|
||||
|
||||
env.close();
|
||||
|
||||
env(vault.deposit(
|
||||
{.depositor = owner, .id = vaultKeylet.key, .amount = IOU(100)}));
|
||||
env.close();
|
||||
|
||||
auto const tx1 = vault.deposit(
|
||||
{.depositor = owner, .id = vaultKeylet.key, .amount = IOU(3.75)});
|
||||
for (auto i = 0; i < 5; ++i)
|
||||
{
|
||||
if (i == 4)
|
||||
std::cerr << tx1 << '\n';
|
||||
env(tx1);
|
||||
env.close();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
testWithIOU()
|
||||
{
|
||||
@@ -4973,20 +5014,21 @@ public:
|
||||
void
|
||||
run() override
|
||||
{
|
||||
testSequences();
|
||||
testPreflight();
|
||||
testCreateFailXRP();
|
||||
testCreateFailIOU();
|
||||
testCreateFailMPT();
|
||||
testWithMPT();
|
||||
testWithIOU();
|
||||
testWithDomainCheck();
|
||||
testWithDomainCheckXRP();
|
||||
testNonTransferableShares();
|
||||
testFailedPseudoAccount();
|
||||
testScaleIOU();
|
||||
testRPC();
|
||||
testDelegate();
|
||||
// testSequences();
|
||||
// testPreflight();
|
||||
// testCreateFailXRP();
|
||||
// testCreateFailIOU();
|
||||
// testCreateFailMPT();
|
||||
// testWithMPT();
|
||||
// testWithIOU();
|
||||
testIOURounding();
|
||||
// testWithDomainCheck();
|
||||
// testWithDomainCheckXRP();
|
||||
// testNonTransferableShares();
|
||||
// testFailedPseudoAccount();
|
||||
// testScaleIOU();
|
||||
// testRPC();
|
||||
// testDelegate();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1011,25 +1011,41 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
testRoundingError()
|
||||
{
|
||||
testcase("rounding error");
|
||||
|
||||
STAmount assets{noIssue()};
|
||||
STAmount const shares{noIssue(), 37, 0};
|
||||
Number const shareTotal{1148};
|
||||
Number assetTotal{1148, -1};
|
||||
|
||||
assets = (assetTotal * shares) / shareTotal;
|
||||
std::cerr << assets << '\n'; // 3.699999999999999/1/1
|
||||
BEAST_EXPECT(assets == Number(37l, -1)); // FAIL
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
void
|
||||
run() override
|
||||
{
|
||||
testSetValue();
|
||||
testNativeCurrency();
|
||||
testCustomCurrency();
|
||||
testArithmetic();
|
||||
testUnderflow();
|
||||
testRounding();
|
||||
testConvertXRP();
|
||||
testConvertIOU();
|
||||
testCanAddXRP();
|
||||
testCanAddIOU();
|
||||
testCanAddMPT();
|
||||
testCanSubtractXRP();
|
||||
testCanSubtractIOU();
|
||||
testCanSubtractMPT();
|
||||
// testSetValue();
|
||||
// testNativeCurrency();
|
||||
// testCustomCurrency();
|
||||
// testArithmetic();
|
||||
// testUnderflow();
|
||||
// testRounding();
|
||||
// testConvertXRP();
|
||||
// testConvertIOU();
|
||||
// testCanAddXRP();
|
||||
// testCanAddIOU();
|
||||
// testCanAddMPT();
|
||||
// testCanSubtractXRP();
|
||||
// testCanSubtractIOU();
|
||||
// testCanSubtractMPT();
|
||||
testRoundingError();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user