8000 test: enable unit tests to work with variable reference fee by vvysokikh1 · Pull Request #5145 · XRPLF/rippled · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

test: enable unit tests to work with variable reference fee #5145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 34 commits into from
Mar 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d8778f0
test: enable unit tests to work with variable reference fee
vvysokikh1 Sep 20, 2024
40b139a
test: enable unit tests to work with variable reference fee (part 2)
vvysokikh1 Sep 23, 2024
590dc50
test: enable unit tests to work with variable reference fee (part 3)
vvysokikh1 Sep 25, 2024
bad2421
clang-format applied
vvysokikh1 Sep 25, 2024
ce491aa
reverted oracle changes
vvysokikh1 Sep 25, 2024
b0dcfa0
fixed oracle tests
vvysokikh1 Sep 30, 2024
2e384c4
clang-format applied
vvysokikh1 Sep 30, 2024
b62c65f
reverted amm changes
vvysokikh1 Sep 30, 2024
8f49e57
fixed designator initializers ordering
vvysokikh1 Oct 1, 2024
642d2a6
fixed typos
vvysokikh1 Oct 1, 2024
4e7ac62
fixed part of offer test
vvysokikh1 Oct 1, 2024
cdd049a
another offer test fix
vvysokikh1 Oct 1, 2024
115f61c
fixed some AMM tests
vvysokikh1 Oct 1, 2024
63e1aee
fixed some AMM tests
vvysokikh1 Oct 1, 2024
46999c0
clang-format applied
vvysokikh1 Oct 1, 2024
0dd1d2b
reverted oracle changes
vvysokikh1 Oct 1, 2024
604796e
some AMM test fixes
vvysokikh1 Oct 2, 2024
507e7ea
Revert "some AMM test fixes"
vvysokikh1 Oct 3, 2024
d90c4e1
fixed check test
vvysokikh1 Feb 26, 2025
574617c
fixed AMM tests
vvysokikh1 Feb 26, 2025
5a795f0
fixed AMMExtended tests
vvysokikh1 Feb 26, 2025
1a83be2
fixed flow test
vvysokikh1 Feb 26, 2025
d4f24e5
fixed offer tests
vvysokikh1 Feb 27, 2025
2c90b42
fixed paychan test
vvysokikh1 Feb 27, 2025
e190a5d
fixed paychan test 2
vvysokikh1 Feb 27, 2025
167eed3
fixed xchain test
vvysokikh1 Feb 27, 2025
8770006
fixed oracle test
vvysokikh1 Mar 3, 2025
f8fa5dc
fixed GetAggregatePrice tests
vvysokikh1 Mar 3, 2025
0f937d0
fix simulate tests
vvysokikh1 Mar 3, 2025
617a1b5
fix LedgerRPC tests
vvysokikh1 Mar 3, 2025
c888e3b
fix deliveredAmount test
vvysokikh1 Mar 3, 2025
a724148
fix mptoken test
vvysokikh1 Mar 3, 2025
460d05c
fix bunch of tests
vvysokikh1 Mar 4, 2025
b9a5163
Merge branch 'develop' into other_tests_variable_reference_fee
bthomee Mar 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 44 additions & 69 deletions src/test/app/AMMExtended_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,17 @@ struct AMMExtended_test : public jtx::AMMTest
auto const USD2 = gw2["USD"];

env.fund(XRP(20'000), alice, noripple(bob), carol, dan, gw1, gw2);
env.close();
env.trust(USD1(20'000), alice, carol, dan);
env(trust(bob, USD1(1'000), tfSetNoRipple));
env.trust(USD2(1'000), alice, carol, dan);
env(trust(bob, USD2(1'000), tfSetNoRipple));
env.close();

env(pay(gw1, dan, USD1(10'000)));
env(pay(gw1, bob, USD1(50)));
env(pay(gw2, bob, USD2(50)));
env.close();

AMM ammDan(env, dan, XRP(10'000), USD1(10'000));

Expand All @@ -157,12 +160,15 @@ struct AMMExtended_test : public jtx::AMMTest

env.fund(XRP(20'000), alice, bob, carol, gw1, gw2);
env.fund(XRP(20'000), dan);
env.close();
env.trust(USD1(20'000), alice, bob, carol, dan);
env.trust(USD2(1'000), alice, bob, carol, dan);
env.close();

env(pay(gw1, dan, USD1(10'050)));
env(pay(gw1, bob, USD1(50)));
env(pay(gw2, bob, USD2(50)));
env.close();

AMM ammDan(env, dan, XRP(10'000), USD1(10'050));

Expand Down Expand Up @@ -337,6 +343,7 @@ struct AMMExtended_test : public jtx::AMMTest
Env env{*this, features};

env.fund(XRP(200'000), gw, alice, bob);
env.close();

env(trust(alice, USD(1'000)));

Expand Down Expand Up @@ -440,6 +447,7 @@ struct AMMExtended_test : public jtx::AMMTest
testAMM(
[&](AMM& ammAlice, Env& env) {
env.fund(XRP(1'000), bob);
env.close();
env(trust(bob, USD(100)));
env.close();
env(pay(alice, bob, USD(100)), sendmax(XRP(100)));
Expand All @@ -463,6 +471,7 @@ struct AMMExtended_test : public jtx::AMMTest
testAMM(
[&](AMM& ammAlice, Env& env) {
env.fund(XRP(1'000), bob);
env.close();
env(trust(bob, USD(100)));
env.close();
env(pay(alice, bob, XRP(100)), sendmax(USD(100)));
Expand Down Expand Up @@ -493,7 +502,6 @@ struct AMMExtended_test : public jtx::AMMTest
auto const EUR1 = gw2["EUR"];

fund(env, gw1, {gw2, alice, bob, carol, dan}, XRP(60'000));

env(trust(alice, USD1(1'000)));
env.close();
env(trust(bob, EUR1(1'000)));
Expand Down Expand Up @@ -558,6 +566,7 @@ struct AMMExtended_test : public jtx::AMMTest

env.fund(starting_xrp, gw1, gw2, gw3, alice);
env.fund(XRP(2'000), bob);
env.close();

env(trust(alice, USD1(1'000)));
env(trust(alice, USD2(1'000)));
Expand Down Expand Up @@ -657,6 +666,7 @@ struct AMMExtended_test : public jtx::AMMTest

env.fund(starting_xrp, gw, alice);
env.fund(XRP(2'000), bob);
env.close();

env(trust(alice, USD(150)));
env(trust(bob, USD(4'000)));
Expand Down Expand Up @@ -1516,6 +1526,7 @@ struct AMMExtended_test : public jtx::AMMTest
Env env = pathTestEnv();
auto const AUD = gw["AUD"];
env.fund(XRP(10'000), alice, bob, carol, gw);
env.close();
env(rate(gw, 1.1));
env.trust(AUD(2'000), bob, carol);
env(pay(gw, carol, AUD(51)));
Expand Down Expand Up @@ -1892,6 +1903,7 @@ struct AMMExtended_test : public jtx::AMMTest
fund(env, gw, {carol}, XRP(10'000), {}, Fund::Acct);
auto const AMMXRPPool = env.current()->fees().increment * 2;
env.fund(reserve(env, 5) + ammCrtFee(env) + AMMXRPPool, bob);
env.close();
env.trust(USD(1'000), alice, bob, carol);
env.trust(EUR(1'000), alice, bob, carol);

Expand Down Expand Up @@ -2028,16 +2040,20 @@ struct AMMExtended_test : public jtx::AMMTest

env.fund(XRP(10'000), alice, carol, gw);
env.fund(XRP(10'000), bob);
env.close();
env.trust(USD(1'000), alice, bob, carol);
env.trust(BTC(1'000), alice, bob, carol);
env.trust(EUR(1'000), alice, bob, carol);
env.close();

env(pay(gw, alice, BTC(60)));
env(pay(gw, bob, USD(200)));
env(pay(gw, bob, EUR(150)));
env.close();

env(offer(bob, BTC(50), USD(50)));
env(offer(bob, BTC(40), EUR(50)));
env.close();
AMM ammBob(env, bob, EUR(100), USD(150));

// unfund offer
Expand Down Expand Up @@ -2076,18 +2092,21 @@ struct AMMExtended_test : public jtx::AMMTest
Env env(*this, features);

env.fund(XRP(10'000), bob, carol, gw);
env.close();
// Sets rippling on, this is different from
// the original test
fund(env, gw, {alice}, XRP(10'000), {}, Fund::Acct);
env.trust(USD(1'000), alice, bob, carol);
env.trust(BTC(1'000), alice, bob, carol);
env.trust(EUR(1'000), alice, bob, carol);
env.close();

env(pay(gw, alice, BTC(60)));
env(pay(gw, bob, BTC(100)));
env(pay(gw, bob, USD(100)));
env(pay(gw, bob, EUR(50)));
env(pay(gw, carol, EUR(1)));
env.close();

// This is multiplath, which generates limited # of offers
AMM ammBobBTC_USD(env, bob, BTC(50), USD(50));
Expand Down Expand Up @@ -2171,13 +2190,16 @@ struct AMMExtended_test : public jtx::AMMTest

Env env(*this, features);
env.fund(XRP(10'000), bob, carol, gw);
env.close();
fund(env, gw, {alice}, XRP(10'000), {}, Fund::Acct);
env.trust(USD(1'000), alice, bob, carol);
env.trust(EUR(1'000), alice, bob, carol);
env.close();

env(pay(gw, alice, USD(1'000)));
env(pay(gw, bob, EUR(1'000)));
env(pay(gw, bob, USD(1'000)));
env.close();

// env(offer(bob, USD(1), drops(2)), txflags(tfPassive));
AMM ammBob(env, bob, USD(8), XRPAmount{21}) F438 ;
Expand Down Expand Up @@ -3155,6 +3177,7 @@ struct AMMExtended_test : public jtx::AMMTest

fund(env, gw, {ed}, XRP(100'000'000), {USD(11)});
env.fund(XRP(100'000'000), alice, bob, carol, dan);
env.close();
env.trust(USD(1), bob);
env(pay(gw, bob, USD(1)));
env.trust(USD(1), dan);
Expand Down Expand Up @@ -3227,7 +3250,9 @@ struct AMMExtended_test : public jtx::AMMTest
txflags(tfPartialPayment),
sendmax(XRP(5)),
ter(tecPATH_PARTIAL));
env.require(balance(alice, XRP(9'999.99999)));
env.require(balance(
alice,
drops(10'000'000'000 - env.current()->fees().base.drops())));
env.require(balance(bob, XRP(10'000)));
}

Expand Down Expand Up @@ -3271,6 +3296,7 @@ struct AMMExtended_test : public jtx::AMMTest
auto const dan = Account("dan");
Env env(*this, features);
fund(env, gw, {alice, bob, carol, dan}, XRP(10'000));
env.close();
env.trust(USD(1'100), bob, carol, dan);
env(pay(gw, bob, USD(100)));
env(pay(gw, dan, USD(1'100)));
Expand Down Expand Up @@ -3495,51 +3521,23 @@ struct AMMExtended_test : public jtx::AMMTest
BEAST_EXPECT(lines[jss::lines][0u][jss::balance] == "100");
}

{
// Account with line unfrozen (proving operations normally work)
// test: can make Payment on that line
env(pay(alice, bob, G1["USD"](1)));
// Account with line unfrozen (proving operations normally work)
// test: can make Payment on that line
env(pay(alice, bob, G1["USD"](1)));

// test: can receive Payment on that line
env(pay(bob, alice, G1["USD"](1)));
env.close();
}
// test: can receive Payment on that line
env(pay(bob, alice, G1["USD"](1)));
env.close();

{
// Is created via a TrustSet with SetFreeze flag
// test: sets LowFreeze | HighFreeze flags
env(trust(G1, bob["USD"](0), tfSetFreeze));
auto affected = env.meta()->getJson(
JsonOptions::none)[sfAffectedNodes.fieldName];
if (!BEAST_EXPECT(checkArraySize(affected, 2u)))
return;
auto ff =
affected[1u][sfModifiedNode.fieldName][sfFinalFields.fieldName];
BEAST_EXPECT(
ff[sfLowLimit.fieldName] ==
G1["USD"](0).value().getJson(JsonOptions::none));
BEAST_EXPECT(ff[jss::Flags].asUInt() & lsfLowFreeze);
BEAST_EXPECT(!(ff[jss::Flags].asUInt() & lsfHighFreeze));
env.close();
}
// Is created via a TrustSet with SetFreeze flag
// test: sets LowFreeze | HighFreeze flags
env(trust(G1, bob["USD"](0), tfSetFreeze));
env.close();

{
// Account with line frozen by issuer
// test: can buy more assets on that line
env(offer(bob, G1["USD"](5), XRP(25)));
auto affected = env.meta()->getJson(
JsonOptions::none)[sfAffectedNodes.fieldName];
if (!BEAST_EXPECT(checkArraySize(affected, 4u)))
return;
auto ff =
affected[1u][sfModifiedNode.fieldName][sfFinalFields.fieldName];
BEAST_EXPECT(
ff[sfHighLimit.fieldName] ==
bob["USD"](100).value().getJson(JsonOptions::none));
auto amt = STAmount{Issue{to_currency("USD"), noAccount()}, -15}
.value()
.getJson(JsonOptions::none);
BEAST_EXPECT(ff[sfBalance.fieldName] == amt);
env.close();
BEAST_EXPECT(ammAlice.expectBalances(
XRP(525), G1["USD"](100), ammAlice.tokens()));
Expand Down Expand Up @@ -3799,17 +3797,6 @@ struct AMMExtended_test : public jtx::AMMTest
env(trust(G1, a3am, tfSetFreeze));
auto const info = ammA3.ammRpcInfo();
BEAST_EXPECT(info[jss::amm][jss::asset2_frozen].asBool());
auto affected =
env.meta()->getJson(JsonOptions::none)[sfAffectedNodes.fieldName];
if (!BEAST_EXPECT(checkArraySize(affected, 2u)))
return;
auto ff =
affected[1u][sfModifiedNode.fieldName][sfFinalFields.fieldName];
BEAST_EXPECT(
ff[sfHighLimit.fieldName] ==
G1["USD"](0).value().getJson(JsonOptions::none));
BEAST_EXPECT(!(ff[jss::Flags].asUInt() & lsfLowFreeze));
BEAST_EXPECT(ff[jss::Flags].asUInt() & lsfHighFreeze);
env.close();

// test: Can make a payment via the new offer
Expand All @@ -3822,27 +3809,10 @@ struct AMMExtended_test : public jtx::AMMTest
// removal buy successful OfferCreate
// test: freeze the new offer
env(trust(G1, A4["USD"](0), tfSetFreeze));
affected =
env.meta()->getJson(JsonOptions::none)[sfAffectedNodes.fieldName];
if (!BEAST_EXPECT(checkArraySize(affected, 2u)))
return;
ff = affected[0u][sfModifiedNode.fieldName][sfFinalFields.fieldName];
BEAST_EXPECT(
ff[sfLowLimit.fieldName] ==
G1["USD"](0).value().getJson(JsonOptions::none));
BEAST_EXPECT(ff[jss::Flags].asUInt() & lsfLowFreeze);
BEAST_EXPECT(!(ff[jss::Flags].asUInt() & lsfHighFreeze));
env.close();

// test: can no longer create a crossing offer
env(offer(A2, G1["USD"](999), XRP(999)));
affected =
env.meta()->getJson(JsonOptions::none)[sfAffectedNodes.fieldName];
if (!BEAST_EXPECT(checkArraySize(affected, 8u)))
return;
auto created = affected[0u][sfCreatedNode.fieldName];
BEAST_EXPECT(
created[sfNewFields.fieldName][jss::Account] == A2.human());
env.close();

// test: offer was removed by offer_create
Expand Down Expand Up @@ -3953,12 +3923,14 @@ struct AMMExtended_test : public jtx::AMMTest
fund(env, gw, {alice, bob}, XRP(10'000));
env.trust(USD(1'000), alice, bob);
env.trust(EUR(1'000), alice, bob);
env.close();
fund(
env,
bob,
{alice, gw},
{BobUSD(100), BobEUR(100)},
Fund::IOUOnly);
env.close();

AMM ammBobXRP_USD(env, bob, XRP(100), BobUSD(100));
env(offer(gw, XRP(100), USD(100)), txflags(tfPassive));
Expand Down Expand Up @@ -4024,10 +3996,12 @@ struct AMMExtended_test : public jtx::AMMTest
Env env(*this, features);

env.fund(XRP(10'000), alice, bob, carol, gw);
env.close();
env.trust(USD(10'000), alice, bob, carol);

env.close();
env(pay(gw, bob, USD(100)));
env(pay(gw, alice, USD(100)));
env.close();

AMM ammBob(env, bob, XRP(100), USD(100));

Expand All @@ -4043,6 +4017,7 @@ struct AMMExtended_test : public jtx::AMMTest
Env env(*this, features);

env.fund(XRP(10'000), alice, bob, carol, gw);
env.close();
env.trust(USD(10'000), alice, bob, carol);
env.trust(EUR(10'000), alice, bob, carol);
env.trust(CNY(10'000), alice, bob, carol);
Expand Down
Loading
Loading
0