From f1490215cb2f5b08a51e10e167e78ac1148c17e9 Mon Sep 17 00:00:00 2001 From: Vlad <129996061+vvysokikh1@users.noreply.github.com> Date: Tue, 25 Mar 2025 14:31:25 +0000 Subject: [PATCH] test: enable unit tests to work with variable reference fee (#5145) Fix remaining unit tests to be able to process reference fee values other than 10. --- src/test/app/AMMExtended_test.cpp | 113 ++++------ src/test/app/AMM_test.cpp | 38 ++-- src/test/app/Check_test.cpp | 17 +- src/test/app/DID_test.cpp | 9 +- src/test/app/DeliverMin_test.cpp | 11 +- src/test/app/DepositAuth_test.cpp | 17 +- src/test/app/Escrow_test.cpp | 267 ++++++++++++----------- src/test/app/Flow_test.cpp | 42 +++- src/test/app/LedgerMaster_test.cpp | 2 + src/test/app/MPToken_test.cpp | 4 +- src/test/app/MultiSign_test.cpp | 5 + src/test/app/NFToken_test.cpp | 101 +++++---- src/test/app/Offer_test.cpp | 67 ++++-- src/test/app/Oracle_test.cpp | 272 ++++++++++++++++++------ src/test/app/Path_test.cpp | 20 ++ src/test/app/PayChan_test.cpp | 4 +- src/test/app/ReducedOffer_test.cpp | 2 +- src/test/app/Regression_test.cpp | 1 + src/test/app/SetAuth_test.cpp | 1 + src/test/jtx/Env_test.cpp | 14 +- src/test/ledger/BookDirs_test.cpp | 1 + src/test/ledger/View_test.cpp | 1 + src/test/rpc/AccountTx_test.cpp | 4 + src/test/rpc/DeliveredAmount_test.cpp | 8 +- src/test/rpc/GatewayBalances_test.cpp | 7 + src/test/rpc/GetAggregatePrice_test.cpp | 53 +++-- src/test/rpc/JSONRPC_test.cpp | 20 +- src/test/rpc/LedgerClosed_test.cpp | 6 +- src/test/rpc/LedgerRPC_test.cpp | 45 ++-- src/test/rpc/LedgerRequestRPC_test.cpp | 11 +- src/test/rpc/OwnerInfo_test.cpp | 1 + src/test/rpc/RobustTransaction_test.cpp | 3 +- src/test/rpc/Simulate_test.cpp | 7 +- src/test/rpc/Subscribe_test.cpp | 16 +- src/test/rpc/TransactionEntry_test.cpp | 9 +- src/test/rpc/Transaction_test.cpp | 16 +- 36 files changed, 816 insertions(+), 399 deletions(-) diff --git a/src/test/app/AMMExtended_test.cpp b/src/test/app/AMMExtended_test.cpp index 22f3a7769..ae94c929f 100644 --- a/src/test/app/AMMExtended_test.cpp +++ b/src/test/app/AMMExtended_test.cpp @@ -117,14 +117,17 @@ private: 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)); @@ -147,12 +150,15 @@ private: 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)); @@ -327,6 +333,7 @@ private: Env env{*this, features}; env.fund(XRP(200'000), gw, alice, bob); + env.close(); env(trust(alice, USD(1'000))); @@ -430,6 +437,7 @@ private: 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))); @@ -453,6 +461,7 @@ private: 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))); @@ -483,7 +492,6 @@ private: 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))); @@ -548,6 +556,7 @@ private: 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))); @@ -647,6 +656,7 @@ private: 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))); @@ -1474,6 +1484,7 @@ private: 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))); @@ -1850,6 +1861,7 @@ private: 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); @@ -1986,16 +1998,20 @@ private: 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 @@ -2034,18 +2050,21 @@ private: 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)); @@ -2129,13 +2148,16 @@ private: 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}); @@ -2917,6 +2939,7 @@ private: 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); @@ -2985,7 +3008,9 @@ private: 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))); } @@ -3029,6 +3054,7 @@ private: 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))); @@ -3239,51 +3265,23 @@ private: 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())); @@ -3543,17 +3541,6 @@ private: 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 @@ -3566,27 +3553,10 @@ private: // 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 @@ -3698,12 +3668,14 @@ private: 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)); @@ -3769,10 +3741,12 @@ private: Env env(*this, features - featureXahauGenesis - featureTouch); 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)); @@ -3788,6 +3762,7 @@ private: 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); diff --git a/src/test/app/AMM_test.cpp b/src/test/app/AMM_test.cpp index 618525fcd..76e030fca 100644 --- a/src/test/app/AMM_test.cpp +++ b/src/test/app/AMM_test.cpp @@ -1357,14 +1357,15 @@ private: // Equal deposit: 1000000 tokens, 10% of the current pool testAMM([&](AMM& ammAlice, Env& env) { + auto const baseFee = env.current()->fees().base; ammAlice.deposit(carol, 1'000'000); BEAST_EXPECT(ammAlice.expectBalances( XRP(11'000), USD(11'000), IOUAmount{11'000'000, 0})); // 30,000 less deposited 1,000 BEAST_EXPECT(expectLine(env, carol, USD(29'000))); // 30,000 less deposited 1,000 and 10 drops tx fee - BEAST_EXPECT( - expectLedgerEntryRoot(env, carol, XRPAmount{28'999'999'990})); + BEAST_EXPECT(expectLedgerEntryRoot( + env, carol, XRPAmount{29'000'000'000 - baseFee})); }); // equal asset deposit: unit test to exercise the rounding-down of @@ -1681,6 +1682,7 @@ private: env.fund(XRP(30'000), gw, alice, bob); env.close(); env(fset(gw, asfRequireAuth)); + env.close(); env(trust(alice, gw["USD"](30'000), 0)); env(trust(gw, alice["USD"](0), tfSetfAuth)); // Bob trusts Gateway to owe him USD... @@ -2230,6 +2232,7 @@ private: // Equal withdrawal by Carol: 1000000 of tokens, 10% of the current // pool testAMM([&](AMM& ammAlice, Env& env) { + auto const baseFee = env.current()->fees().base.drops(); // Single deposit of 100000 worth of tokens, // which is 10% of the pool. Carol is LP now. ammAlice.deposit(carol, 1'000'000); @@ -2240,16 +2243,16 @@ private: // 30,000 less deposited 1,000 BEAST_EXPECT(expectLine(env, carol, USD(29'000))); // 30,000 less deposited 1,000 and 10 drops tx fee - BEAST_EXPECT( - expectLedgerEntryRoot(env, carol, XRPAmount{28'999'999'990})); + BEAST_EXPECT(expectLedgerEntryRoot( + env, carol, XRPAmount{29'000'000'000 - baseFee})); // Carol withdraws all tokens ammAlice.withdraw(carol, 1'000'000); BEAST_EXPECT( ammAlice.expectLPTokens(carol, IOUAmount(beast::Zero()))); BEAST_EXPECT(expectLine(env, carol, USD(30'000))); - BEAST_EXPECT( - expectLedgerEntryRoot(env, carol, XRPAmount{29'999'999'980})); + BEAST_EXPECT(expectLedgerEntryRoot( + env, carol, XRPAmount{30'000'000'000 - 2 * baseFee})); }); // Equal withdrawal by tokens 1000000, 10% @@ -3301,12 +3304,14 @@ private: // preflight tests { Env env(*this, features); + auto const baseFee = env.current()->fees().base; + fund(env, gw, {alice, bob}, XRP(2'000), {USD(2'000)}); AMM amm(env, gw, XRP(1'000), USD(1'010), false, 1'000); Json::Value tx = amm.bid({.account = alice, .bidMin = 500}); { - auto jtx = env.jt(tx, seq(1), fee(10)); + auto jtx = env.jt(tx, seq(1), fee(baseFee)); env.app().config().features.erase(featureAMM); PreflightContext pfctx( env.app(), @@ -3320,7 +3325,7 @@ private: } { - auto jtx = env.jt(tx, seq(1), fee(10)); + auto jtx = env.jt(tx, seq(1), fee(baseFee)); jtx.jv["TxnSignature"] = "deadbeef"; jtx.stx = env.ust(jtx); PreflightContext pfctx( @@ -3334,7 +3339,7 @@ private: } { - auto jtx = env.jt(tx, seq(1), fee(10)); + auto jtx = env.jt(tx, seq(1), fee(baseFee)); jtx.jv["Asset2"]["currency"] = "XAH"; jtx.jv["Asset2"].removeMember("issuer"); jtx.stx = env.ust(jtx); @@ -3393,11 +3398,12 @@ private: // Can't pay into AMM with escrow. testAMM([&](AMM& ammAlice, Env& env) { + auto const baseFee = env.current()->fees().base; env(escrow(carol, ammAlice.ammAccount(), XRP(1)), condition(cb1), finish_time(env.now() + 1s), cancel_time(env.now() + 2s), - fee(1'500), + fee(baseFee * 150), ter(tecNO_PERMISSION)); }); @@ -3817,11 +3823,14 @@ private: { Env env(*this, features); fund(env, gw, {alice, bob, carol}, XRP(20'000), {USD(2'000)}); + env.close(); env(offer(bob, XRP(50), USD(150)), txflags(tfPassive)); + env.close(); AMM ammAlice(env, alice, XRP(1'000), USD(1'050)); env(pay(alice, carol, USD(200)), sendmax(XRP(200)), txflags(tfPartialPayment)); + env.close(); BEAST_EXPECT(ammAlice.expectBalances( XRP(1'050), USD(1'000), ammAlice.tokens())); BEAST_EXPECT(expectLine(env, carol, USD(2'200))); @@ -4344,7 +4353,9 @@ private: 0); // Carol withdraws ammAlice.withdrawAll(carol, XRP(0)); - BEAST_EXPECT(accountBalance(env, carol) == "29999949949"); + BEAST_EXPECT( + accountBalance(env, carol) == + std::to_string(29999949999 - 5 * baseFee)); BEAST_EXPECT(ammAlice.expectBalances( XRPAmount{10'000'000'000} - priceXRP, USD(10'000), @@ -4982,7 +4993,10 @@ private: STAmount{USD, UINT64_C(30'000'0000000003), -10})); // alice XRP balance is 30,000initial - 50 ammcreate fee - // 10drops fee - BEAST_EXPECT(accountBalance(env, alice) == "29949999990"); + BEAST_EXPECT( + accountBalance(env, alice) == + std::to_string( + 29950000000 - env.current()->fees().base.drops())); }, std::nullopt, 0, diff --git a/src/test/app/Check_test.cpp b/src/test/app/Check_test.cpp index d27df4646..99b0c8dba 100644 --- a/src/test/app/Check_test.cpp +++ b/src/test/app/Check_test.cpp @@ -150,6 +150,7 @@ class Check_test : public beast::unit_test::suite Env env{*this, features - featureChecks}; env.fund(XRP(1000), alice); + env.close(); uint256 const checkId{ getCheckIndex(env.master, env.seq(env.master))}; @@ -168,6 +169,7 @@ class Check_test : public beast::unit_test::suite Env env{*this, features}; env.fund(XRP(1000), alice); + env.close(); uint256 const checkId1{ getCheckIndex(env.master, env.seq(env.master))}; @@ -204,6 +206,7 @@ class Check_test : public beast::unit_test::suite STAmount const startBalance{XRP(1000).value()}; env.fund(startBalance, gw, alice, bob); + env.close(); // Note that no trust line has been set up for alice, but alice can // still write a check for USD. You don't have to have the funds @@ -314,6 +317,7 @@ class Check_test : public beast::unit_test::suite STAmount const startBalance{XRP(1000).value()}; env.fund(startBalance, gw, alice, bob); + env.close(); /* * Attempt to create two checks from `from` to `to` and @@ -398,6 +402,7 @@ class Check_test : public beast::unit_test::suite STAmount const startBalance{XRP(1000).value()}; env.fund(startBalance, gw1, gwF, alice, bob); + env.close(); // Bad fee. env(check::create(alice, bob, USD(50)), @@ -551,6 +556,7 @@ class Check_test : public beast::unit_test::suite // Insufficient reserve. Account const cheri{"cheri"}; env.fund(env.current()->fees().accountReserve(1) - drops(1), cheri); + env.close(); env(check::create(cheri, bob, USD(50)), fee(drops(env.current()->fees().base)), @@ -580,6 +586,7 @@ class Check_test : public beast::unit_test::suite XRPAmount const baseFeeDrops{env.current()->fees().base}; STAmount const startBalance{XRP(300).value()}; env.fund(startBalance, alice, bob); + env.close(); { // Basic XRP check. uint256 const chkId{getCheckIndex(alice, env.seq(alice))}; @@ -703,6 +710,7 @@ class Check_test : public beast::unit_test::suite Env env{*this, features}; env.fund(XRP(1000), gw, alice, bob); + env.close(); // alice writes the check before she gets the funds. uint256 const chkId1{getCheckIndex(alice, env.seq(alice))}; @@ -863,6 +871,7 @@ class Check_test : public beast::unit_test::suite Env env{*this, features}; env.fund(XRP(1000), gw, alice, bob); + env.close(); env(trust(alice, USD(20))); env(trust(bob, USD(20))); @@ -1016,6 +1025,7 @@ class Check_test : public beast::unit_test::suite Env env{*this, testFeatures}; env.fund(XRP(1000), gw, alice, bob); + env.close(); // alice creates her checks ahead of time. uint256 const chkId1{getCheckIndex(alice, env.seq(alice))}; @@ -1089,6 +1099,7 @@ class Check_test : public beast::unit_test::suite Env env{*this, features}; env.fund(XRP(1000), gw, alice, bob); + env.close(); env(trust(alice, USD(1000))); env(trust(bob, USD(1000))); @@ -1159,6 +1170,7 @@ class Check_test : public beast::unit_test::suite Env env{*this, features}; env.fund(XRP(1000), gw, alice, bob); + env.close(); env(trust(alice, USD(1000))); env(trust(bob, USD(1000))); @@ -1367,6 +1379,7 @@ class Check_test : public beast::unit_test::suite Env env(*this, features); env.fund(XRP(1000), gw, alice, bob, zoe); + env.close(); // Now set up alice's trustline. env(trust(alice, USD(20))); @@ -1671,6 +1684,7 @@ class Check_test : public beast::unit_test::suite Env env{*this, testFeatures}; env.fund(XRP(1000), gw, alice, bob, zoe); + env.close(); // alice creates her checks ahead of time. // Three ordinary checks with no expiration. @@ -1832,6 +1846,7 @@ class Check_test : public beast::unit_test::suite Env env{*this, features}; env.fund(XRP(1000), alice, bob); + env.close(); // Bad fee. env(check::cancel(bob, getCheckIndex(alice, env.seq(alice))), @@ -1991,12 +2006,10 @@ class Check_test : public beast::unit_test::suite BEAST_EXPECT(checksOnAccount(env, alice).size() == 0); BEAST_EXPECT(env.seq(alice) == aliceSeq); env.require(balance(alice, USD(700))); - env.require(balance(alice, drops(699'999'940))); env.require(owners(bob, 6)); BEAST_EXPECT(env.seq(bob) == bobSeq); env.require(balance(bob, USD(200))); - env.require(balance(bob, drops(1'299'999'940))); } void diff --git a/src/test/app/DID_test.cpp b/src/test/app/DID_test.cpp index d1626b647..345d7f95a 100644 --- a/src/test/app/DID_test.cpp +++ b/src/test/app/DID_test.cpp @@ -74,6 +74,7 @@ struct DID_test : public beast::unit_test::suite // the reserve for creating a DID. auto const acctReserve = env.current()->fees().accountReserve(0); auto const incReserve = env.current()->fees().increment; + auto const baseFee = env.current()->fees().base; env.fund(acctReserve, alice); env.close(); BEAST_EXPECT(env.balance(alice) == acctReserve); @@ -85,8 +86,10 @@ struct DID_test : public beast::unit_test::suite BEAST_EXPECT(ownerCount(env, alice) == 0); // Pay alice almost enough to make the reserve for a DID. - env(pay(env.master, alice, incReserve + drops(19))); - BEAST_EXPECT(env.balance(alice) == acctReserve + incReserve + drops(9)); + env(pay(env.master, alice, drops(incReserve + 2 * baseFee - 1))); + BEAST_EXPECT( + env.balance(alice) == + acctReserve + incReserve + drops(baseFee - 1)); env.close(); // alice still does not have enough XRP for the reserve of a DID. @@ -95,7 +98,7 @@ struct DID_test : public beast::unit_test::suite BEAST_EXPECT(ownerCount(env, alice) == 0); // Pay alice enough to make the reserve for a DID. - env(pay(env.master, alice, drops(11))); + env(pay(env.master, alice, drops(baseFee + 1))); env.close(); // Now alice can create a DID. diff --git a/src/test/app/DeliverMin_test.cpp b/src/test/app/DeliverMin_test.cpp index 3c5fd43c1..b079b9368 100644 --- a/src/test/app/DeliverMin_test.cpp +++ b/src/test/app/DeliverMin_test.cpp @@ -40,7 +40,9 @@ public: { Env env(*this, features); env.fund(XRP(10000), "alice", "bob", "carol", gw); + env.close(); env.trust(USD(100), "alice", "bob", "carol"); + env.close(); env(pay("alice", "bob", USD(10)), delivermin(USD(10)), ter(temBAD_AMOUNT)); @@ -68,14 +70,17 @@ public: txflags(tfPartialPayment), sendmax(XRP(5)), ter(tecPATH_PARTIAL)); - env.require(balance("alice", XRP(9999.99999))); + env.require(balance( + "alice", XRP(10000) - drops(env.current()->fees().base))); env.require(balance("bob", XRP(10000))); } { Env env(*this, features); env.fund(XRP(10000), "alice", "bob", gw); + env.close(); env.trust(USD(1000), "alice", "bob"); + env.close(); env(pay(gw, "bob", USD(100))); env(offer("bob", XRP(100), USD(100))); env(pay("alice", "alice", USD(10000)), @@ -89,7 +94,9 @@ public: { Env env(*this, features); env.fund(XRP(10000), "alice", "bob", "carol", gw); + env.close(); env.trust(USD(1000), "bob", "carol"); + env.close(); env(pay(gw, "bob", USD(200))); env(offer("bob", XRP(100), USD(100))); env(offer("bob", XRP(1000), USD(100))); @@ -112,7 +119,9 @@ public: { Env env(*this, features); env.fund(XRP(10000), "alice", "bob", "carol", "dan", gw); + env.close(); env.trust(USD(1000), "bob", "carol", "dan"); + env.close(); env(pay(gw, "bob", USD(100))); env(pay(gw, "dan", USD(100))); env(offer("bob", XRP(100), USD(100))); diff --git a/src/test/app/DepositAuth_test.cpp b/src/test/app/DepositAuth_test.cpp index 3b20710b1..dc610c0a4 100644 --- a/src/test/app/DepositAuth_test.cpp +++ b/src/test/app/DepositAuth_test.cpp @@ -97,6 +97,7 @@ struct DepositAuth_test : public beast::unit_test::suite Env env(*this, features); env.fund(XRP(10000), alice, bob, carol, gw); + env.close(); env.trust(USD(1000), alice, bob); env.close(); @@ -187,18 +188,20 @@ struct DepositAuth_test : public beast::unit_test::suite Account const bob{"bob"}; Env env(*this, features); + auto const baseFee = env.current()->fees().base; env.fund(XRP(10000), alice, bob); + env.close(); // bob sets the lsfDepositAuth flag. - env(fset(bob, asfDepositAuth), fee(drops(10))); + env(fset(bob, asfDepositAuth), fee(drops(baseFee))); env.close(); - BEAST_EXPECT(env.balance(bob, XRP) == XRP(10000) - drops(10)); + BEAST_EXPECT(env.balance(bob, XRP) == XRP(10000) - drops(baseFee)); // bob has more XRP than the base reserve. Any XRP payment should fail. env(pay(alice, bob, drops(1)), ter(tecNO_PERMISSION)); env.close(); - BEAST_EXPECT(env.balance(bob, XRP) == XRP(10000) - drops(10)); + BEAST_EXPECT(env.balance(bob, XRP) == XRP(10000) - drops(baseFee)); // Change bob's XRP balance to exactly the base reserve. { @@ -260,7 +263,7 @@ struct DepositAuth_test : public beast::unit_test::suite BEAST_EXPECT(env.balance(bob, XRP) == drops(1)); // Pay bob enough so he can afford the fee to clear lsfDepositAuth. - env(pay(alice, bob, drops(9))); + env(pay(alice, bob, drops(baseFee - 1))); env.close(); // Interestingly, at this point the terINSUF_FEE_B retry grabs the @@ -302,6 +305,7 @@ struct DepositAuth_test : public beast::unit_test::suite Env env(*this, features); env.fund(XRP(10000), gw1, alice, bob); + env.close(); env(trust(gw1, alice["USD"](10), noRipplePrev ? tfSetNoRipple : 0)); env(trust(gw1, bob["USD"](10), noRippleNext ? tfSetNoRipple : 0)); env.trust(USD1(10), alice, bob); @@ -325,6 +329,7 @@ struct DepositAuth_test : public beast::unit_test::suite Env env(*this, features); env.fund(XRP(10000), gw1, gw2, alice); + env.close(); env(trust(alice, USD1(10), noRipplePrev ? tfSetNoRipple : 0)); env(trust(alice, USD2(10), noRippleNext ? tfSetNoRipple : 0)); env(pay(gw2, alice, USD2(10))); @@ -573,7 +578,7 @@ struct DepositPreauth_test : public beast::unit_test::suite env.require(owners(becky, 0)); // carol gets enough XRP to (barely) meet the reserve. - env(pay(alice, carol, drops(11))); + env(pay(alice, carol, drops(env.current()->fees().base + 1))); env.close(); env(deposit::auth(carol, becky)); env.close(); @@ -663,6 +668,7 @@ struct DepositPreauth_test : public beast::unit_test::suite const char credType[] = "abcde"; Account const carol{"carol"}; env.fund(XRP(5000), carol); + env.close(); bool const supportsCredentials = features[featureCredentials]; @@ -1127,6 +1133,7 @@ struct DepositPreauth_test : public beast::unit_test::suite // not enough reserve Account const john{"john"}; env.fund(env.current()->fees().accountReserve(0), john); + env.close(); auto jv = deposit::authCredentials(john, {{issuer, credType}}); env(jv, ter(tecINSUFFICIENT_RESERVE)); } diff --git a/src/test/app/Escrow_test.cpp b/src/test/app/Escrow_test.cpp index e87ccc3f0..2fe53ecc6 100644 --- a/src/test/app/Escrow_test.cpp +++ b/src/test/app/Escrow_test.cpp @@ -124,7 +124,8 @@ struct Escrow_test : public beast::unit_test::suite using namespace jtx; using namespace std::chrono; - Env env{*this, features}; + Env env(*this, features); + auto const baseFee = env.current()->fees().base; env.fund(XRP(5000), "alice", "bob"); env(escrow("alice", "bob", XRP(1000)), finish_time(env.now() + 1s)); env.close(); @@ -134,12 +135,12 @@ struct Escrow_test : public beast::unit_test::suite env(escrow("alice", "bob", XRP(1000)), condition(cb1), finish_time(env.now() + 1s), - fee(1500)); + fee(baseFee * 150)); env.close(); env(finish("bob", "alice", seq1), condition(cb1), fulfillment(fb1), - fee(1500)); + fee(baseFee * 150)); auto const seq2 = env.seq("alice"); @@ -147,9 +148,9 @@ struct Escrow_test : public beast::unit_test::suite condition(cb2), finish_time(env.now() + 1s), cancel_time(env.now() + 2s), - fee(1500)); + fee(baseFee * 150)); env.close(); - env(cancel("bob", "alice", seq2), fee(1500)); + env(cancel("bob", "alice", seq2), fee(baseFee * 150)); } void @@ -160,7 +161,8 @@ struct Escrow_test : public beast::unit_test::suite { testcase("Timing: Finish Only"); - Env env{*this, features}; + Env env(*this, features); + auto const baseFee = env.current()->fees().base; env.fund(XRP(5000), "alice", "bob"); env.close(); @@ -174,15 +176,16 @@ struct Escrow_test : public beast::unit_test::suite // prematurely. for (; env.now() < ts; env.close()) env(finish("bob", "alice", seq), - fee(1500), + fee(baseFee * 150), ter(tecNO_PERMISSION)); - env(finish("bob", "alice", seq), fee(1500)); + env(finish("bob", "alice", seq), fee(baseFee * 150)); } { testcase("Timing: Cancel Only"); - Env env{*this, features}; + Env env(*this, features); + auto const baseFee = env.current()->fees().base; env.fund(XRP(5000), "alice", "bob"); env.close(); @@ -198,23 +201,24 @@ struct Escrow_test : public beast::unit_test::suite // prematurely. for (; env.now() < ts; env.close()) env(cancel("bob", "alice", seq), - fee(1500), + fee(baseFee * 150), ter(tecNO_PERMISSION)); // Verify that a finish won't work anymore. env(finish("bob", "alice", seq), condition(cb1), fulfillment(fb1), - fee(1500), + fee(baseFee * 150), ter(tecNO_PERMISSION)); // Verify that the cancel will succeed - env(cancel("bob", "alice", seq), fee(1500)); + env(cancel("bob", "alice", seq), fee(baseFee * 150)); } { testcase("Timing: Finish and Cancel -> Finish"); - Env env{*this, features}; + Env env(*this, features); + auto const baseFee = env.current()->fees().base; env.fund(XRP(5000), "alice", "bob"); env.close(); @@ -232,23 +236,26 @@ struct Escrow_test : public beast::unit_test::suite for (; env.now() < fts; env.close()) { env(finish("bob", "alice", seq), - fee(1500), + fee(baseFee * 150), ter(tecNO_PERMISSION)); env(cancel("bob", "alice", seq), - fee(1500), + fee(baseFee * 150), ter(tecNO_PERMISSION)); } // Verify that a cancel still won't work - env(cancel("bob", "alice", seq), fee(1500), ter(tecNO_PERMISSION)); + env(cancel("bob", "alice", seq), + fee(baseFee * 150), + ter(tecNO_PERMISSION)); // And verify that a finish will - env(finish("bob", "alice", seq), fee(1500)); + env(finish("bob", "alice", seq), fee(baseFee * 150)); } { testcase("Timing: Finish and Cancel -> Cancel"); - Env env{*this, features}; + Env env(*this, features); + auto const baseFee = env.current()->fees().base; env.fund(XRP(5000), "alice", "bob"); env.close(); @@ -266,10 +273,10 @@ struct Escrow_test : public beast::unit_test::suite for (; env.now() < fts; env.close()) { env(finish("bob", "alice", seq), - fee(1500), + fee(baseFee * 150), ter(tecNO_PERMISSION)); env(cancel("bob", "alice", seq), - fee(1500), + fee(baseFee * 150), ter(tecNO_PERMISSION)); } @@ -277,15 +284,17 @@ struct Escrow_test : public beast::unit_test::suite // prematurely. At this point a finish would succeed. for (; env.now() < cts; env.close()) env(cancel("bob", "alice", seq), - fee(1500), + fee(baseFee * 150), ter(tecNO_PERMISSION)); // Verify that finish will no longer work, since we are past the // cancel activation time. - env(finish("bob", "alice", seq), fee(1500), ter(tecNO_PERMISSION)); + env(finish("bob", "alice", seq), + fee(baseFee * 150), + ter(tecNO_PERMISSION)); // And verify that a cancel will succeed. - env(cancel("bob", "alice", seq), fee(1500)); + env(cancel("bob", "alice", seq), fee(baseFee * 150)); } } @@ -364,6 +373,7 @@ struct Escrow_test : public beast::unit_test::suite testcase("Implied Finish Time (without fix1571)"); Env env(*this, supported_amendments() - fix1571); + auto const baseFee = env.current()->fees().base; env.fund(XRP(5000), "alice", "bob", "carol"); env.close(); @@ -372,9 +382,9 @@ struct Escrow_test : public beast::unit_test::suite auto const seq1 = env.seq("alice"); env(escrow("alice", "bob", XRP(100)), cancel_time(env.now() + 1s), - fee(1500)); + fee(baseFee * 150)); env.close(); - env(finish("carol", "alice", seq1), fee(1500)); + env(finish("carol", "alice", seq1), fee(baseFee * 150)); BEAST_EXPECT(env.balance("bob") == XRP(5100)); env.close(); @@ -385,26 +395,27 @@ struct Escrow_test : public beast::unit_test::suite env(escrow("alice", "bob", XRP(100)), cancel_time(env.now() + 1s), condition(cb1), - fee(1500)); + fee(baseFee * 150)); env.close(); env(finish("carol", "alice", seq2), condition(cb1), fulfillment(fb1), - fee(1500)); + fee(baseFee * 150)); BEAST_EXPECT(env.balance("bob") == XRP(5200)); } { testcase("Implied Finish Time (with fix1571)"); - Env env{*this, features}; + Env env(*this, features); + auto const baseFee = env.current()->fees().base; env.fund(XRP(5000), "alice", "bob", "carol"); env.close(); // Creating an escrow with only a cancel time is not allowed: env(escrow("alice", "bob", XRP(100)), cancel_time(env.now() + 90s), - fee(1500), + fee(baseFee * 150), ter(temMALFORMED)); // Creating an escrow with only a cancel time and a condition is @@ -413,12 +424,12 @@ struct Escrow_test : public beast::unit_test::suite env(escrow("alice", "bob", XRP(100)), cancel_time(env.now() + 90s), condition(cb1), - fee(1500)); + fee(baseFee * 150)); env.close(); env(finish("carol", "alice", seq), condition(cb1), fulfillment(fb1), - fee(1500)); + fee(baseFee * 150)); BEAST_EXPECT(env.balance("bob") == XRP(5100)); } } @@ -431,7 +442,8 @@ struct Escrow_test : public beast::unit_test::suite using namespace jtx; using namespace std::chrono; - Env env{*this, features}; + Env env(*this, features); + auto const baseFee = env.current()->fees().base; env.fund(XRP(5000), "alice", "bob"); env.close(); @@ -534,10 +546,10 @@ struct Escrow_test : public beast::unit_test::suite auto const seq = env.seq("hannah"); env(escrow("hannah", "hannah", XRP(10)), finish_time(env.now() + 1s), - fee(1500)); + fee(150 * baseFee)); env.close(); env(finish("hannah", "hannah", seq + 7), - fee(1500), + fee(150 * baseFee), ter(tecNO_TARGET)); } @@ -550,7 +562,7 @@ struct Escrow_test : public beast::unit_test::suite env(finish("ivan", "ivan", seq), condition(cb1), fulfillment(fb1), - fee(1500), + fee(150 * baseFee), ter(tecCRYPTOCONDITION_ERROR)); } } @@ -565,12 +577,13 @@ struct Escrow_test : public beast::unit_test::suite { // Unconditional - Env env{*this, features}; + Env env(*this, features); + auto const baseFee = env.current()->fees().base; env.fund(XRP(5000), "alice", "bob"); auto const seq = env.seq("alice"); env(escrow("alice", "alice", XRP(1000)), finish_time(env.now() + 5s)); - env.require(balance("alice", XRP(4000) - drops(10))); + env.require(balance("alice", XRP(4000) - drops(baseFee))); // Not enough time has elapsed for a finish and canceling isn't // possible. @@ -583,17 +596,18 @@ struct Escrow_test : public beast::unit_test::suite // Finish should succeed. Verify funds. env(finish("bob", "alice", seq)); - env.require(balance("alice", XRP(5000) - drops(10))); + env.require(balance("alice", XRP(5000) - drops(baseFee))); } { // Unconditionally pay from Alice to Bob. Zelda (neither source nor // destination) signs all cancels and finishes. This shows that // Escrow will make a payment to Bob with no intervention from Bob. - Env env{*this, features}; + Env env(*this, features); + auto const baseFee = env.current()->fees().base; env.fund(XRP(5000), "alice", "bob", "zelda"); auto const seq = env.seq("alice"); env(escrow("alice", "bob", XRP(1000)), finish_time(env.now() + 5s)); - env.require(balance("alice", XRP(4000) - drops(10))); + env.require(balance("alice", XRP(4000) - drops(baseFee))); // Not enough time has elapsed for a finish and canceling isn't // possible. @@ -608,13 +622,14 @@ struct Escrow_test : public beast::unit_test::suite env(finish("zelda", "alice", seq)); env.close(); - env.require(balance("alice", XRP(4000) - drops(10))); + env.require(balance("alice", XRP(4000) - drops(baseFee))); env.require(balance("bob", XRP(6000))); - env.require(balance("zelda", XRP(5000) - drops(40))); + env.require(balance("zelda", XRP(5000) - drops(4 * baseFee))); } { // Bob sets DepositAuth so only Bob can finish the escrow. - Env env{*this, features}; + Env env(*this, features); + auto const baseFee = env.current()->fees().base; env.fund(XRP(5000), "alice", "bob", "zelda"); env(fset("bob", asfDepositAuth)); @@ -622,7 +637,7 @@ struct Escrow_test : public beast::unit_test::suite auto const seq = env.seq("alice"); env(escrow("alice", "bob", XRP(1000)), finish_time(env.now() + 5s)); - env.require(balance("alice", XRP(4000) - drops(10))); + env.require(balance("alice", XRP(4000) - drops(baseFee))); // Not enough time has elapsed for a finish and canceling isn't // possible. @@ -644,7 +659,6 @@ struct Escrow_test : public beast::unit_test::suite env(finish("bob", "alice", seq)); env.close(); - auto const baseFee = env.current()->fees().base; env.require(balance("alice", XRP(4000) - (baseFee * 5))); env.require(balance("bob", XRP(6000) - (baseFee * 5))); env.require(balance("zelda", XRP(5000) - (baseFee * 4))); @@ -652,7 +666,8 @@ struct Escrow_test : public beast::unit_test::suite { // Bob sets DepositAuth but preauthorizes Zelda, so Zelda can // finish the escrow. - Env env{*this, features}; + Env env(*this, features); + auto const baseFee = env.current()->fees().base; env.fund(XRP(5000), "alice", "bob", "zelda"); env(fset("bob", asfDepositAuth)); @@ -662,7 +677,7 @@ struct Escrow_test : public beast::unit_test::suite auto const seq = env.seq("alice"); env(escrow("alice", "bob", XRP(1000)), finish_time(env.now() + 5s)); - env.require(balance("alice", XRP(4000) - drops(10))); + env.require(balance("alice", XRP(4000) - drops(baseFee))); env.close(); // DepositPreauth allows Finish to succeed for either Zelda or @@ -672,20 +687,20 @@ struct Escrow_test : public beast::unit_test::suite env(finish("zelda", "alice", seq)); env.close(); - auto const baseFee = env.current()->fees().base; env.require(balance("alice", XRP(4000) - (baseFee * 2))); env.require(balance("bob", XRP(6000) - (baseFee * 2))); env.require(balance("zelda", XRP(5000) - (baseFee * 1))); } { // Conditional - Env env{*this, features}; + Env env(*this, features); + auto const baseFee = env.current()->fees().base; env.fund(XRP(5000), "alice", "bob"); auto const seq = env.seq("alice"); env(escrow("alice", "alice", XRP(1000)), condition(cb2), finish_time(env.now() + 5s)); - env.require(balance("alice", XRP(4000) - drops(10))); + env.require(balance("alice", XRP(4000) - drops(baseFee))); // Not enough time has elapsed for a finish and canceling isn't // possible. @@ -695,13 +710,13 @@ struct Escrow_test : public beast::unit_test::suite env(finish("alice", "alice", seq), condition(cb2), fulfillment(fb2), - fee(1500), + fee(150 * baseFee), ter(tecNO_PERMISSION)); env(finish("bob", "alice", seq), ter(tecNO_PERMISSION)); env(finish("bob", "alice", seq), condition(cb2), fulfillment(fb2), - fee(1500), + fee(150 * baseFee), ter(tecNO_PERMISSION)); env.close(); @@ -716,18 +731,19 @@ struct Escrow_test : public beast::unit_test::suite env(finish("bob", "alice", seq), condition(cb2), fulfillment(fb2), - fee(1500)); + fee(150 * baseFee)); } { // Self-escrowed conditional with DepositAuth. - Env env{*this, features}; + Env env(*this, features); + auto const baseFee = env.current()->fees().base; env.fund(XRP(5000), "alice", "bob"); auto const seq = env.seq("alice"); env(escrow("alice", "alice", XRP(1000)), condition(cb3), finish_time(env.now() + 5s)); - env.require(balance("alice", XRP(4000) - drops(10))); + env.require(balance("alice", XRP(4000) - drops(baseFee))); env.close(); // Finish is now possible but requires the cryptocondition. @@ -742,28 +758,29 @@ struct Escrow_test : public beast::unit_test::suite env(finish("alice", "alice", seq), condition(cb2), fulfillment(fb2), - fee(1500), + fee(150 * baseFee), ter(tecCRYPTOCONDITION_ERROR)); env(finish("bob", "alice", seq), condition(cb3), fulfillment(fb3), - fee(1500), + fee(150 * baseFee), ter(tecNO_PERMISSION)); env(finish("alice", "alice", seq), condition(cb3), fulfillment(fb3), - fee(1500)); + fee(150 * baseFee)); } { // Self-escrowed conditional with DepositAuth and DepositPreauth. - Env env{*this, features}; + Env env(*this, features); + auto const baseFee = env.current()->fees().base; env.fund(XRP(5000), "alice", "bob", "zelda"); auto const seq = env.seq("alice"); env(escrow("alice", "alice", XRP(1000)), condition(cb3), finish_time(env.now() + 5s)); - env.require(balance("alice", XRP(4000) - drops(10))); + env.require(balance("alice", XRP(4000) - drops(baseFee))); env.close(); // Alice preauthorizes Zelda for deposit, even though Alice has not @@ -784,17 +801,17 @@ struct Escrow_test : public beast::unit_test::suite env(finish("alice", "alice", seq), condition(cb2), fulfillment(fb2), - fee(1500), + fee(150 * baseFee), ter(tecCRYPTOCONDITION_ERROR)); env(finish("bob", "alice", seq), condition(cb3), fulfillment(fb3), - fee(1500), + fee(150 * baseFee), ter(tecNO_PERMISSION)); env(finish("zelda", "alice", seq), condition(cb3), fulfillment(fb3), - fee(1500)); + fee(150 * baseFee)); } } @@ -807,7 +824,8 @@ struct Escrow_test : public beast::unit_test::suite using namespace std::chrono; { // Test cryptoconditions - Env env{*this, features}; + Env env(*this, features); + auto const baseFee = env.current()->fees().base; env.fund(XRP(5000), "alice", "bob", "carol"); auto const seq = env.seq("alice"); BEAST_EXPECT((*env.le("alice"))[sfOwnerCount] == 0); @@ -815,7 +833,7 @@ struct Escrow_test : public beast::unit_test::suite condition(cb1), cancel_time(env.now() + 1s)); BEAST_EXPECT((*env.le("alice"))[sfOwnerCount] == 1); - env.require(balance("alice", XRP(4000) - drops(10))); + env.require(balance("alice", XRP(4000) - drops(baseFee))); env.require(balance("carol", XRP(5000))); env(cancel("bob", "alice", seq), ter(tecNO_PERMISSION)); BEAST_EXPECT((*env.le("alice"))[sfOwnerCount] == 1); @@ -828,19 +846,19 @@ struct Escrow_test : public beast::unit_test::suite env(finish("bob", "alice", seq), condition(cb1), fulfillment(cb1), - fee(1500), + fee(150 * baseFee), ter(tecCRYPTOCONDITION_ERROR)); BEAST_EXPECT((*env.le("alice"))[sfOwnerCount] == 1); env(finish("bob", "alice", seq), condition(cb1), fulfillment(cb2), - fee(1500), + fee(150 * baseFee), ter(tecCRYPTOCONDITION_ERROR)); BEAST_EXPECT((*env.le("alice"))[sfOwnerCount] == 1); env(finish("bob", "alice", seq), condition(cb1), fulfillment(cb3), - fee(1500), + fee(150 * baseFee), ter(tecCRYPTOCONDITION_ERROR)); BEAST_EXPECT((*env.le("alice"))[sfOwnerCount] == 1); @@ -849,19 +867,19 @@ struct Escrow_test : public beast::unit_test::suite env(finish("bob", "alice", seq), condition(cb2), fulfillment(fb1), - fee(1500), + fee(150 * baseFee), ter(tecCRYPTOCONDITION_ERROR)); BEAST_EXPECT((*env.le("alice"))[sfOwnerCount] == 1); env(finish("bob", "alice", seq), condition(cb2), fulfillment(fb2), - fee(1500), + fee(150 * baseFee), ter(tecCRYPTOCONDITION_ERROR)); BEAST_EXPECT((*env.le("alice"))[sfOwnerCount] == 1); env(finish("bob", "alice", seq), condition(cb2), fulfillment(fb3), - fee(1500), + fee(150 * baseFee), ter(tecCRYPTOCONDITION_ERROR)); BEAST_EXPECT((*env.le("alice"))[sfOwnerCount] == 1); @@ -869,7 +887,7 @@ struct Escrow_test : public beast::unit_test::suite env(finish("bob", "alice", seq), condition(cb1), fulfillment(fb1), - fee(1500)); + fee(150 * baseFee)); // SLE removed on finish BEAST_EXPECT(!env.le(keylet::escrow(Account("alice").id(), seq))); @@ -880,7 +898,8 @@ struct Escrow_test : public beast::unit_test::suite env(cancel("bob", "carol", 1), ter(tecNO_TARGET)); } { // Test cancel when condition is present - Env env{*this, features}; + Env env(*this, features); + auto const baseFee = env.current()->fees().base; env.fund(XRP(5000), "alice", "bob", "carol"); auto const seq = env.seq("alice"); BEAST_EXPECT((*env.le("alice"))[sfOwnerCount] == 0); @@ -888,15 +907,16 @@ struct Escrow_test : public beast::unit_test::suite condition(cb2), cancel_time(env.now() + 1s)); env.close(); - env.require(balance("alice", XRP(4000) - drops(10))); + env.require(balance("alice", XRP(4000) - drops(baseFee))); // balance restored on cancel env(cancel("bob", "alice", seq)); - env.require(balance("alice", XRP(5000) - drops(10))); + env.require(balance("alice", XRP(5000) - drops(baseFee))); // SLE removed on cancel BEAST_EXPECT(!env.le(keylet::escrow(Account("alice").id(), seq))); } { - Env env{*this, features}; + Env env(*this, features); + auto const baseFee = env.current()->fees().base; env.fund(XRP(5000), "alice", "bob", "carol"); env.close(); auto const seq = env.seq("alice"); @@ -912,7 +932,7 @@ struct Escrow_test : public beast::unit_test::suite env(finish("bob", "alice", seq), condition(cb3), fulfillment(fb3), - fee(1500), + fee(150 * baseFee), ter(tecNO_PERMISSION)); BEAST_EXPECT((*env.le("alice"))[sfOwnerCount] == 1); env.require(balance("carol", XRP(5000))); @@ -962,16 +982,17 @@ struct Escrow_test : public beast::unit_test::suite ter(temMALFORMED)); auto const seq = env.seq("alice"); + auto const baseFee = env.current()->fees().base; env(escrow("alice", "carol", XRP(1000)), condition(Slice{p + 1, s - 2}), cancel_time(ts), - fee(100)); + fee(10 * baseFee)); env(finish("bob", "alice", seq), condition(cb1), fulfillment(fb1), - fee(1500)); - env.require(balance("alice", XRP(4000) - drops(100))); - env.require(balance("bob", XRP(5000) - drops(1500))); + fee(150 * baseFee)); + env.require(balance("alice", XRP(4000) - drops(10 * baseFee))); + env.require(balance("bob", XRP(5000) - drops(150 * baseFee))); env.require(balance("carol", XRP(6000))); } { // Test long and short conditions & fulfillments during finish @@ -1026,97 +1047,98 @@ struct Escrow_test : public beast::unit_test::suite ter(temMALFORMED)); auto const seq = env.seq("alice"); + auto const baseFee = env.current()->fees().base; env(escrow("alice", "carol", XRP(1000)), condition(Slice{cp + 1, cs - 2}), cancel_time(ts), - fee(100)); + fee(10 * baseFee)); // Now, try to fulfill using the same sequence of // malformed conditions. env(finish("bob", "alice", seq), condition(Slice{cp, cs}), fulfillment(Slice{fp, fs}), - fee(1500), + fee(150 * baseFee), ter(tecCRYPTOCONDITION_ERROR)); env(finish("bob", "alice", seq), condition(Slice{cp, cs - 1}), fulfillment(Slice{fp, fs}), - fee(1500), + fee(150 * baseFee), ter(tecCRYPTOCONDITION_ERROR)); env(finish("bob", "alice", seq), condition(Slice{cp, cs - 2}), fulfillment(Slice{fp, fs}), - fee(1500), + fee(150 * baseFee), ter(tecCRYPTOCONDITION_ERROR)); env(finish("bob", "alice", seq), condition(Slice{cp + 1, cs - 1}), fulfillment(Slice{fp, fs}), - fee(1500), + fee(150 * baseFee), ter(tecCRYPTOCONDITION_ERROR)); env(finish("bob", "alice", seq), condition(Slice{cp + 1, cs - 3}), fulfillment(Slice{fp, fs}), - fee(1500), + fee(150 * baseFee), ter(tecCRYPTOCONDITION_ERROR)); env(finish("bob", "alice", seq), condition(Slice{cp + 2, cs - 2}), fulfillment(Slice{fp, fs}), - fee(1500), + fee(150 * baseFee), ter(tecCRYPTOCONDITION_ERROR)); env(finish("bob", "alice", seq), condition(Slice{cp + 2, cs - 3}), fulfillment(Slice{fp, fs}), - fee(1500), + fee(150 * baseFee), ter(tecCRYPTOCONDITION_ERROR)); // Now, using the correct condition, try malformed fulfillments: env(finish("bob", "alice", seq), condition(Slice{cp + 1, cs - 2}), fulfillment(Slice{fp, fs}), - fee(1500), + fee(150 * baseFee), ter(tecCRYPTOCONDITION_ERROR)); env(finish("bob", "alice", seq), condition(Slice{cp + 1, cs - 2}), fulfillment(Slice{fp, fs - 1}), - fee(1500), + fee(150 * baseFee), ter(tecCRYPTOCONDITION_ERROR)); env(finish("bob", "alice", seq), condition(Slice{cp + 1, cs - 2}), fulfillment(Slice{fp, fs - 2}), - fee(1500), + fee(150 * baseFee), ter(tecCRYPTOCONDITION_ERROR)); env(finish("bob", "alice", seq), condition(Slice{cp + 1, cs - 2}), fulfillment(Slice{fp + 1, fs - 1}), - fee(1500), + fee(150 * baseFee), ter(tecCRYPTOCONDITION_ERROR)); env(finish("bob", "alice", seq), condition(Slice{cp + 1, cs - 2}), fulfillment(Slice{fp + 1, fs - 3}), - fee(1500), + fee(150 * baseFee), ter(tecCRYPTOCONDITION_ERROR)); env(finish("bob", "alice", seq), condition(Slice{cp + 1, cs - 2}), fulfillment(Slice{fp + 1, fs - 3}), - fee(1500), + fee(150 * baseFee), ter(tecCRYPTOCONDITION_ERROR)); env(finish("bob", "alice", seq), condition(Slice{cp + 1, cs - 2}), fulfillment(Slice{fp + 2, fs - 2}), - fee(1500), + fee(150 * baseFee), ter(tecCRYPTOCONDITION_ERROR)); env(finish("bob", "alice", seq), condition(Slice{cp + 1, cs - 2}), fulfillment(Slice{fp + 2, fs - 3}), - fee(1500), + fee(150 * baseFee), ter(tecCRYPTOCONDITION_ERROR)); // Now try for the right one env(finish("bob", "alice", seq), condition(cb2), fulfillment(fb2), - fee(1500)); - env.require(balance("alice", XRP(4000) - drops(100))); + fee(150 * baseFee)); + env.require(balance("alice", XRP(4000) - drops(10 * baseFee))); env.require(balance("carol", XRP(6000))); } { // Test empty condition during creation and @@ -1130,6 +1152,7 @@ struct Escrow_test : public beast::unit_test::suite ter(temMALFORMED)); auto const seq = env.seq("alice"); + auto const baseFee = env.current()->fees().base; env(escrow("alice", "carol", XRP(1000)), condition(cb3), cancel_time(env.now() + 1s)); @@ -1137,17 +1160,17 @@ struct Escrow_test : public beast::unit_test::suite env(finish("bob", "alice", seq), condition(Slice{}), fulfillment(Slice{}), - fee(1500), + fee(150 * baseFee), ter(tecCRYPTOCONDITION_ERROR)); env(finish("bob", "alice", seq), condition(cb3), fulfillment(Slice{}), - fee(1500), + fee(150 * baseFee), ter(tecCRYPTOCONDITION_ERROR)); env(finish("bob", "alice", seq), condition(Slice{}), fulfillment(fb3), - fee(1500), + fee(150 * baseFee), ter(tecCRYPTOCONDITION_ERROR)); // Assemble finish that is missing the Condition or the Fulfillment @@ -1161,9 +1184,9 @@ struct Escrow_test : public beast::unit_test::suite env(finish("bob", "alice", seq), condition(cb3), fulfillment(fb3), - fee(1500)); + fee(150 * baseFee)); env.require(balance("carol", XRP(6000))); - env.require(balance("alice", XRP(4000) - drops(10))); + env.require(balance("alice", XRP(4000) - drops(baseFee))); } { // Test a condition other than PreimageSha256, which // would require a separate amendment @@ -1370,7 +1393,8 @@ struct Escrow_test : public beast::unit_test::suite using namespace jtx; using namespace std::chrono; - Env env{*this, features}; + Env env(*this, features); + auto const baseFee = env.current()->fees().base; env.memoize("alice"); env.memoize("bob"); @@ -1381,7 +1405,7 @@ struct Escrow_test : public beast::unit_test::suite escrow("alice", "carol", XRP(1000)), finish_time(env.now() + 1s), seq(1), - fee(10)); + fee(baseFee)); auto const pf = preflight( env.app(), env.current()->rules(), @@ -1390,12 +1414,13 @@ struct Escrow_test : public beast::unit_test::suite env.journal); BEAST_EXPECT(pf.ter == tesSUCCESS); BEAST_EXPECT(!pf.consequences.isBlocker()); - BEAST_EXPECT(pf.consequences.fee() == drops(10)); + BEAST_EXPECT(pf.consequences.fee() == drops(baseFee)); BEAST_EXPECT(pf.consequences.potentialSpend() == XRP(1000)); } { - auto const jtx = env.jt(cancel("bob", "alice", 3), seq(1), fee(10)); + auto const jtx = + env.jt(cancel("bob", "alice", 3), seq(1), fee(baseFee)); auto const pf = preflight( env.app(), env.current()->rules(), @@ -1404,12 +1429,13 @@ struct Escrow_test : public beast::unit_test::suite env.journal); BEAST_EXPECT(pf.ter == tesSUCCESS); BEAST_EXPECT(!pf.consequences.isBlocker()); - BEAST_EXPECT(pf.consequences.fee() == drops(10)); + BEAST_EXPECT(pf.consequences.fee() == drops(baseFee)); BEAST_EXPECT(pf.consequences.potentialSpend() == XRP(0)); } { - auto const jtx = env.jt(finish("bob", "alice", 3), seq(1), fee(10)); + auto const jtx = + env.jt(finish("bob", "alice", 3), seq(1), fee(baseFee)); auto const pf = preflight( env.app(), env.current()->rules(), @@ -1418,7 +1444,7 @@ struct Escrow_test : public beast::unit_test::suite env.journal); BEAST_EXPECT(pf.ter == tesSUCCESS); BEAST_EXPECT(!pf.consequences.isBlocker()); - BEAST_EXPECT(pf.consequences.fee() == drops(10)); + BEAST_EXPECT(pf.consequences.fee() == drops(baseFee)); BEAST_EXPECT(pf.consequences.potentialSpend() == XRP(0)); } } @@ -1435,7 +1461,8 @@ struct Escrow_test : public beast::unit_test::suite { // Create escrow and finish using tickets. - Env env{*this, features}; + Env env(*this, features); + auto const baseFee = env.current()->fees().base; env.fund(XRP(5000), alice, bob); env.close(); @@ -1474,7 +1501,7 @@ struct Escrow_test : public beast::unit_test::suite for (; env.now() < ts; env.close()) { env(finish(bob, alice, escrowSeq), - fee(1500), + fee(150 * baseFee), ticket::use(--bobTicket), ter(tecNO_PERMISSION)); BEAST_EXPECT(env.seq(bob) == bobRootSeq); @@ -1482,21 +1509,21 @@ struct Escrow_test : public beast::unit_test::suite // bob tries to re-use a ticket, which is rejected. env(finish(bob, alice, escrowSeq), - fee(1500), + fee(150 * baseFee), ticket::use(bobTicket), ter(tefNO_TICKET)); // bob uses one of his remaining tickets. Success! env(finish(bob, alice, escrowSeq), - fee(1500), + fee(150 * baseFee), ticket::use(--bobTicket)); env.close(); BEAST_EXPECT(env.seq(bob) == bobRootSeq); } - { // Create escrow and cancel using tickets. - Env env{*this, features}; + Env env(*this, features); + auto const baseFee = env.current()->fees().base; env.fund(XRP(5000), alice, bob); env.close(); @@ -1535,7 +1562,7 @@ struct Escrow_test : public beast::unit_test::suite for (; env.now() < ts; env.close()) { env(cancel(bob, alice, escrowSeq), - fee(1500), + fee(150 * baseFee), ticket::use(bobTicket++), ter(tecNO_PERMISSION)); BEAST_EXPECT(env.seq(bob) == bobRootSeq); @@ -1545,14 +1572,14 @@ struct Escrow_test : public beast::unit_test::suite env(finish(bob, alice, escrowSeq), condition(cb1), fulfillment(fb1), - fee(1500), + fee(150 * baseFee), ticket::use(bobTicket++), ter(tecNO_PERMISSION)); BEAST_EXPECT(env.seq(bob) == bobRootSeq); // Verify that the cancel succeeds. env(cancel(bob, alice, escrowSeq), - fee(1500), + fee(150 * baseFee), ticket::use(bobTicket++)); env.close(); BEAST_EXPECT(env.seq(bob) == bobRootSeq); diff --git a/src/test/app/Flow_test.cpp b/src/test/app/Flow_test.cpp index aa7e819e0..ae65432ac 100644 --- a/src/test/app/Flow_test.cpp +++ b/src/test/app/Flow_test.cpp @@ -73,6 +73,7 @@ struct Flow_test : public beast::unit_test::suite Env env(*this, features); env.fund(XRP(10000), alice, bob, gw); + env.close(); env.trust(USD(1000), alice, bob); env(pay(gw, alice, USD(100))); env(pay(alice, bob, USD(10)), paths(USD)); @@ -83,6 +84,7 @@ struct Flow_test : public beast::unit_test::suite Env env(*this, features); env.fund(XRP(10000), alice, bob); + env.close(); env(pay(alice, bob, XRP(100))); env.require(balance(bob, XRP(10000 + 100))); env.require(balance(alice, xrpMinusFee(env, 10000 - 100))); @@ -92,6 +94,7 @@ struct Flow_test : public beast::unit_test::suite Env env(*this, features); env.fund(XRP(10000), alice, bob, gw); + env.close(); env.trust(USD(1000), alice, bob); env(pay(gw, alice, USD(100))); env(pay(alice, bob, USD(110)), paths(USD), ter(tecPATH_PARTIAL)); @@ -106,6 +109,7 @@ struct Flow_test : public beast::unit_test::suite Env env(*this, features); env.fund(XRP(10000), alice, bob, carol, dan); + env.close(); env.trust(USDA(10), bob); env.trust(USDB(10), carol); env.trust(USDC(10), dan); @@ -121,6 +125,7 @@ struct Flow_test : public beast::unit_test::suite Env env(*this, features); env.fund(XRP(10000), alice, bob, carol, dan); + env.close(); env.trust(USDA(10), bob); env.trust(USDB(10), alice, carol); env.trust(USDC(10), dan); @@ -141,6 +146,7 @@ struct Flow_test : public beast::unit_test::suite Env env(*this, features); env.fund(XRP(10000), alice, bob, carol, dan); + env.close(); env.trust(USDA(10), bob); env.trust(USDB(10), alice, carol); env.trust(USDC(10), dan); @@ -159,6 +165,7 @@ struct Flow_test : public beast::unit_test::suite Env env(*this, features); env.fund(XRP(10000), alice, bob, carol, dan, erin); + env.close(); env.trust(USDA(10), bob, carol); env.trust(USDB(10), dan); env.trust(USDC(10), alice, dan); @@ -182,6 +189,7 @@ struct Flow_test : public beast::unit_test::suite Env env(*this, features); env.fund(XRP(10000), alice, bob, carol); + env.close(); env.trust(USDA(10), bob); env.trust(USDB(10), carol); @@ -219,6 +227,7 @@ struct Flow_test : public beast::unit_test::suite { Env env(*this, features); env.fund(XRP(10000), alice, bob, carol, dan); + env.close(); env(trust(bob, USDD(100)), qualityInPercent(bobDanQIn)); env(trust(bob, USDA(100)), qualityOutPercent(bobAliceQOut)); env(trust(carol, USDA(100))); @@ -244,6 +253,8 @@ struct Flow_test : public beast::unit_test::suite { Env env(*this, features); env.fund(XRP(10000), alice, bob, carol); + env.close(); + env(trust(bob, USDA(10))); env(trust(carol, USDA(10)), qualityInPercent(carolAliceQIn)); @@ -260,6 +271,7 @@ struct Flow_test : public beast::unit_test::suite { Env env(*this, features); env.fund(XRP(10000), alice, bob, carol); + env.close(); env(trust(bob, USDA(10)), qualityOutPercent(bobAliceQOut)); env(trust(carol, USDA(10))); @@ -291,6 +303,7 @@ struct Flow_test : public beast::unit_test::suite Env env(*this, features); env.fund(XRP(10000), alice, bob, carol, gw); + env.close(); env.trust(USD(1000), alice, bob, carol); env.trust(BTC(1000), alice, bob, carol); @@ -312,6 +325,7 @@ struct Flow_test : public beast::unit_test::suite Env env(*this, features); env.fund(XRP(10000), alice, bob, carol, gw); + env.close(); env.trust(USD(1000), alice, bob, carol); env.trust(BTC(1000), alice, bob, carol); @@ -335,6 +349,7 @@ struct Flow_test : public beast::unit_test::suite Env env(*this, features); env.fund(XRP(10000), alice, bob, carol, gw); + env.close(); env.trust(USD(1000), alice, bob, carol); env.trust(BTC(1000), alice, bob, carol); @@ -355,6 +370,7 @@ struct Flow_test : public beast::unit_test::suite Env env(*this, features); env.fund(XRP(10000), alice, bob, carol, gw); + env.close(); env.trust(USD(1000), alice, bob, carol); env.trust(BTC(1000), alice, bob, carol); @@ -375,6 +391,7 @@ struct Flow_test : public beast::unit_test::suite Env env(*this, features); env.fund(XRP(10000), alice, bob, carol, gw); + env.close(); env.trust(USD(1000), alice, bob, carol); env.trust(BTC(1000), alice, bob, carol); env.trust(EUR(1000), alice, bob, carol); @@ -422,6 +439,7 @@ struct Flow_test : public beast::unit_test::suite Env env(*this, features); env.fund(XRP(10000), alice, bob, carol, gw); + env.close(); env.trust(USD(1000), alice, bob, carol); env.trust(BTC(1000), alice, bob, carol); env.trust(EUR(1000), alice, bob, carol); @@ -508,6 +526,8 @@ struct Flow_test : public beast::unit_test::suite // expected. Env env(*this, features); env.fund(XRP(10000), alice, bob, carol, gw); + env.close(); + env.trust(USD(1000), alice, bob, carol); env.trust(EUR(1000), alice, bob, carol); @@ -584,6 +604,7 @@ struct Flow_test : public beast::unit_test::suite Env env(*this, features); env.fund(XRP(10000), alice, bob, carol, gw); + env.close(); env(rate(gw, 1.25)); env.trust(USD(1000), alice, bob, carol); env(pay(gw, alice, USD(50))); @@ -596,6 +617,7 @@ struct Flow_test : public beast::unit_test::suite Env env(*this, features); env.fund(XRP(10000), alice, bob, carol, gw); + env.close(); env(rate(gw, 1.25)); env.trust(USD(1000), alice, bob, carol); env(pay(gw, alice, USD(50))); @@ -608,6 +630,7 @@ struct Flow_test : public beast::unit_test::suite Env env(*this, features); env.fund(XRP(10000), alice, bob, carol, gw); + env.close(); env(rate(gw, 1.25)); env.trust(USD(1000), alice, bob, carol); env(pay(gw, bob, USD(65))); @@ -626,6 +649,7 @@ struct Flow_test : public beast::unit_test::suite Env env(*this, features); env.fund(XRP(10000), alice, bob, carol, gw); + env.close(); env(rate(gw, 1.25)); env.trust(USD(1000), alice, bob, carol); env.trust(EUR(1000), alice, bob, carol); @@ -651,6 +675,7 @@ struct Flow_test : public beast::unit_test::suite auto const USDB = bob["USD"]; env.fund(XRP(10000), alice, bob, carol, gw); + env.close(); env(rate(gw, 1.25)); env.trust(USD(1000), alice, bob, carol); env.trust(USDA(1000), bob); @@ -673,6 +698,7 @@ struct Flow_test : public beast::unit_test::suite Account const dan("dan"); env.fund(XRP(10000), alice, bob, carol, dan, gw); + env.close(); env(rate(gw, 1.25)); env.trust(USD(1000), alice, bob, carol, dan); env.trust(EUR(1000), carol, dan); @@ -700,6 +726,7 @@ struct Flow_test : public beast::unit_test::suite Env env(*this, features); env.fund(XRP(10000), alice, bob, gw); + env.close(); env(rate(gw, 1.25)); env.trust(USD(1000), alice, bob); env(offer(gw, XRP(100), USD(100))); @@ -714,6 +741,7 @@ struct Flow_test : public beast::unit_test::suite Env env(*this, features); env.fund(XRP(10000), alice, bob, gw); + env.close(); env(rate(gw, 1.25)); env.trust(USD(1000), alice, bob); env(offer(gw, XRP(125), USD(125))); @@ -742,6 +770,7 @@ struct Flow_test : public beast::unit_test::suite env.fund(XRP(10000), alice, carol, gw); env.fund(reserve(env, 5), bob); + env.close(); env.trust(USD(1000), alice, bob, carol); env.trust(EUR(1000), alice, bob, carol); @@ -787,6 +816,7 @@ struct Flow_test : public beast::unit_test::suite Env env(*this); env.fund(XRP(10000), alice, bob, carol, gw); + env.close(); env.trust(USD(100), alice, bob, carol); env(pay(gw, bob, USD(100))); @@ -987,6 +1017,7 @@ struct Flow_test : public beast::unit_test::suite auto const USD = gw["USD"]; env.fund(XRP(10000), alice, gw); + env.close(); env(trust(alice, USD(20))); env(pay(gw, alice, USD(10))); env(offer(alice, XRP(50000), USD(10))); @@ -1016,6 +1047,7 @@ struct Flow_test : public beast::unit_test::suite auto const USD = gw["USD"]; env.fund(XRP(100000), alice, bob, gw); + env.close(); env(trust(bob, USD(20))); STAmount tinyAmt1{ @@ -1049,6 +1081,7 @@ struct Flow_test : public beast::unit_test::suite auto const USD = gw["USD"]; env.fund(XRP(100000), alice, bob, gw); + env.close(); env(trust(alice, USD(20))); STAmount tinyAmt1{ @@ -1151,6 +1184,7 @@ struct Flow_test : public beast::unit_test::suite auto const gw = Account("gw"); env.fund(XRP(100000000), alice, noripple(bob), carol, gw); + env.close(); env.trust(gw["USD"](10000), alice, carol); env(trust(bob, gw["USD"](10000), tfSetNoRipple)); env.trust(gw["USD"](10000), bob); @@ -1276,6 +1310,7 @@ struct Flow_test : public beast::unit_test::suite Env env(*this, features); env.fund(XRP(10000), alice); + env.close(); env(pay(alice, alice, alice["USD"](100)), path(~alice["USD"]), @@ -1305,8 +1340,10 @@ struct Flow_test : public beast::unit_test::suite // Payment path starting with XRP Env env(*this, feats); env.fund(XRP(10000), alice, bob, gw); + env.close(); env.trust(USD(1000), alice, bob); env.trust(EUR(1000), alice, bob); + env.close(); env(pay(gw, alice, USD(100))); env(pay(gw, alice, EUR(100))); env.close(); @@ -1330,6 +1367,7 @@ struct Flow_test : public beast::unit_test::suite // Payment path ending with XRP Env env(*this); env.fund(XRP(10000), alice, bob, gw); + env.close(); env.trust(USD(1000), alice, bob); env.trust(EUR(1000), alice, bob); env(pay(gw, alice, USD(100))); @@ -1388,6 +1426,7 @@ struct Flow_test : public beast::unit_test::suite Env env(*this, features); env.fund(XRP(10000), alice); + env.close(); // alice creates a ticket for the payment. std::uint32_t const ticketSeq{env.seq(alice) + 1}; @@ -1397,7 +1436,8 @@ struct Flow_test : public beast::unit_test::suite env(pay(alice, bob, XRP(1000)), ticket::use(ticketSeq)); env.close(); env.require(balance(bob, XRP(1000))); - env.require(balance(alice, XRP(9000) - drops(20))); + env.require( + balance(alice, XRP(9000) - (env.current()->fees().base * 2))); } void diff --git a/src/test/app/LedgerMaster_test.cpp b/src/test/app/LedgerMaster_test.cpp index 87b2d10c2..9bb75d3c8 100644 --- a/src/test/app/LedgerMaster_test.cpp +++ b/src/test/app/LedgerMaster_test.cpp @@ -37,6 +37,8 @@ class LedgerMaster_test : public beast::unit_test::suite using namespace jtx; return envconfig([&](std::unique_ptr cfg) { cfg->NETWORK_ID = networkID; + // This test relies on ledger hash so must lock it to fee 10. + cfg->FEES.reference_fee = 10; return cfg; }); } diff --git a/src/test/app/MPToken_test.cpp b/src/test/app/MPToken_test.cpp index 2ab925b5e..8f65c230d 100644 --- a/src/test/app/MPToken_test.cpp +++ b/src/test/app/MPToken_test.cpp @@ -1902,7 +1902,9 @@ class MPToken_test : public beast::unit_test::suite Account const alice{"alice"}; - Env env{*this, features}; + auto cfg = envconfig(); + cfg->FEES.reference_fee = 10; + Env env{*this, std::move(cfg), features}; MPTTester mptAlice(env, alice); mptAlice.create(); diff --git a/src/test/app/MultiSign_test.cpp b/src/test/app/MultiSign_test.cpp index 30a9ea9cc..245efab52 100644 --- a/src/test/app/MultiSign_test.cpp +++ b/src/test/app/MultiSign_test.cpp @@ -141,6 +141,7 @@ public: Env env{*this, features}; Account const alice{"alice", KeyType::ed25519}; env.fund(XRP(1000), alice); + env.close(); // Add alice as a multisigner for herself. Should fail. env(signers(alice, 1, {{alice, 1}}), ter(temBAD_SIGNER)); @@ -886,6 +887,7 @@ public: Env env{*this, features}; Account const alice{"alice", KeyType::ed25519}; env.fund(XRP(1000), alice); + env.close(); // There are three negative tests we need to make: // M0. A lone master key cannot be disabled. @@ -967,6 +969,7 @@ public: Env env{*this, features}; Account const alice{"alice", KeyType::secp256k1}; env.fund(XRP(1000), alice); + env.close(); // Give alice a regular key with a zero fee. Should succeed. Once. Account const alie{"alie", KeyType::ed25519}; @@ -983,6 +986,7 @@ public: // fee should always fail. Even the first time. Account const becky{"becky", KeyType::ed25519}; env.fund(XRP(1000), becky); + env.close(); env(signers(becky, 1, {{alice, 1}}), sig(becky)); env(regkey(becky, alie), msig(alice), fee(0), ter(telINSUF_FEE_P)); @@ -1101,6 +1105,7 @@ public: Account const alice{"alice"}; env.fund(XRP(1000), alice); + env.close(); env(signers(alice, 1, {{bogie, 1}, {demon, 1}}), sig(alice)); auto const baseFee = env.current()->fees().base; diff --git a/src/test/app/NFToken_test.cpp b/src/test/app/NFToken_test.cpp index 535484e50..00d2f7ebf 100644 --- a/src/test/app/NFToken_test.cpp +++ b/src/test/app/NFToken_test.cpp @@ -210,8 +210,11 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // the reserve for creating their first NFT. auto const acctReserve = env.current()->fees().accountReserve(0); auto const incReserve = env.current()->fees().increment; + auto const baseFee = env.current()->fees().base; + env.fund(acctReserve, alice, minter); env.close(); + BEAST_EXPECT(env.balance(alice) == acctReserve); BEAST_EXPECT(env.balance(minter) == acctReserve); BEAST_EXPECT(ownerCount(env, alice) == 0); @@ -221,12 +224,13 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // page. env(token::mint(alice, 0u), ter(tecINSUFFICIENT_RESERVE)); env.close(); + BEAST_EXPECT(ownerCount(env, alice) == 0); BEAST_EXPECT(mintedCount(env, alice) == 0); BEAST_EXPECT(burnedCount(env, alice) == 0); // Pay alice almost enough to make the reserve for an NFT page. - env(pay(env.master, alice, incReserve + drops(9))); + env(pay(env.master, alice, incReserve + drops(baseFee - 1))); env.close(); // A lambda that checks alice's ownerCount, mintedCount, and @@ -258,15 +262,17 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // page. env(token::mint(alice, 0u), ter(tecINSUFFICIENT_RESERVE)); env.close(); + checkAliceOwnerMintedBurned(0, 0, 0, __LINE__); // Pay alice enough to make the reserve for an NFT page. - env(pay(env.master, alice, drops(11))); + env(pay(env.master, alice, drops(baseFee + 1))); env.close(); // Now alice can mint an NFT. env(token::mint(alice)); env.close(); + checkAliceOwnerMintedBurned(1, 1, 0, __LINE__); // Alice should be able to mint an additional 31 NFTs without @@ -284,7 +290,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite checkAliceOwnerMintedBurned(1, 32, 0, __LINE__); // Pay alice almost enough to make the reserve for an NFT page. - env(pay(env.master, alice, XRP(50) + drops(329))); + env(pay(env.master, alice, incReserve + drops(baseFee * 33 - 1))); env.close(); // alice still does not have enough XRP for the reserve of an NFT @@ -294,7 +300,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite checkAliceOwnerMintedBurned(1, 32, 0, __LINE__); // Pay alice enough to make the reserve for an NFT page. - env(pay(env.master, alice, drops(11))); + env(pay(env.master, alice, drops(baseFee + 1))); env.close(); // Now alice can mint an NFT. @@ -367,7 +373,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite std::uint32_t nftSeq = 33; // Pay minter almost enough to make the reserve for an NFT page. - env(pay(env.master, minter, XRP(50) - drops(1))); + env(pay(env.master, minter, incReserve - drops(1))); env.close(); checkMintersOwnerMintedBurned(0, 33, nftSeq, 0, 0, 0, __LINE__); @@ -382,7 +388,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite checkMintersOwnerMintedBurned(0, 33, nftSeq, 0, 0, 0, __LINE__); // Pay minter enough to make the reserve for an NFT page. - env(pay(env.master, minter, drops(11))); + env(pay(env.master, minter, drops(baseFee + 1))); env.close(); // Now minter can mint an NFT for alice. @@ -400,7 +406,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // Pay minter almost enough for the reserve of an additional NFT // page. - env(pay(env.master, minter, XRP(50) + drops(319))); + env(pay(env.master, minter, incReserve + drops(baseFee * 32 - 1))); env.close(); // That NFT page is full. Creating an additional NFT page requires @@ -413,7 +419,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite checkMintersOwnerMintedBurned(0, 65, nftSeq, 1, 0, 0, __LINE__); // Pay minter enough for the reserve of an additional NFT page. - env(pay(env.master, minter, drops(11))); + env(pay(env.master, minter, drops(baseFee + 1))); env.close(); // Now minter can mint an NFT. @@ -882,7 +888,8 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite BEAST_EXPECT(ownerCount(env, buyer) == 1); // Give buyer almost enough XRP to cover the reserve. - env(pay(env.master, buyer, XRP(50) + drops(119))); + auto const baseFee = env.current()->fees().base; + env(pay(env.master, buyer, XRP(50) + drops(baseFee * 12 - 1))); env.close(); env(token::createOffer(buyer, nftAlice0ID, gwAUD(1000)), @@ -892,7 +899,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite BEAST_EXPECT(ownerCount(env, buyer) == 1); // Give buyer just enough XRP to cover the reserve for the offer. - env(pay(env.master, buyer, drops(11))); + env(pay(env.master, buyer, drops(baseFee + 1))); env.close(); // We don't care whether the offer is fully funded until the offer is @@ -2096,6 +2103,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite using namespace test::jtx; Env env{*this, features}; + auto const baseFee = env.current()->fees().base; Account const alice{"alice"}; Account const becky{"becky"}; @@ -2389,7 +2397,6 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // minter buys the nft for XRP(1). Since the transfer involves // alice there should be no transfer fee. - STAmount fee = drops(10); STAmount aliceBalance = env.balance(alice); STAmount minterBalance = env.balance(minter); uint256 const minterBuyOfferIndex = @@ -2398,8 +2405,8 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite env.close(); env(token::acceptBuyOffer(alice, minterBuyOfferIndex)); env.close(); - aliceBalance += XRP(1) - fee; - minterBalance -= XRP(1) + fee; + aliceBalance += XRP(1) - baseFee; + minterBalance -= XRP(1) + baseFee; BEAST_EXPECT(env.balance(alice) == aliceBalance); BEAST_EXPECT(env.balance(minter) == minterBalance); @@ -2413,8 +2420,8 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite env.close(); env(token::acceptSellOffer(carol, minterSellOfferIndex)); env.close(); - minterBalance += pmt - fee; - carolBalance -= pmt + fee; + minterBalance += pmt - baseFee; + carolBalance -= pmt + baseFee; BEAST_EXPECT(env.balance(alice) == aliceBalance); BEAST_EXPECT(env.balance(minter) == minterBalance); BEAST_EXPECT(env.balance(carol) == carolBalance); @@ -2429,8 +2436,8 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite env.close(); env(token::acceptBuyOffer(carol, beckyBuyOfferIndex)); env.close(); - carolBalance += pmt - drops(1) - fee; - beckyBalance -= pmt + fee; + carolBalance += pmt - drops(1) - baseFee; + beckyBalance -= pmt + baseFee; aliceBalance += drops(1); BEAST_EXPECT(env.balance(alice) == aliceBalance); @@ -3913,6 +3920,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite features | fixNonFungibleTokensV1_2}) { Env env{*this, tweakedFeatures}; + auto const baseFee = env.current()->fees().base; // The most important thing to explore here is the way funds are // assigned from the buyer to... @@ -4011,7 +4019,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // requested XRP(0). BEAST_EXPECT(env.balance(minter) == minterBalance + XRP(1)); BEAST_EXPECT(env.balance(buyer) == buyerBalance - XRP(1)); - BEAST_EXPECT(env.balance(broker) == brokerBalance - drops(10)); + BEAST_EXPECT(env.balance(broker) == brokerBalance - baseFee); BEAST_EXPECT(env.balance(issuer) == issuerBalance); // Burn the NFT so the next test starts with a clean state. @@ -4067,8 +4075,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite BEAST_EXPECT(env.balance(minter) == minterBalance + XRP(0.5)); BEAST_EXPECT(env.balance(buyer) == buyerBalance - XRP(1)); BEAST_EXPECT( - env.balance(broker) == - brokerBalance + XRP(0.5) - drops(10)); + env.balance(broker) == brokerBalance + XRP(0.5) - baseFee); BEAST_EXPECT(env.balance(issuer) == issuerBalance); // Burn the NFT so the next test starts with a clean state. @@ -4115,7 +4122,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // requested XRP(0). BEAST_EXPECT(env.balance(minter) == minterBalance + XRP(0.5)); BEAST_EXPECT(env.balance(buyer) == buyerBalance - XRP(1)); - BEAST_EXPECT(env.balance(broker) == brokerBalance - drops(10)); + BEAST_EXPECT(env.balance(broker) == brokerBalance - baseFee); BEAST_EXPECT(env.balance(issuer) == issuerBalance + XRP(0.5)); // Burn the NFT so the next test starts with a clean state. @@ -4165,8 +4172,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite BEAST_EXPECT(env.balance(minter) == minterBalance + XRP(0.125)); BEAST_EXPECT(env.balance(buyer) == buyerBalance - XRP(1)); BEAST_EXPECT( - env.balance(broker) == - brokerBalance + XRP(0.75) - drops(10)); + env.balance(broker) == brokerBalance + XRP(0.75) - baseFee); BEAST_EXPECT(env.balance(issuer) == issuerBalance + XRP(0.125)); // Burn the NFT so the next test starts with a clean state. @@ -6001,6 +6007,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite Account const broker{"broker"}; Env env{*this, features}; + auto const baseFee = env.current()->fees().base; env.fund(XRP(10000), alice, bob, broker); env.close(); @@ -6072,8 +6079,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite BEAST_EXPECT(nftCount(env, bob) == 1); BEAST_EXPECT(env.balance(bob) == bobsPriorBalance - XRP(1)); BEAST_EXPECT( - env.balance(broker) == - brokersPriorBalance + XRP(1) - drops(10)); + env.balance(broker) == brokersPriorBalance + XRP(1) - baseFee); } else { @@ -6081,8 +6087,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // than the broker burning their transaction fee. BEAST_EXPECT(nftCount(env, bob) == 1); BEAST_EXPECT(env.balance(bob) == bobsPriorBalance); - BEAST_EXPECT( - env.balance(broker) == brokersPriorBalance - drops(10)); + BEAST_EXPECT(env.balance(broker) == brokersPriorBalance - baseFee); } } @@ -6623,6 +6628,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // The remaining tests assume featureNFTokenMintOffer is enabled. { Env env{*this, features}; + auto const baseFee = env.current()->fees().base; Account const alice("alice"); Account const buyer{"buyer"}; Account const gw("gw"); @@ -6760,13 +6766,13 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite env.close(); // have reserve for NFTokenPage, Offer - env(pay(env.master, bob, incReserve + drops(10))); + env(pay(env.master, bob, incReserve + drops(baseFee))); env.close(); env(token::mint(bob), token::amount(XRP(0))); env.close(); // doesn't have reserve for Offer - env(pay(env.master, bob, drops(10))); + env(pay(env.master, bob, drops(baseFee))); env.close(); env(token::mint(bob), token::amount(XRP(0)), @@ -6774,7 +6780,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite env.close(); // have reserve for Offer - env(pay(env.master, bob, incReserve + drops(10))); + env(pay(env.master, bob, incReserve + drops(baseFee))); env.close(); env(token::mint(bob), token::amount(XRP(0))); env.close(); @@ -7138,6 +7144,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite Env env{*this, features}; auto const acctReserve = env.current()->fees().accountReserve(0); auto const incReserve = env.current()->fees().increment; + auto const baseFee = env.current()->fees().base; env.fund(XRP(10000), alice); env.close(); @@ -7171,8 +7178,8 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // there is enough reserve. A detail to note is that NFTs(sell // offer) will not allow one to go below the reserve requirement, // because buyer's balance is computed after the transaction fee is - // deducted. This means that the reserve requirement will be 10 - // drops higher than normal. + // deducted. This means that the reserve requirement will be `base + // fee` drops higher than normal. else { // Bob is not able to accept the offer with only the account @@ -7181,26 +7188,26 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite ter(tecINSUFFICIENT_RESERVE)); env.close(); - // after prev transaction, Bob owns 199,999,990 drops due to - // burnt tx fee + // after prev transaction, Bob owns `200M - base fee` drops due + // to burnt tx fee BEAST_EXPECT(ownerCount(env, bob) == 0); - // Send bob an increment reserve and 10 drops (to make up for + // Send bob an increment reserve and base fee (to make up for // the transaction fee burnt from the prev failed tx) Bob now // owns 250,000,000 drops - env(pay(env.master, bob, incReserve + drops(10))); + env(pay(env.master, bob, incReserve + drops(baseFee))); env.close(); // However, this transaction will still fail because the reserve - // requirement is 10 drops higher + // requirement is `base fee` drops higher env(token::acceptSellOffer(bob, sellOfferIndex), ter(tecINSUFFICIENT_RESERVE)); env.close(); - // Send bob an increment reserve and 20 drops - // Bob now owns 250,000,010 drops - env(pay(env.master, bob, drops(20))); + // Send bob `base fee * 2` drops + // Bob now owns `250M + base fee` drops + env(pay(env.master, bob, drops(baseFee * 2))); env.close(); // Bob is now able to accept the offer @@ -7317,6 +7324,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite Env env{*this, features}; auto const acctReserve = env.current()->fees().accountReserve(0); auto const incReserve = env.current()->fees().increment; + auto const baseFee = env.current()->fees().base; env.fund(XRP(10000), alice); env.close(); @@ -7338,15 +7346,15 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite env(token::createOffer(bob, nftId, XRP(1)), token::owner(alice)); env.close(); - // accepting the buy offer fails because bob's balance is 10 drops - // lower than the required amount, since the previous tx burnt 10 + // accepting the buy offer fails because bob's balance is `base fee` + // drops lower than the required amount, since the previous tx burnt // drops for tx fee. env(token::acceptBuyOffer(alice, buyOfferIndex), ter(tecINSUFFICIENT_FUNDS)); env.close(); - // send Bob 10 drops - env(pay(env.master, bob, drops(10))); + // send Bob `base fee` drops + env(pay(env.master, bob, drops(baseFee))); env.close(); // Now bob can buy the offer @@ -7367,6 +7375,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite Env env{*this, features}; auto const acctReserve = env.current()->fees().accountReserve(0); auto const incReserve = env.current()->fees().increment; + auto const baseFee = env.current()->fees().base; env.fund(XRP(10000), alice, broker); env.close(); @@ -7405,8 +7414,8 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite ter(tecINSUFFICIENT_FUNDS)); env.close(); - // send Bob 10 drops - env(pay(env.master, bob, drops(10))); + // send Bob `base fee` drops + env(pay(env.master, bob, drops(baseFee))); env.close(); // broker offers. diff --git a/src/test/app/Offer_test.cpp b/src/test/app/Offer_test.cpp index c0a877c76..70d7b9575 100644 --- a/src/test/app/Offer_test.cpp +++ b/src/test/app/Offer_test.cpp @@ -96,6 +96,7 @@ public: Account const carol{"carol"}; env.fund(XRP(10000), alice, bob, carol, gw); + env.close(); env.trust(USD(1000), alice, bob, carol); env.trust(BTC(1000), alice, bob, carol); @@ -231,6 +232,7 @@ public: Env env{*this, features}; env.fund(XRP(10000), alice, bob, carol, gw); + env.close(); env.trust(USD(1000), alice, bob, carol); env.trust(EUR(1000), alice, bob, carol); env(pay(gw, alice, USD(100))); @@ -655,6 +657,7 @@ public: auto const USD2 = gw2["USD"]; env.fund(XRP(10000), alice, noripple(bob), carol, dan, gw1, gw2); + env.close(); env.trust(USD1(1000), alice, carol, dan); env(trust(bob, USD1(1000), tfSetNoRipple)); env.trust(USD2(1000), alice, carol, dan); @@ -682,6 +685,7 @@ public: auto const USD2 = gw2["USD"]; env.fund(XRP(10000), alice, bob, carol, dan, gw1, gw2); + env.close(); env.trust(USD1(1000), alice, bob, carol, dan); env.trust(USD2(1000), alice, bob, carol, dan); @@ -756,8 +760,10 @@ public: auto const xrpOffer2 = XRP(500); env.fund(r + f + xrpOffer, bob); + env(offer(bob, usdOffer2, xrpOffer2), ter(tesSUCCESS)); env.fund(r + f, alice); + env(trust(alice, usdOffer), ter(tesSUCCESS)); env(pay(gw, alice, usdOffer), ter(tesSUCCESS)); env(offer(alice, xrpOffer, usdOffer), ter(tesSUCCESS)); @@ -786,10 +792,12 @@ public: auto const xrpOffer2 = XRP(500); env.fund(r + f + xrpOffer, bob, carol); + env(offer(bob, usdOffer2, xrpOffer2), ter(tesSUCCESS)); env(offer(carol, usdOffer, xrpOffer), ter(tesSUCCESS)); env.fund(r + f, alice); + env(trust(alice, usdOffer), ter(tesSUCCESS)); env(pay(gw, alice, usdOffer), ter(tesSUCCESS)); env(offer(alice, xrpOffer, usdOffer), ter(tesSUCCESS)); @@ -849,6 +857,7 @@ public: auto const f = env.current()->fees().base; env.fund(startBalance, gw, alice, bob); + env.close(); // bob creates an offer that expires before the next ledger close. env(offer(bob, USD(500), XRP(500)), @@ -910,6 +919,7 @@ public: auto const f = env.current()->fees().base; env.fund(startBalance, gw, alice, bob); + env.close(); env(trust(alice, USD(1000)), ter(tesSUCCESS)); env(pay(gw, alice, USD(1000)), ter(tesSUCCESS)); @@ -1069,6 +1079,7 @@ public: Env env{*this, features}; env.fund(startBalance, gw, alice); + env.close(); // Order that has invalid flags env(offer(alice, USD(1000), XRP(1000)), @@ -1225,6 +1236,7 @@ public: Env env{*this, features}; env.fund(XRP(1000000), gw); + env.close(); // The fee that's charged for transactions auto const f = env.current()->fees().base; @@ -1232,12 +1244,14 @@ public: // Account is at the reserve, and will dip below once // fees are subtracted. env.fund(reserve(env, 0), "alice"); + env.close(); env(offer("alice", usdOffer, xrpOffer), ter(tecUNFUNDED_OFFER)); env.require(balance("alice", reserve(env, 0) - f), owners("alice", 0)); // Account has just enough for the reserve and the // fee. env.fund(reserve(env, 0) + f, "bob"); + env.close(); env(offer("bob", usdOffer, xrpOffer), ter(tecUNFUNDED_OFFER)); env.require(balance("bob", reserve(env, 0)), owners("bob", 0)); @@ -1245,6 +1259,7 @@ public: // the offer, and a bit more, but not enough for the // reserve after the offer is placed. env.fund(reserve(env, 0) + f + XRP(1), "carol"); + env.close(); env(offer("carol", usdOffer, xrpOffer), ter(tecINSUF_RESERVE_OFFER)); env.require( balance("carol", reserve(env, 0) + XRP(1)), owners("carol", 0)); @@ -1252,12 +1267,14 @@ public: // Account has enough for the reserve plus one // offer, and the fee. env.fund(reserve(env, 1) + f, "dan"); + env.close(); env(offer("dan", usdOffer, xrpOffer), ter(tesSUCCESS)); env.require(balance("dan", reserve(env, 1)), owners("dan", 1)); // Account has enough for the reserve plus one // offer, the fee and the entire offer amount. env.fund(reserve(env, 1) + f + xrpOffer, "eve"); + env.close(); env(offer("eve", usdOffer, xrpOffer), ter(tesSUCCESS)); env.require( balance("eve", reserve(env, 1) + xrpOffer), owners("eve", 1)); @@ -1284,8 +1301,10 @@ public: if (use_partner) { env.fund(XRP(10000), partner); + env.close(); env(trust(partner, USD(100))); env(trust(partner, BTC(500))); + env.close(); env(pay(gw, partner, USD(100))); env(pay(gw, partner, BTC(500))); } @@ -1412,6 +1431,7 @@ public: env.fund(gw_initial_balance, gw); env.fund(alice_initial_balance, alice); env.fund(bob_initial_balance, bob); + env.close(); env(rate(gw, 1.005)); @@ -1507,6 +1527,7 @@ public: auto const USD = gw["USD"]; env.fund(XRP(10000), gw, alice, bob); + env.close(); env(trust(alice, USD(1000))); env(trust(bob, USD(1000))); @@ -1559,6 +1580,7 @@ public: auto const USD = gw["USD"]; env.fund(XRP(100000), gw, alice, bob); + env.close(); env(trust(alice, USD(1000))); @@ -1621,6 +1643,7 @@ public: auto const nextOfferSeq = env.seq(env.master); env.fund(XRP(10000), alice); + env.close(); env(offer_cancel(env.master, nextOfferSeq)); @@ -1648,6 +1671,7 @@ public: auto const USD = gw["USD"]; env.fund(XRP(10000), gw, alice, bob); + env.close(); env.require(owners(bob, 0)); env(trust(alice, USD(100))); @@ -1700,6 +1724,7 @@ public: auto const carol = Account{"carol"}; env.fund(XRP(10000), alice, bob, carol); + env.close(); env(trust(alice, carol["EUR"](2000))); env(trust(bob, alice["USD"](100))); @@ -1730,6 +1755,7 @@ public: auto const USD = gw["USD"]; env.fund(XRP(10000), gw, alice, bob); + env.close(); env(trust(alice, USD(200))); env(trust(bob, USD(1000))); @@ -1816,6 +1842,7 @@ public: auto const USD = gw["USD"]; env.fund(XRP(10000), gw, alice, bob, carol); + env.close(); env(trust(carol, USD(1000))); env(trust(bob, USD(2000))); @@ -1857,6 +1884,7 @@ public: auto const USD = gw["USD"]; env.fund(XRP(10000), gw, alice, bob, carol); + env.close(); env(trust(alice, USD(1000))); env(trust(carol, USD(2000))); @@ -1907,6 +1935,7 @@ public: auto const EUR = gw2["EUR"]; env.fund(XRP(10000), gw1, gw2, alice, bob, carol, dan); + env.close(); env(trust(alice, USD(1000))); env(trust(bob, EUR(1000))); @@ -1972,6 +2001,7 @@ public: auto const EUR = gw["EUR"]; env.fund(XRP(100000000), alice, bob, carol, gw); + env.close(); env.trust(USD(10), alice); env.close(); @@ -2054,6 +2084,7 @@ public: env.current()->fees().base * 4; env.fund(starting_xrp, gw1, gw2, gw3, alice, bob); + env.close(); env(trust(alice, USD1(1000))); env(trust(alice, USD2(1000))); @@ -2100,6 +2131,7 @@ public: auto const USD = gw["USD"]; env.fund(XRP(10000), gw, alice, bob); + env.close(); env(rate(gw, 1.005)); @@ -2153,6 +2185,7 @@ public: env.current()->fees().base * 2; env.fund(starting_xrp, gw, alice, bob); + env.close(); env(trust(alice, USD(1000))); env(trust(bob, USD(1000))); @@ -2195,6 +2228,7 @@ public: env.current()->fees().base * 2; env.fund(starting_xrp, gw, alice, bob); + env.close(); env(trust(alice, USD(150))); env(trust(bob, USD(1000))); @@ -2240,6 +2274,7 @@ public: env.current()->fees().base * 2; env.fund(starting_xrp, gw, alice, bob); + env.close(); env(trust(alice, XTS(1000))); env(trust(alice, XXX(1000))); @@ -2344,6 +2379,7 @@ public: Env env{*this, features}; env.fund(XRP(10000000), gw); + env.close(); // The fee that's charged for transactions auto const f = env.current()->fees().base; @@ -2370,7 +2406,7 @@ public: {"ann", reserve(env, 0) + 0 * f, 1, noPreTrust, 1000, tecUNFUNDED_OFFER, f, USD( 0), 0, 0}, // Account is at the reserve, and will dip below once fees are subtracted. {"bev", reserve(env, 0) + 1 * f, 1, noPreTrust, 1000, tecUNFUNDED_OFFER, f, USD( 0), 0, 0}, // Account has just enough for the reserve and the fee. {"cam", reserve(env, 0) + 2 * f, 0, noPreTrust, 1000, tecINSUF_RESERVE_OFFER, f, USD( 0), 0, 0}, // Account has enough for the reserve, the fee and the offer, and a bit more, but not enough for the reserve after the offer is placed. - {"deb", reserve(env, 0) + 2 * f, 1, noPreTrust, 1000, tesSUCCESS, 2 * f, USD(0.00001), 0, 1}, // Account has enough to buy a little USD then the offer runs dry. + {"deb", drops(10) + reserve(env, 0) + 1 * f, 1, noPreTrust, 1000, tesSUCCESS, drops(10) + f, USD(0.00001), 0, 1}, // Account has enough to buy a little USD then the offer runs dry. {"eve", reserve(env, 1) + 0 * f, 0, noPreTrust, 1000, tesSUCCESS, f, USD( 0), 1, 1}, // No offer to cross {"flo", reserve(env, 1) + 0 * f, 1, noPreTrust, 1000, tesSUCCESS, XRP( 1) + f, USD( 1), 0, 1}, {"gay", reserve(env, 1) + 1 * f, 1000, noPreTrust, 1000, tesSUCCESS, XRP( 50) + f, USD( 50), 0, 1}, @@ -2389,7 +2425,7 @@ public: {"abe", reserve(env, 0) + 0 * f, 1, gwPreTrust, 1000, tecUNFUNDED_OFFER, f, USD( 0), 0, 0}, {"bud", reserve(env, 0) + 1 * f, 1, gwPreTrust, 1000, tecUNFUNDED_OFFER, f, USD( 0), 0, 0}, {"che", reserve(env, 0) + 2 * f, 0, gwPreTrust, 1000, tecINSUF_RESERVE_OFFER, f, USD( 0), 0, 0}, - {"dan", reserve(env, 0) + 2 * f, 1, gwPreTrust, 1000, tesSUCCESS, 2 * f, USD(0.00001), 0, 0}, + {"dan", drops(10) + reserve(env, 0) + 1 * f, 1, gwPreTrust, 1000, tesSUCCESS, drops(10) + f, USD(0.00001), 0, 0}, {"eli", XRP( 20) + reserve(env, 0) + 1 * f, 1000, gwPreTrust, 1000, tesSUCCESS, XRP(20) + 1 * f, USD( 20), 0, 0}, {"fyn", reserve(env, 1) + 0 * f, 0, gwPreTrust, 1000, tesSUCCESS, f, USD( 0), 1, 1}, {"gar", reserve(env, 1) + 0 * f, 1, gwPreTrust, 1000, tesSUCCESS, XRP( 1) + f, USD( 1), 1, 1}, @@ -2400,7 +2436,7 @@ public: {"pat", reserve(env, 1) + 2 * f, 0, acctPreTrust, 1000, tecUNFUNDED_OFFER, 2 * f, USD( 0), 0, 1}, {"quy", reserve(env, 1) + 2 * f, 1, acctPreTrust, 1000, tecUNFUNDED_OFFER, 2 * f, USD( 0), 0, 1}, {"ron", reserve(env, 1) + 3 * f, 0, acctPreTrust, 1000, tecINSUF_RESERVE_OFFER, 2 * f, USD( 0), 0, 1}, - {"syd", reserve(env, 1) + 3 * f, 1, acctPreTrust, 1000, tesSUCCESS, 3 * f, USD(0.00001), 0, 1}, + {"syd", drops(10) + reserve(env, 1) + 2 * f, 1, acctPreTrust, 1000, tesSUCCESS, drops(10) + 2 * f, USD(0.00001), 0, 1}, {"ted", XRP( 20) + reserve(env, 1) + 2 * f, 1000, acctPreTrust, 1000, tesSUCCESS, XRP(20) + 2 * f, USD( 20), 0, 1}, {"uli", reserve(env, 2) + 0 * f, 0, acctPreTrust, 1000, tecINSUF_RESERVE_OFFER, 2 * f, USD( 0), 0, 1}, {"vic", reserve(env, 2) + 0 * f, 1, acctPreTrust, 1000, tesSUCCESS, XRP( 1) + 2 * f, USD( 1), 0, 1}, @@ -2428,13 +2464,13 @@ public: // Optionally pre-establish a trustline between gw and acct. if (t.preTrust == gwPreTrust) env(trust(gw, acct["USD"](1))); + env.close(); // Optionally pre-establish a trustline between acct and gw. // Note this is not really part of the test, so we expect there // to be enough XRP reserve for acct to create the trust line. if (t.preTrust == acctPreTrust) env(trust(acct, USD(1))); - env.close(); { @@ -2795,6 +2831,7 @@ public: Env env{*this, features}; env.fund(XRP(10000000), gw); + env.close(); // The fee that's charged for transactions auto const f = env.current()->fees().base; @@ -2984,6 +3021,7 @@ public: Env env{*this, features}; env.fund(XRP(10000000), gw, alice, bob); + env.close(); // Code returned if an offer is killed. TER const killedCode{ @@ -4013,6 +4051,7 @@ public: using namespace jtx; Env env{*this, features}; + auto const baseFee = env.current()->fees().base.drops(); auto const gw = Account("gw"); auto const BTC = gw["BTC"]; @@ -4050,10 +4089,10 @@ public: // clang-format off TestData const tests[]{ // btcStart --------------------- actor[0] --------------------- -------------------- actor[1] ------------------- - {0, 0, 1, BTC(20), {{"ann", 0, drops(3899999999960), BTC(20.0), USD(3000)}, {"abe", 0, drops(4099999999970), BTC( 0), USD(750)}}}, // no BTC xfer fee - {0, 1, 0, BTC(20), {{"bev", 0, drops(4099999999960), BTC( 7.5), USD(2000)}, {"bob", 0, drops(3899999999970), BTC(10), USD( 0)}}}, // no USD xfer fee - {0, 0, 0, BTC(20), {{"cam", 0, drops(3999999999950), BTC(20.0), USD(2000)} }}, // no xfer fee - {0, 1, 0, BTC( 5), {{"deb", 1, drops(4039999999960), BTC( 0.0), USD(2000)}, {"dan", 1, drops(3959999999970), BTC( 4), USD( 0)}}}, // no USD xfer fee + {0, 0, 1, BTC(20), {{"ann", 0, drops(3900000'000000 - 4 * baseFee), BTC(20.0), USD(3000)}, {"abe", 0, drops(4100000'000000 - 3 * baseFee), BTC( 0), USD(750)}}}, // no BTC xfer fee + {0, 1, 0, BTC(20), {{"bev", 0, drops(4100000'000000 - 4 * baseFee), BTC( 7.5), USD(2000)}, {"bob", 0, drops(3900000'000000 - 3 * baseFee), BTC(10), USD( 0)}}}, // no USD xfer fee + {0, 0, 0, BTC(20), {{"cam", 0, drops(4000000'000000 - 5 * baseFee), BTC(20.0), USD(2000)} }}, // no xfer fee + {0, 1, 0, BTC( 5), {{"deb", 1, drops(4040000'000000 - 4 * baseFee), BTC( 0.0), USD(2000)}, {"dan", 1, drops(3960000'000000 - 3 * baseFee), BTC( 4), USD( 0)}}}, // no USD xfer fee }; // clang-format on @@ -4163,6 +4202,7 @@ public: using namespace jtx; Env env{*this, features}; + auto const baseFee = env.current()->fees().base.drops(); auto const gw = Account("gw"); auto const BTC = gw["BTC"]; @@ -4200,14 +4240,14 @@ public: // clang-format off TestData const takerTests[]{ // btcStart ------------------- actor[0] -------------------- ------------------- actor[1] -------------------- - {0, 0, 1, BTC(5), {{"deb", 0, drops(3899999999960), BTC(5), USD(3000)}, {"dan", 0, drops(4099999999970), BTC(0), USD(750)}}}, // no BTC xfer fee - {0, 0, 0, BTC(5), {{"flo", 0, drops(3999999999950), BTC(5), USD(2000)} }} // no xfer fee + {0, 0, 1, BTC(5), {{"deb", 0, drops(3900000'000000 - 4 * baseFee), BTC(5), USD(3000)}, {"dan", 0, drops(4100000'000000 - 3 * baseFee), BTC(0), USD(750)}}}, // no BTC xfer fee + {0, 0, 0, BTC(5), {{"flo", 0, drops(4000000'000000 - 5 * baseFee), BTC(5), USD(2000)} }} // no xfer fee }; TestData const flowTests[]{ // btcStart ------------------- actor[0] -------------------- ------------------- actor[1] -------------------- - {0, 0, 1, BTC(5), {{"gay", 1, drops(3949999999960), BTC(5), USD(2500)}, {"gar", 1, drops(4049999999970), BTC(0), USD(1375)}}}, // no BTC xfer fee - {0, 0, 0, BTC(5), {{"hye", 2, drops(3999999999950), BTC(5), USD(2000)} }} // no xfer fee + {0, 0, 1, BTC(5), {{"gay", 1, drops(3950000'000000 - 4 * baseFee), BTC(5), USD(2500)}, {"gar", 1, drops(4050000'000000 - 3 * baseFee), BTC(0), USD(1375)}}}, // no BTC xfer fee + {0, 0, 0, BTC(5), {{"hye", 2, drops(4000000'000000 - 5 * baseFee), BTC(5), USD(2000)} }} // no xfer fee }; // clang-format on @@ -4657,6 +4697,7 @@ public: Env env{*this, features}; env.fund(XRP(10000), alice, becky, carol, noripple(gw)); + env.close(); env.trust(USD(1000), becky); env(pay(gw, becky, USD(5))); env.close(); @@ -4750,6 +4791,7 @@ public: Env env{*this, features}; auto const gw = Account{"gateway"}; env.fund(XRP(10000), gw); + env.close(); auto txn = noop(gw); txn[sfTickSize.fieldName] = Quality::minTickSize - 1; @@ -4785,6 +4827,7 @@ public: auto const XXX = gw["XXX"]; env.fund(XRP(10000), gw, alice); + env.close(); { // Gateway sets its tick size to 5 diff --git a/src/test/app/Oracle_test.cpp b/src/test/app/Oracle_test.cpp index 291349309..a96897039 100644 --- a/src/test/app/Oracle_test.cpp +++ b/src/test/app/Oracle_test.cpp @@ -43,7 +43,11 @@ private: Account const bad("bad"); env.memoize(bad); Oracle oracle( - env, {.owner = bad, .seq = seq(1), .err = ter(terNO_ACCOUNT)}); + env, + {.owner = bad, + .seq = seq(1), + .fee = static_cast(env.current()->fees().base.drops()), + .err = ter(terNO_ACCOUNT)}); } // Insufficient reserve @@ -51,7 +55,10 @@ private: Env env(*this); env.fund(env.current()->fees().accountReserve(0), owner); Oracle oracle( - env, {.owner = owner, .err = ter(tecINSUFFICIENT_RESERVE)}); + env, + {.owner = owner, + .fee = static_cast(env.current()->fees().base.drops()), + .err = ter(tecINSUFFICIENT_RESERVE)}); } // Insufficient reserve if the data series extends to greater than 5 { @@ -60,7 +67,10 @@ private: env.current()->fees().accountReserve(1) + env.current()->fees().base * 2, owner); - Oracle oracle(env, {.owner = owner}); + Oracle oracle( + env, + {.owner = owner, + .fee = static_cast(env.current()->fees().base.drops())}); BEAST_EXPECT(oracle.exists()); oracle.set(UpdateArg{ .series = @@ -71,38 +81,47 @@ private: {"XRP", "CAD", 740, 1}, {"XRP", "AUD", 740, 1}, }, + .fee = static_cast(env.current()->fees().base.drops()), .err = ter(tecINSUFFICIENT_RESERVE)}); } { Env env(*this); + auto const baseFee = + static_cast(env.current()->fees().base.drops()); env.fund(XRP(1'000), owner); - Oracle oracle(env, {.owner = owner}, false); + Oracle oracle(env, {.owner = owner, .fee = baseFee}, false); // Invalid flag - oracle.set( - CreateArg{.flags = tfSellNFToken, .err = ter(temINVALID_FLAG)}); + oracle.set(CreateArg{ + .flags = tfSellNFToken, + .fee = baseFee, + .err = ter(temINVALID_FLAG)}); // Duplicate token pair oracle.set(CreateArg{ .series = {{"XRP", "USD", 740, 1}, {"XRP", "USD", 750, 1}}, + .fee = baseFee, .err = ter(temMALFORMED)}); // Price is not included oracle.set(CreateArg{ .series = {{"XRP", "USD", 740, 1}, {"XRP", "EUR", std::nullopt, 1}}, + .fee = baseFee, .err = ter(temMALFORMED)}); // Token pair is in update and delete oracle.set(CreateArg{ .series = {{"XRP", "USD", 740, 1}, {"XRP", "USD", std::nullopt, 1}}, + .fee = baseFee, .err = ter(temMALFORMED)}); // Token pair is in add and delete oracle.set(CreateArg{ .series = {{"XRP", "EUR", 740, 1}, {"XRP", "EUR", std::nullopt, 1}}, + .fee = baseFee, .err = ter(temMALFORMED)}); // Array of token pair is 0 or exceeds 10 @@ -119,19 +138,25 @@ private: {"XRP", "US9", 740, 1}, {"XRP", "U10", 750, 1}, {"XRP", "U11", 740, 1}}, + .fee = baseFee, .err = ter(temARRAY_TOO_LARGE)}); - oracle.set(CreateArg{.series = {}, .err = ter(temARRAY_EMPTY)}); + oracle.set(CreateArg{ + .series = {}, .fee = baseFee, .err = ter(temARRAY_EMPTY)}); } // Array of token pair exceeds 10 after update { Env env{*this}; + auto const baseFee = + static_cast(env.current()->fees().base.drops()); env.fund(XRP(1'000), owner); Oracle oracle( env, CreateArg{ - .owner = owner, .series = {{{"XRP", "USD", 740, 1}}}}); + .owner = owner, + .series = {{{"XRP", "USD", 740, 1}}}, + .fee = baseFee}); oracle.set(UpdateArg{ .series = { @@ -146,75 +171,95 @@ private: {"XRP", "US9", 740, 1}, {"XRP", "U10", 750, 1}, }, + .fee = baseFee, .err = ter(tecARRAY_TOO_LARGE)}); } { Env env(*this); + auto const baseFee = + static_cast(env.current()->fees().base.drops()); env.fund(XRP(1'000), owner); - Oracle oracle(env, {.owner = owner}, false); + Oracle oracle(env, {.owner = owner, .fee = baseFee}, false); // Asset class or provider not included on create oracle.set(CreateArg{ .assetClass = std::nullopt, .provider = "provider", + .fee = baseFee, .err = ter(temMALFORMED)}); oracle.set(CreateArg{ .assetClass = "currency", .provider = std::nullopt, .uri = "URI", + .fee = baseFee, .err = ter(temMALFORMED)}); // Asset class or provider are included on update // and don't match the current values - oracle.set(CreateArg{}); + oracle.set(CreateArg{ + .fee = static_cast(env.current()->fees().base.drops())}); BEAST_EXPECT(oracle.exists()); oracle.set(UpdateArg{ .series = {{"XRP", "USD", 740, 1}}, .provider = "provider1", + .fee = baseFee, .err = ter(temMALFORMED)}); oracle.set(UpdateArg{ .series = {{"XRP", "USD", 740, 1}}, .assetClass = "currency1", + .fee = baseFee, .err = ter(temMALFORMED)}); } { Env env(*this); + auto const baseFee = + static_cast(env.current()->fees().base.drops()); env.fund(XRP(1'000), owner); - Oracle oracle(env, {.owner = owner}, false); + Oracle oracle(env, {.owner = owner, .fee = baseFee}, false); // Fields too long // Asset class std::string assetClass(17, '0'); - oracle.set( - CreateArg{.assetClass = assetClass, .err = ter(temMALFORMED)}); + oracle.set(CreateArg{ + .assetClass = assetClass, + .fee = baseFee, + .err = ter(temMALFORMED)}); // provider std::string const large(257, '0'); - oracle.set(CreateArg{.provider = large, .err = ter(temMALFORMED)}); + oracle.set(CreateArg{ + .provider = large, .fee = baseFee, .err = ter(temMALFORMED)}); // URI - oracle.set(CreateArg{.uri = large, .err = ter(temMALFORMED)}); + oracle.set(CreateArg{ + .uri = large, .fee = baseFee, .err = ter(temMALFORMED)}); // Empty field // Asset class - oracle.set(CreateArg{.assetClass = "", .err = ter(temMALFORMED)}); + oracle.set(CreateArg{ + .assetClass = "", .fee = baseFee, .err = ter(temMALFORMED)}); // provider - oracle.set(CreateArg{.provider = "", .err = ter(temMALFORMED)}); + oracle.set(CreateArg{ + .provider = "", .fee = baseFee, .err = ter(temMALFORMED)}); // URI - oracle.set(CreateArg{.uri = "", .err = ter(temMALFORMED)}); + oracle.set( + CreateArg{.uri = "", .fee = baseFee, .err = ter(temMALFORMED)}); } { // Different owner creates a new object and fails because // of missing fields currency/provider Env env(*this); + auto const baseFee = + static_cast(env.current()->fees().base.drops()); Account const some("some"); env.fund(XRP(1'000), owner); env.fund(XRP(1'000), some); - Oracle oracle(env, {.owner = owner}); + Oracle oracle(env, {.owner = owner, .fee = baseFee}); BEAST_EXPECT(oracle.exists()); oracle.set(UpdateArg{ .owner = some, .series = {{"XRP", "USD", 740, 1}}, + .fee = baseFee, .err = ter(temMALFORMED)}); } @@ -222,6 +267,8 @@ private: // Invalid update time using namespace std::chrono; Env env(*this); + auto const baseFee = + static_cast(env.current()->fees().base.drops()); auto closeTime = [&]() { return duration_cast( env.current()->info().closeTime.time_since_epoch() - @@ -229,89 +276,109 @@ private: .count(); }; env.fund(XRP(1'000), owner); - Oracle oracle(env, {.owner = owner}); + Oracle oracle(env, {.owner = owner, .fee = baseFee}); BEAST_EXPECT(oracle.exists()); env.close(seconds(400)); // Less than the last close time - 300s oracle.set(UpdateArg{ .series = {{"XRP", "USD", 740, 1}}, .lastUpdateTime = static_cast(closeTime() - 301), + .fee = baseFee, .err = ter(tecINVALID_UPDATE_TIME)}); // Greater than last close time + 300s oracle.set(UpdateArg{ .series = {{"XRP", "USD", 740, 1}}, .lastUpdateTime = static_cast(closeTime() + 311), + .fee = baseFee, .err = ter(tecINVALID_UPDATE_TIME)}); - oracle.set(UpdateArg{.series = {{"XRP", "USD", 740, 1}}}); + oracle.set( + UpdateArg{.series = {{"XRP", "USD", 740, 1}}, .fee = baseFee}); BEAST_EXPECT(oracle.expectLastUpdateTime( static_cast(testStartTime.count() + 450))); // Less than the previous lastUpdateTime oracle.set(UpdateArg{ .series = {{"XRP", "USD", 740, 1}}, .lastUpdateTime = static_cast(449), + .fee = baseFee, .err = ter(tecINVALID_UPDATE_TIME)}); // Less than the epoch time oracle.set(UpdateArg{ .series = {{"XRP", "USD", 740, 1}}, .lastUpdateTime = static_cast(epoch_offset.count() - 1), + .fee = baseFee, .err = ter(tecINVALID_UPDATE_TIME)}); } { // delete token pair that doesn't exist Env env(*this); + auto const baseFee = + static_cast(env.current()->fees().base.drops()); env.fund(XRP(1'000), owner); - Oracle oracle(env, {.owner = owner}); + Oracle oracle(env, {.owner = owner, .fee = baseFee}); BEAST_EXPECT(oracle.exists()); oracle.set(UpdateArg{ .series = {{"XRP", "EUR", std::nullopt, std::nullopt}}, + .fee = baseFee, .err = ter(tecTOKEN_PAIR_NOT_FOUND)}); // delete all token pairs oracle.set(UpdateArg{ .series = {{"XRP", "USD", std::nullopt, std::nullopt}}, + .fee = baseFee, .err = ter(tecARRAY_EMPTY)}); } { // same BaseAsset and QuoteAsset Env env(*this); + auto const baseFee = + static_cast(env.current()->fees().base.drops()); env.fund(XRP(1'000), owner); Oracle oracle( env, {.owner = owner, .series = {{"USD", "USD", 740, 1}}, + .fee = baseFee, .err = ter(temMALFORMED)}); } { // Scale is greater than maxPriceScale Env env(*this); + auto const baseFee = + static_cast(env.current()->fees().base.drops()); env.fund(XRP(1'000), owner); Oracle oracle( env, {.owner = owner, .series = {{"USD", "BTC", 740, maxPriceScale + 1}}, + .fee = baseFee, .err = ter(temMALFORMED)}); } { // Updating token pair to add and delete Env env(*this); + auto const baseFee = + static_cast(env.current()->fees().base.drops()); env.fund(XRP(1'000), owner); - Oracle oracle(env, {.owner = owner}); + Oracle oracle(env, {.owner = owner, .fee = baseFee}); oracle.set(UpdateArg{ .series = {{"XRP", "EUR", std::nullopt, std::nullopt}, {"XRP", "EUR", 740, 1}}, + .fee = baseFee, .err = ter(temMALFORMED)}); // Delete token pair that doesn't exist in this oracle oracle.set(UpdateArg{ .series = {{"XRP", "EUR", std::nullopt, std::nullopt}}, + .fee = baseFee, .err = ter(tecTOKEN_PAIR_NOT_FOUND)}); // Delete token pair in oracle, which is not in the ledger oracle.set(UpdateArg{ .documentID = 10, .series = {{"XRP", "EUR", std::nullopt, std::nullopt}}, + .fee = baseFee, .err = ter(temMALFORMED)}); } @@ -321,7 +388,10 @@ private: env.fund(XRP(1'000), owner); Oracle oracle( env, {.owner = owner, .fee = -1, .err = ter(temBAD_FEE)}); - Oracle oracle1(env, {.owner = owner}); + Oracle oracle1( + env, + {.owner = owner, + .fee = static_cast(env.current()->fees().base.drops())}); oracle.set( UpdateArg{.owner = owner, .fee = -1, .err = ter(temBAD_FEE)}); } @@ -335,9 +405,12 @@ private: Account const owner("owner"); auto test = [&](Env& env, DataSeries const& series, std::uint16_t adj) { + auto const baseFee = + static_cast(env.current()->fees().base.drops()); env.fund(XRP(1'000), owner); auto const count = ownerCount(env, owner); - Oracle oracle(env, {.owner = owner, .series = series}); + Oracle oracle( + env, {.owner = owner, .series = series, .fee = baseFee}); BEAST_EXPECT(oracle.exists()); BEAST_EXPECT(ownerCount(env, owner) == (count + adj)); BEAST_EXPECT(oracle.expectLastUpdateTime(946694810)); @@ -366,13 +439,17 @@ private: { // Different owner creates a new object Env env(*this); + auto const baseFee = + static_cast(env.current()->fees().base.drops()); Account const some("some"); env.fund(XRP(1'000), owner); env.fund(XRP(1'000), some); - Oracle oracle(env, {.owner = owner}); + Oracle oracle(env, {.owner = owner, .fee = baseFee}); BEAST_EXPECT(oracle.exists()); oracle.set(CreateArg{ - .owner = some, .series = {{"912810RR9", "USD", 740, 1}}}); + .owner = some, + .series = {{"912810RR9", "USD", 740, 1}}, + .fee = baseFee}); BEAST_EXPECT(Oracle::exists(env, some, oracle.documentID())); } } @@ -384,9 +461,11 @@ private: using namespace jtx; Env env(*this); + auto const baseFee = + static_cast(env.current()->fees().base.drops()); Account const owner("owner"); env.fund(XRP(1'000), owner); - Oracle oracle(env, {.owner = owner}); + Oracle oracle(env, {.owner = owner, .fee = baseFee}); BEAST_EXPECT(oracle.exists()); { @@ -394,19 +473,27 @@ private: Account const bad("bad"); env.memoize(bad); oracle.remove( - {.owner = bad, .seq = seq(1), .err = ter(terNO_ACCOUNT)}); + {.owner = bad, + .seq = seq(1), + .fee = baseFee, + .err = ter(terNO_ACCOUNT)}); } // Invalid DocumentID - oracle.remove({.documentID = 2, .err = ter(tecNO_ENTRY)}); + oracle.remove( + {.documentID = 2, .fee = baseFee, .err = ter(tecNO_ENTRY)}); // Invalid owner Account const invalid("invalid"); env.fund(XRP(1'000), invalid); - oracle.remove({.owner = invalid, .err = ter(tecNO_ENTRY)}); + oracle.remove( + {.owner = invalid, .fee = baseFee, .err = ter(tecNO_ENTRY)}); // Invalid flags - oracle.remove({.flags = tfSellNFToken, .err = ter(temINVALID_FLAG)}); + oracle.remove( + {.flags = tfSellNFToken, + .fee = baseFee, + .err = ter(temINVALID_FLAG)}); // Bad fee oracle.remove({.fee = -1, .err = ter(temBAD_FEE)}); @@ -420,11 +507,14 @@ private: Account const owner("owner"); auto test = [&](Env& env, DataSeries const& series, std::uint16_t adj) { + auto const baseFee = + static_cast(env.current()->fees().base.drops()); env.fund(XRP(1'000), owner); - Oracle oracle(env, {.owner = owner, .series = series}); + Oracle oracle( + env, {.owner = owner, .series = series, .fee = baseFee}); auto const count = ownerCount(env, owner); BEAST_EXPECT(oracle.exists()); - oracle.remove({}); + oracle.remove({.fee = baseFee}); BEAST_EXPECT(!oracle.exists()); BEAST_EXPECT(ownerCount(env, owner) == (count - adj)); }; @@ -454,17 +544,24 @@ private: { // deleting the account deletes the oracles Env env(*this); + auto const baseFee = + static_cast(env.current()->fees().base.drops()); + auto const alice = Account("alice"); auto const acctDelFee{drops(env.current()->fees().increment)}; env.fund(XRP(1'000), owner); env.fund(XRP(1'000), alice); Oracle oracle( - env, {.owner = owner, .series = {{"XRP", "USD", 740, 1}}}); + env, + {.owner = owner, + .series = {{"XRP", "USD", 740, 1}}, + .fee = baseFee}); Oracle oracle1( env, {.owner = owner, .documentID = 2, - .series = {{"XRP", "EUR", 740, 1}}}); + .series = {{"XRP", "EUR", 740, 1}}, + .fee = baseFee}); BEAST_EXPECT(ownerCount(env, owner) == 2); BEAST_EXPECT(oracle.exists()); BEAST_EXPECT(oracle1.exists()); @@ -503,13 +600,16 @@ private: { Env env(*this); + auto const baseFee = + static_cast(env.current()->fees().base.drops()); env.fund(XRP(1'000), owner); auto count = ownerCount(env, owner); - Oracle oracle(env, {.owner = owner}); + Oracle oracle(env, {.owner = owner, .fee = baseFee}); BEAST_EXPECT(oracle.exists()); // update existing pair - oracle.set(UpdateArg{.series = {{"XRP", "USD", 740, 2}}}); + oracle.set( + UpdateArg{.series = {{"XRP", "USD", 740, 2}}, .fee = baseFee}); BEAST_EXPECT(oracle.expectPrice({{"XRP", "USD", 740, 2}})); // owner count is increased by 1 since the oracle object is added // with one token pair @@ -517,7 +617,8 @@ private: BEAST_EXPECT(ownerCount(env, owner) == count); // add new pairs, not-included pair is reset - oracle.set(UpdateArg{.series = {{"XRP", "EUR", 700, 2}}}); + oracle.set( + UpdateArg{.series = {{"XRP", "EUR", 700, 2}}, .fee = baseFee}); BEAST_EXPECT(oracle.expectPrice( {{"XRP", "USD", 0, 0}, {"XRP", "EUR", 700, 2}})); // owner count is not changed since the number of pairs is 2 @@ -525,7 +626,8 @@ private: // update both pairs oracle.set(UpdateArg{ - .series = {{"XRP", "USD", 741, 2}, {"XRP", "EUR", 710, 2}}}); + .series = {{"XRP", "USD", 741, 2}, {"XRP", "EUR", 710, 2}}, + .fee = baseFee}); BEAST_EXPECT(oracle.expectPrice( {{"XRP", "USD", 741, 2}, {"XRP", "EUR", 710, 2}})); // owner count is not changed since the number of pairs is 2 @@ -533,25 +635,29 @@ private: // owner count is increased by 1 since the number of pairs is 6 oracle.set(UpdateArg{ - .series = { - {"BTC", "USD", 741, 2}, - {"ETH", "EUR", 710, 2}, - {"YAN", "EUR", 710, 2}, - {"CAN", "EUR", 710, 2}, - }}); + .series = + { + {"BTC", "USD", 741, 2}, + {"ETH", "EUR", 710, 2}, + {"YAN", "EUR", 710, 2}, + {"CAN", "EUR", 710, 2}, + }, + .fee = baseFee}); count += 1; BEAST_EXPECT(ownerCount(env, owner) == count); // update two pairs and delete four oracle.set(UpdateArg{ - .series = {{"BTC", "USD", std::nullopt, std::nullopt}}}); + .series = {{"BTC", "USD", std::nullopt, std::nullopt}}, + .fee = baseFee}); oracle.set(UpdateArg{ - .series = { - {"XRP", "USD", 742, 2}, - {"XRP", "EUR", 711, 2}, - {"ETH", "EUR", std::nullopt, std::nullopt}, - {"YAN", "EUR", std::nullopt, std::nullopt}, - {"CAN", "EUR", std::nullopt, std::nullopt}}}); + .series = + {{"XRP", "USD", 742, 2}, + {"XRP", "EUR", 711, 2}, + {"ETH", "EUR", std::nullopt, std::nullopt}, + {"YAN", "EUR", std::nullopt, std::nullopt}, + {"CAN", "EUR", std::nullopt, std::nullopt}}, + .fee = baseFee}); BEAST_EXPECT(oracle.expectPrice( {{"XRP", "USD", 742, 2}, {"XRP", "EUR", 711, 2}})); // owner count is decreased by 1 since the number of pairs is 2 @@ -562,12 +668,15 @@ private: // Min reserve to create and update { Env env(*this); + auto const baseFee = + static_cast(env.current()->fees().base.drops()); env.fund( env.current()->fees().accountReserve(1) + env.current()->fees().base * 2, owner); - Oracle oracle(env, {.owner = owner}); - oracle.set(UpdateArg{.series = {{"XRP", "USD", 742, 2}}}); + Oracle oracle(env, {.owner = owner, .fee = baseFee}); + oracle.set( + UpdateArg{.series = {{"XRP", "USD", 742, 2}}, .fee = baseFee}); } } @@ -579,6 +688,9 @@ private: Oracle::setFee(100'000); Env env(*this, features); + auto const baseFee = + static_cast(env.current()->fees().base.drops()); + Account const alice{"alice", KeyType::secp256k1}; Account const bogie{"bogie", KeyType::secp256k1}; Account const ed{"ed", KeyType::secp256k1}; @@ -602,24 +714,32 @@ private: // Create // Force close (true) and time advancement because the close time // is no longer 0. - Oracle oracle(env, CreateArg{.owner = alice, .close = true}, false); - oracle.set(CreateArg{.msig = msig(becky), .err = ter(tefBAD_QUORUM)}); - oracle.set( - CreateArg{.msig = msig(zelda), .err = ter(tefBAD_SIGNATURE)}); - oracle.set(CreateArg{.msig = msig(becky, bogie)}); + Oracle oracle( + env, + CreateArg{.owner = alice, .fee = baseFee, .close = true}, + false); + oracle.set(CreateArg{ + .msig = msig(becky), .fee = baseFee, .err = ter(tefBAD_QUORUM)}); + oracle.set(CreateArg{ + .msig = msig(zelda), .fee = baseFee, .err = ter(tefBAD_SIGNATURE)}); + oracle.set(CreateArg{.msig = msig(becky, bogie), .fee = baseFee}); BEAST_EXPECT(oracle.exists()); // Update oracle.set(UpdateArg{ .series = {{"XRP", "USD", 740, 1}}, .msig = msig(becky), + .fee = baseFee, .err = ter(tefBAD_QUORUM)}); oracle.set(UpdateArg{ .series = {{"XRP", "USD", 740, 1}}, .msig = msig(zelda), + .fee = baseFee, .err = ter(tefBAD_SIGNATURE)}); oracle.set(UpdateArg{ - .series = {{"XRP", "USD", 741, 1}}, .msig = msig(becky, bogie)}); + .series = {{"XRP", "USD", 741, 1}}, + .msig = msig(becky, bogie), + .fee = baseFee}); BEAST_EXPECT(oracle.expectPrice({{"XRP", "USD", 741, 1}})); // remove the signer list env(signers(alice, jtx::none), sig(alie)); @@ -632,19 +752,28 @@ private: oracle.set(UpdateArg{ .series = {{"XRP", "USD", 740, 1}}, .msig = msig(becky, bogie), + .fee = baseFee, .err = ter(tefBAD_SIGNATURE)}); // updated list succeeds oracle.set(UpdateArg{ - .series = {{"XRP", "USD", 7412, 2}}, .msig = msig(zelda, bob)}); + .series = {{"XRP", "USD", 7412, 2}}, + .msig = msig(zelda, bob), + .fee = baseFee}); BEAST_EXPECT(oracle.expectPrice({{"XRP", "USD", 7412, 2}})); - oracle.set( - UpdateArg{.series = {{"XRP", "USD", 74245, 3}}, .msig = msig(ed)}); + oracle.set(UpdateArg{ + .series = {{"XRP", "USD", 74245, 3}}, + .msig = msig(ed), + .fee = baseFee}); BEAST_EXPECT(oracle.expectPrice({{"XRP", "USD", 74245, 3}})); // Remove - oracle.remove({.msig = msig(bob), .err = ter(tefBAD_QUORUM)}); - oracle.remove({.msig = msig(becky), .err = ter(tefBAD_SIGNATURE)}); - oracle.remove({.msig = msig(ed)}); + oracle.remove( + {.msig = msig(bob), .fee = baseFee, .err = ter(tefBAD_QUORUM)}); + oracle.remove( + {.msig = msig(becky), + .fee = baseFee, + .err = ter(tefBAD_SIGNATURE)}); + oracle.remove({.msig = msig(ed), .fee = baseFee}); BEAST_EXPECT(!oracle.exists()); } @@ -657,15 +786,18 @@ private: auto const features = supported_amendments() - featurePriceOracle; Account const owner("owner"); Env env(*this, features); + auto const baseFee = + static_cast(env.current()->fees().base.drops()); env.fund(XRP(1'000), owner); { - Oracle oracle(env, {.owner = owner, .err = ter(temDISABLED)}); + Oracle oracle( + env, {.owner = owner, .fee = baseFee, .err = ter(temDISABLED)}); } { - Oracle oracle(env, {.owner = owner}, false); - oracle.remove({.err = ter(temDISABLED)}); + Oracle oracle(env, {.owner = owner, .fee = baseFee}, false); + oracle.remove({.fee = baseFee, .err = ter(temDISABLED)}); } } diff --git a/src/test/app/Path_test.cpp b/src/test/app/Path_test.cpp index 34c17255a..d6a15ac86 100644 --- a/src/test/app/Path_test.cpp +++ b/src/test/app/Path_test.cpp @@ -237,6 +237,7 @@ public: Env env = pathTestEnv(); auto const gw = Account("gateway"); env.fund(XRP(10000), "alice", "bob", gw); + env.close(); env.trust(gw["USD"](100), "alice", "bob"); env.close(); @@ -318,6 +319,7 @@ public: using namespace jtx; Env env = pathTestEnv(); env.fund(XRP(10000), "alice", "bob"); + env.close(); auto const result = find_paths(env, "alice", "bob", Account("bob")["USD"](5)); @@ -331,6 +333,7 @@ public: using namespace jtx; Env env = pathTestEnv(); env.fund(XRP(10000), "alice", "bob"); + env.close(); env.trust(Account("alice")["USD"](700), "bob"); STPathSet st; @@ -350,6 +353,7 @@ public: auto const gw = Account("gateway"); auto const USD = gw["USD"]; env.fund(XRP(10000), "alice", "bob", gw); + env.close(); env.trust(USD(600), "alice"); env.trust(USD(700), "bob"); env(pay(gw, "alice", USD(70))); @@ -369,6 +373,7 @@ public: auto const gw = Account("gateway"); auto const USD = gw["USD"]; env.fund(XRP(10000), "alice", "bob", gw); + env.close(); env.trust(USD(600), "alice"); env.trust(USD(700), "bob"); env(pay(gw, "alice", USD(70))); @@ -389,6 +394,7 @@ public: testcase("XRP to XRP"); Env env = pathTestEnv(); env.fund(XRP(10000), "alice", "bob"); + env.close(); auto const result = find_paths(env, "alice", "bob", XRP(5)); BEAST_EXPECT(std::get<0>(result).empty()); @@ -403,6 +409,7 @@ public: { Env env = pathTestEnv(); env.fund(XRP(10000), "alice", "bob", "carol", "dan", "edward"); + env.close(); env.trust(Account("alice")["USD"](10), "bob"); env.trust(Account("bob")["USD"](10), "carol"); env.trust(Account("carol")["USD"](10), "edward"); @@ -424,6 +431,7 @@ public: auto const gw = Account("gateway"); auto const USD = gw["USD"]; env.fund(XRP(10000), "alice", "bob", "carol", gw); + env.close(); env.trust(USD(100), "bob", "carol"); env(pay(gw, "carol", USD(100))); env(offer("carol", XRP(100), USD(100))); @@ -460,6 +468,7 @@ public: auto const gw2 = Account("gateway2"); auto const gw2_USD = gw2["USD"]; env.fund(XRP(10000), "alice", "bob", gw, gw2); + env.close(); env.trust(USD(600), "alice"); env.trust(gw2_USD(800), "alice"); env.trust(USD(700), "bob"); @@ -489,6 +498,7 @@ public: auto const gw2 = Account("gateway2"); auto const gw2_USD = gw2["USD"]; env.fund(XRP(10000), "alice", "bob", gw, gw2); + env.close(); env(rate(gw2, 1.1)); env.trust(USD(600), "alice"); env.trust(gw2_USD(800), "alice"); @@ -518,6 +528,7 @@ public: auto const gw2 = Account("gateway2"); auto const gw2_USD = gw2["USD"]; env.fund(XRP(10000), "alice", "bob", gw, gw2); + env.close(); env(rate(gw2, 1.1)); env.trust(USD(600), "alice"); env.trust(gw2_USD(800), "alice"); @@ -549,6 +560,7 @@ public: auto const gw2 = Account("gateway2"); auto const gw2_USD = gw2["USD"]; env.fund(XRP(10000), "alice", "bob", "carol", "dan", gw, gw2); + env.close(); env(rate("carol", 1.1)); env.trust(Account("carol")["USD"](800), "alice", "bob"); env.trust(Account("dan")["USD"](800), "alice", "bob"); @@ -738,6 +750,7 @@ public: using namespace jtx; Env env = pathTestEnv(); env.fund(XRP(10000), "alice", "bob", "carol", "dan"); + env.close(); env.trust(Account("bob")["USD"](100), "alice", "carol", "dan"); env.trust(Account("alice")["USD"](100), "dan"); env.trust(Account("carol")["USD"](100), "dan"); @@ -776,6 +789,7 @@ public: using namespace jtx; Env env = pathTestEnv(); env.fund(XRP(10000), "alice", "bob", "carol", "dan"); + env.close(); env.trust(Account("alice")["USD"](40), "bob"); env.trust(Account("dan")["USD"](20), "bob"); env.trust(Account("alice")["USD"](20), "carol"); @@ -795,6 +809,7 @@ public: using namespace jtx; Env env = pathTestEnv(); env.fund(XRP(10000), "alice", "bob", "carol", "dan", "edward"); + env.close(); env.trust(Account("alice")["USD"](120), "edward"); env.trust(Account("edward")["USD"](25), "bob"); env.trust(Account("dan")["USD"](100), "bob"); @@ -824,6 +839,7 @@ public: auto const gw = Account("gateway"); auto const AUD = gw["AUD"]; env.fund(XRP(10000), "alice", "bob", "carol", gw); + env.close(); env(rate(gw, 1.1)); env.trust(AUD(100), "bob", "carol"); env(pay(gw, "carol", AUD(50))); @@ -844,6 +860,7 @@ public: using namespace jtx; Env env = pathTestEnv(); env.fund(XRP(10000), "alice", "bob", "carol"); + env.close(); env.trust(Account("alice")["USD"](1000), "bob"); env.trust(Account("bob")["USD"](1000), "carol"); @@ -862,6 +879,7 @@ public: using namespace jtx; Env env = pathTestEnv(); env.fund(XRP(10000), "alice", "bob"); + env.close(); env(trust("bob", Account("alice")["USD"](1000)), json("{\"" + sfQualityIn.fieldName + "\": 2000}"), json("{\"" + sfQualityOut.fieldName + "\": 1400000000}")); @@ -908,6 +926,7 @@ public: using namespace jtx; Env env = pathTestEnv(); env.fund(XRP(10000), "alice", "bob"); + env.close(); env.trust(Account("bob")["USD"](1000), "alice"); env.trust(Account("alice")["USD"](1000), "bob"); @@ -958,6 +977,7 @@ public: using namespace jtx; Env env = pathTestEnv(); env.fund(XRP(10000), "alice", "bob"); + env.close(); env.trust(Account("bob")["USD"](1000), "alice"); env(pay("bob", "alice", Account("bob")["USD"](50))); env.trust(Account("bob")["USD"](0), "alice"); diff --git a/src/test/app/PayChan_test.cpp b/src/test/app/PayChan_test.cpp index 0b26ea384..ba528d0f1 100644 --- a/src/test/app/PayChan_test.cpp +++ b/src/test/app/PayChan_test.cpp @@ -2004,7 +2004,6 @@ struct PayChan_test : public beast::unit_test::suite Env env{*this, amd}; env.fund(XRP(10000), alice, bob, carol); env.close(); - auto const feeDrops = env.current()->fees().base; // Create a channel from alice to bob auto const pk = alice.pk(); @@ -2023,6 +2022,7 @@ struct PayChan_test : public beast::unit_test::suite carol, withOwnerDirFix ? TER(tecHAS_OBLIGATIONS) : TER(tesSUCCESS)); + auto const feeDrops = env.current()->fees().base; auto chanBal = channelBalance(*env.current(), chan); auto chanAmt = channelAmount(*env.current(), chan); BEAST_EXPECT(chanBal == XRP(0)); @@ -2096,7 +2096,6 @@ struct PayChan_test : public beast::unit_test::suite Env env{*this, features - fixPayChanRecipientOwnerDir}; env.fund(XRP(10000), alice, bob, carol); env.close(); - auto const feeDrops = env.current()->fees().base; // Create a channel from alice to bob auto const pk = alice.pk(); @@ -2111,6 +2110,7 @@ struct PayChan_test : public beast::unit_test::suite rmAccount(env, bob, carol); BEAST_EXPECT(!env.closed()->exists(keylet::account(bob.id()))); + auto const feeDrops = env.current()->fees().base; auto chanBal = channelBalance(*env.current(), chan); auto chanAmt = channelAmount(*env.current(), chan); BEAST_EXPECT(chanBal == XRP(0)); diff --git a/src/test/app/ReducedOffer_test.cpp b/src/test/app/ReducedOffer_test.cpp index 5af06d594..546a07d93 100644 --- a/src/test/app/ReducedOffer_test.cpp +++ b/src/test/app/ReducedOffer_test.cpp @@ -116,7 +116,7 @@ public: STAmount const initialRate = Quality(newOffer).rate(); std::uint32_t const bobOfferSeq = env.seq(bob); STAmount const bobInitialBalance = env.balance(bob); - STAmount const bobsFee = drops(10); + STAmount const bobsFee = env.current()->fees().base; env(offer(bob, newOffer.in, newOffer.out, tfSell), fee(bobsFee)); env.close(); diff --git a/src/test/app/Regression_test.cpp b/src/test/app/Regression_test.cpp index e357764df..c96566f8d 100644 --- a/src/test/app/Regression_test.cpp +++ b/src/test/app/Regression_test.cpp @@ -178,6 +178,7 @@ struct Regression_test : public beast::unit_test::suite envconfig([](std::unique_ptr cfg) { cfg->section("transaction_queue") .set("minimum_txn_in_ledger_standalone", "3"); + cfg->FEES.reference_fee = 10; return cfg; }), features); diff --git a/src/test/app/SetAuth_test.cpp b/src/test/app/SetAuth_test.cpp index c531de2d7..e55fbc4d5 100644 --- a/src/test/app/SetAuth_test.cpp +++ b/src/test/app/SetAuth_test.cpp @@ -57,6 +57,7 @@ struct SetAuth_test : public beast::unit_test::suite env.fund(XRP(100000), "alice", "bob", gw); env(fset(gw, asfRequireAuth)); + env.close(); env(auth(gw, "alice", "USD")); BEAST_EXPECT( env.le(keylet::line(Account("alice").id(), gw.id(), USD.currency))); diff --git a/src/test/jtx/Env_test.cpp b/src/test/jtx/Env_test.cpp index 07009fbe7..b5ee0ac79 100644 --- a/src/test/jtx/Env_test.cpp +++ b/src/test/jtx/Env_test.cpp @@ -190,6 +190,7 @@ public: { Env env(*this, features); env.fund(n, "alice", "bob", gw); + env.close(); env(trust("alice", USD(100)), require(lines("alice", 1))); } @@ -200,6 +201,7 @@ public: BEAST_EXPECT(env.balance(alice, USD) != 0); BEAST_EXPECT(env.balance(alice, USD) == USD(0)); env.fund(n, alice, gw); + env.close(); BEAST_EXPECT(env.balance(alice) == n); BEAST_EXPECT(env.balance(gw) == n); env.trust(USD(1000), alice); @@ -244,6 +246,7 @@ public: env.require(balance("alice", none)); env.require(balance("alice", XRP(none))); env.fund(XRP(10000), "alice", gw); + env.close(); env.require(balance("alice", USD(none))); env.trust(USD(100), "alice"); env.require(balance("alice", XRP(10000))); // fee refunded @@ -682,6 +685,7 @@ public: auto const gw = Account("gw"); auto const USD = gw["USD"]; env.fund(XRP(10000), "alice", "bob"); + env.close(); env.json( pay("alice", "bob", USD(10)), path(Account("alice")), @@ -718,6 +722,8 @@ public: Env env(*this, features); Env_ss envs(env); + auto const baseFee = env.current()->fees().base; + auto const alice = Account("alice"); env.fund(XRP(10000), alice); @@ -751,12 +757,16 @@ public: // Force the factor low enough to fail params[jss::fee_mult_max] = 1; params[jss::fee_div_max] = 2; + + auto const expectedErrorString = "Fee of " + + std::to_string(baseFee.drops()) + + " exceeds the requested tx limit of " + + std::to_string(baseFee.drops() / 2); envs( noop(alice), fee(none), seq(none), - rpc(rpcHIGH_FEE, - "Fee of 10 exceeds the requested tx limit of 5"))(params); + rpc(rpcHIGH_FEE, expectedErrorString))(params); auto tx = env.tx(); BEAST_EXPECT(!tx); diff --git a/src/test/ledger/BookDirs_test.cpp b/src/test/ledger/BookDirs_test.cpp index 19a1b5d27..ed7ca9108 100644 --- a/src/test/ledger/BookDirs_test.cpp +++ b/src/test/ledger/BookDirs_test.cpp @@ -34,6 +34,7 @@ struct BookDirs_test : public beast::unit_test::suite auto gw = Account("gw"); auto USD = gw["USD"]; env.fund(XRP(1000000), "alice", "bob", "gw"); + env.close(); { Book book(xrpIssue(), USD.issue()); diff --git a/src/test/ledger/View_test.cpp b/src/test/ledger/View_test.cpp index a9af8e2a4..4af3e37ce 100644 --- a/src/test/ledger/View_test.cpp +++ b/src/test/ledger/View_test.cpp @@ -815,6 +815,7 @@ class View_test : public beast::unit_test::suite auto const EUR = gw["EUR"]; env.fund(XRP(10000), alice, bob, carol, gw); + env.close(); env.trust(USD(100), alice, bob, carol); { // Global freezing. diff --git a/src/test/rpc/AccountTx_test.cpp b/src/test/rpc/AccountTx_test.cpp index 08918711c..bba1bf7b6 100644 --- a/src/test/rpc/AccountTx_test.cpp +++ b/src/test/rpc/AccountTx_test.cpp @@ -119,6 +119,10 @@ class AccountTx_test : public beast::unit_test::suite Env env( *this, + envconfig([](std::unique_ptr cfg) { + cfg->FEES.reference_fee = 10; + return cfg; + }), supported_amendments() - featureXahauGenesis - fixHookAPI20251128); Account A1{"A1"}; env.fund(XRP(10000), A1); diff --git a/src/test/rpc/DeliveredAmount_test.cpp b/src/test/rpc/DeliveredAmount_test.cpp index bd01d5d4b..c6de424e3 100644 --- a/src/test/rpc/DeliveredAmount_test.cpp +++ b/src/test/rpc/DeliveredAmount_test.cpp @@ -191,7 +191,9 @@ class DeliveredAmount_test : public beast::unit_test::suite auto const gw = Account("gateway"); auto const USD = gw["USD"]; - Env env{*this, features}; + auto cfg = envconfig(); + cfg->FEES.reference_fee = 10; + Env env(*this, std::move(cfg), features); env.fund(XRP(10000), alice, bob, carol, gw); env.trust(USD(1000), alice, bob, carol); env.close(); @@ -273,7 +275,9 @@ class DeliveredAmount_test : public beast::unit_test::suite auto const gw = Account("gateway"); auto const USD = gw["USD"]; - Env env{*this, features}; + auto cfg = envconfig(); + cfg->FEES.reference_fee = 10; + Env env(*this, std::move(cfg), features); env.fund(XRP(10000), alice, bob, carol, gw); env.trust(USD(1000), alice, bob, carol); env.close(); diff --git a/src/test/rpc/GatewayBalances_test.cpp b/src/test/rpc/GatewayBalances_test.cpp index 730d58bcc..249d4f892 100644 --- a/src/test/rpc/GatewayBalances_test.cpp +++ b/src/test/rpc/GatewayBalances_test.cpp @@ -48,6 +48,7 @@ public: // Create a hotwallet Account const hw{"hw"}; env.fund(XRP(10000), "hw"); + env.close(); env(trust(hw, USD(10000))); env(trust(hw, JPY(10000))); env(pay(alice, hw, USD(5000))); @@ -56,12 +57,14 @@ public: // Create some clients Account const bob{"bob"}; env.fund(XRP(10000), "bob"); + env.close(); env(trust(bob, USD(100))); env(trust(bob, CNY(100))); env(pay(alice, bob, USD(50))); Account const charley{"charley"}; env.fund(XRP(10000), "charley"); + env.close(); env(trust(charley, CNY(500))); env(trust(charley, JPY(500))); env(pay(alice, charley, CNY(250))); @@ -69,6 +72,7 @@ public: Account const dave{"dave"}; env.fund(XRP(10000), "dave"); + env.close(); env(trust(dave, CNY(100))); env(pay(alice, dave, CNY(30))); @@ -206,6 +210,7 @@ public: // Create a hotwallet Account const hw{"hw"}; env.fund(XRP(10000), hw); + env.close(); env(trust(hw, maxUSD)); env.close(); env(pay(alice, hw, maxUSD)); @@ -213,12 +218,14 @@ public: // Create some clients Account const bob{"bob"}; env.fund(XRP(10000), bob); + env.close(); env(trust(bob, maxUSD)); env.close(); env(pay(alice, bob, maxUSD)); Account const charley{"charley"}; env.fund(XRP(10000), charley); + env.close(); env(trust(charley, maxUSD)); env.close(); env(pay(alice, charley, maxUSD)); diff --git a/src/test/rpc/GetAggregatePrice_test.cpp b/src/test/rpc/GetAggregatePrice_test.cpp index 1e09219f5..4e9b95069 100644 --- a/src/test/rpc/GetAggregatePrice_test.cpp +++ b/src/test/rpc/GetAggregatePrice_test.cpp @@ -43,6 +43,7 @@ public: { Env env(*this); + auto const baseFee = env.current()->fees().base; // missing base_asset auto ret = Oracle::aggregatePrice(env, std::nullopt, "USD", oracles); @@ -126,7 +127,10 @@ public: // oracles have wrong asset pair env.fund(XRP(1'000), owner); Oracle oracle( - env, {.owner = owner, .series = {{"XRP", "EUR", 740, 1}}}); + env, + {.owner = owner, + .series = {{"XRP", "EUR", 740, 1}}, + .fee = static_cast(baseFee.drops())}); ret = Oracle::aggregatePrice( env, "XRP", "USD", {{{owner, oracle.documentID()}}}); BEAST_EXPECT(ret[jss::error].asString() == "objectNotFound"); @@ -160,12 +164,16 @@ public: // too many oracles { Env env(*this); + auto const baseFee = + static_cast(env.current()->fees().base.drops()); + OraclesData oracles; for (int i = 0; i < 201; ++i) { Account const owner(std::to_string(i)); env.fund(XRP(1'000), owner); - Oracle oracle(env, {.owner = owner, .documentID = i}); + Oracle oracle( + env, {.owner = owner, .documentID = i, .fee = baseFee}); oracles.emplace_back(owner, oracle.documentID()); } auto const ret = Oracle::aggregatePrice(env, "XRP", "USD", oracles); @@ -183,14 +191,18 @@ public: oracles.reserve(10); for (int i = 0; i < 10; ++i) { + auto const baseFee = + static_cast(env.current()->fees().base.drops()); + Account const owner{std::to_string(i)}; env.fund(XRP(1'000), owner); Oracle oracle( env, {.owner = owner, .documentID = rand(), - .series = { - {"XRP", "USD", 740 + i, 1}, {"XRP", "EUR", 740, 1}}}); + .series = + {{"XRP", "USD", 740 + i, 1}, {"XRP", "EUR", 740, 1}}, + .fee = baseFee}); oracles.emplace_back(owner, oracle.documentID()); } }; @@ -238,6 +250,9 @@ public: // updated ledgers { Env env(*this); + auto const baseFee = + static_cast(env.current()->fees().base.drops()); + OraclesData oracles; prep(env, oracles); for (int i = 0; i < 3; ++i) @@ -245,25 +260,32 @@ public: Oracle oracle( env, {.owner = oracles[i].first, - .documentID = asUInt(*oracles[i].second)}, + .documentID = asUInt(*oracles[i].second), + .fee = baseFee}, false); // push XRP/USD by more than three ledgers, so this price // oracle is not included in the dataset - oracle.set(UpdateArg{.series = {{"XRP", "EUR", 740, 1}}}); - oracle.set(UpdateArg{.series = {{"XRP", "EUR", 740, 1}}}); - oracle.set(UpdateArg{.series = {{"XRP", "EUR", 740, 1}}}); + oracle.set(UpdateArg{ + .series = {{"XRP", "EUR", 740, 1}}, .fee = baseFee}); + oracle.set(UpdateArg{ + .series = {{"XRP", "EUR", 740, 1}}, .fee = baseFee}); + oracle.set(UpdateArg{ + .series = {{"XRP", "EUR", 740, 1}}, .fee = baseFee}); } for (int i = 3; i < 6; ++i) { Oracle oracle( env, {.owner = oracles[i].first, - .documentID = asUInt(*oracles[i].second)}, + .documentID = asUInt(*oracles[i].second), + .fee = baseFee}, false); // push XRP/USD by two ledgers, so this price // is included in the dataset - oracle.set(UpdateArg{.series = {{"XRP", "EUR", 740, 1}}}); - oracle.set(UpdateArg{.series = {{"XRP", "EUR", 740, 1}}}); + oracle.set(UpdateArg{ + .series = {{"XRP", "EUR", 740, 1}}, .fee = baseFee}); + oracle.set(UpdateArg{ + .series = {{"XRP", "EUR", 740, 1}}, .fee = baseFee}); } // entire and trimmed stats @@ -286,6 +308,9 @@ public: // Reduced data set because of the time threshold { Env env(*this); + auto const baseFee = + static_cast(env.current()->fees().base.drops()); + OraclesData oracles; prep(env, oracles); for (int i = 0; i < oracles.size(); ++i) @@ -293,11 +318,13 @@ public: Oracle oracle( env, {.owner = oracles[i].first, - .documentID = asUInt(*oracles[i].second)}, + .documentID = asUInt(*oracles[i].second), + .fee = baseFee}, false); // push XRP/USD by two ledgers, so this price // is included in the dataset - oracle.set(UpdateArg{.series = {{"XRP", "USD", 740, 1}}}); + oracle.set(UpdateArg{ + .series = {{"XRP", "USD", 740, 1}}, .fee = baseFee}); } // entire stats only, limit lastUpdateTime to {200, 125} diff --git a/src/test/rpc/JSONRPC_test.cpp b/src/test/rpc/JSONRPC_test.cpp index 03f206707..8d4f76312 100644 --- a/src/test/rpc/JSONRPC_test.cpp +++ b/src/test/rpc/JSONRPC_test.cpp @@ -2065,6 +2065,8 @@ public: { testcase("autofill fees"); test::jtx::Env env(*this); + auto const baseFee = + static_cast(env.current()->fees().base.drops()); auto ledger = env.current(); auto const& feeTrack = env.app().getFeeTrack(); @@ -2084,7 +2086,7 @@ public: BEAST_EXPECT(!RPC::contains_error(result)); BEAST_EXPECT( req[jss::tx_json].isMember(jss::Fee) && - req[jss::tx_json][jss::Fee] == 10); + req[jss::tx_json][jss::Fee] == baseFee); } { @@ -2105,7 +2107,7 @@ public: BEAST_EXPECT(!RPC::contains_error(result)); BEAST_EXPECT( req[jss::tx_json].isMember(jss::Fee) && - req[jss::tx_json][jss::Fee] == 10); + req[jss::tx_json][jss::Fee] == baseFee); } { @@ -2584,20 +2586,24 @@ public: { testcase("sign/submit RPCs"); using namespace std::chrono_literals; + using namespace test::jtx; // Use jtx to set up a ledger so the tests will do the right thing. - test::jtx::Account const a{"a"}; // rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA - test::jtx::Account const g{"g"}; // rLPwWB1itaUGMV8kbMLLysjGkEpTM2Soy4 + Account const a{"a"}; // rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA + Account const g{"g"}; // rLPwWB1itaUGMV8kbMLLysjGkEpTM2Soy4 auto const USD = g["USD"]; // Account: rJrxi4Wxev4bnAGVNP9YCdKPdAoKfAmcsi // seed: sh1yJfwoi98zCygwijUzuHmJDeVKd - test::jtx::Account const ed{"ed", KeyType::ed25519}; + Account const ed{"ed", KeyType::ed25519}; // master is rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh. // "b" (not in the ledger) is rDg53Haik2475DJx8bjMDSDPj4VX7htaMd. // "c" (phantom signer) is rPcNzota6B8YBokhYtcTNqQVCngtbnWfux. - test::jtx::Env env(*this); - env.fund(test::jtx::XRP(100000), a, ed, g); + Env env(*this, envconfig([](std::unique_ptr cfg) { + cfg->FEES.reference_fee = 10; + return cfg; + })); + env.fund(XRP(100000), a, ed, g); env.close(); env(trust(a, USD(1000))); diff --git a/src/test/rpc/LedgerClosed_test.cpp b/src/test/rpc/LedgerClosed_test.cpp index b0a2216b1..fc7b3a7da 100644 --- a/src/test/rpc/LedgerClosed_test.cpp +++ b/src/test/rpc/LedgerClosed_test.cpp @@ -31,7 +31,11 @@ public: testMonitorRoot() { using namespace test::jtx; - Env env{*this, FeatureBitset{}}; + + // This test relies on ledger hash so must lock it to fee 10. + auto p = envconfig(); + p->FEES.reference_fee = 10; + Env env{*this, std::move(p), FeatureBitset{}}; Account const alice{"alice"}; env.fund(XRP(10000), alice); diff --git a/src/test/rpc/LedgerRPC_test.cpp b/src/test/rpc/LedgerRPC_test.cpp index c202156b5..043ac0230 100644 --- a/src/test/rpc/LedgerRPC_test.cpp +++ b/src/test/rpc/LedgerRPC_test.cpp @@ -612,8 +612,12 @@ public: { testcase("ledger_entry Request AccountRoot"); using namespace test::jtx; + + auto cfg = envconfig(); + cfg->FEES.reference_fee = 10; Env env{ *this, + std::move(cfg), supported_amendments() - featureXahauGenesis - fixHookAPI20251128}; Account const alice{"alice"}; env.fund(XRP(10000), alice); @@ -1092,7 +1096,7 @@ public: { // Setup Bob with DepositAuth - env(fset(bob, asfDepositAuth), fee(drops(10))); + env(fset(bob, asfDepositAuth)); env.close(); env(deposit::authCredentials(bob, {{issuer, credType}})); env.close(); @@ -3168,9 +3172,12 @@ public: { testcase("Lookup ledger"); using namespace test::jtx; - Env env{*this, FeatureBitset{}}; // hashes requested below assume - // no amendments + auto cfg = envconfig(); + cfg->FEES.reference_fee = 10; + Env env{ + *this, std::move(cfg), FeatureBitset{}}; // hashes requested below + // assume no amendments env.fund(XRP(10000), "alice"); env.close(); env.fund(XRP(10000), "bob"); @@ -3382,16 +3389,19 @@ public: { testcase("Ledger with Queued Transactions"); using namespace test::jtx; - Env env{ + auto cfg = envconfig([](std::unique_ptr cfg) { + auto& section = cfg->section("transaction_queue"); + section.set("minimum_txn_in_ledger_standalone", "3"); + section.set("normal_consensus_increase_percent", "0"); + return cfg; + }); + + cfg->FEES.reference_fee = 10; + Env env( *this, - envconfig([](std::unique_ptr cfg) { - auto& section = cfg->section("transaction_queue"); - section.set("minimum_txn_in_ledger_standalone", "3"); - section.set("normal_consensus_increase_percent", "0"); - return cfg; - }), + std::move(cfg), supported_amendments() - featureXahauGenesis - - fixProvisionalDoubleThreading - fixHookAPI20251128}; + fixProvisionalDoubleThreading - fixHookAPI20251128); Json::Value jv; jv[jss::ledger_index] = "current"; @@ -3651,7 +3661,10 @@ public: Env env(*this); Account const owner("owner"); env.fund(XRP(1'000), owner); - Oracle oracle(env, {.owner = owner}); + Oracle oracle( + env, + {.owner = owner, + .fee = static_cast(env.current()->fees().base.drops())}); // Malformed document id auto res = Oracle::ledgerEntry(env, owner, NoneTag); @@ -3685,6 +3698,8 @@ public: using namespace ripple::test::jtx::oracle; Env env(*this); + auto const baseFee = + static_cast(env.current()->fees().base.drops()); std::vector accounts; std::vector oracles; for (int i = 0; i < 10; ++i) @@ -3692,11 +3707,13 @@ public: Account const owner(std::string("owner") + std::to_string(i)); env.fund(XRP(1'000), owner); // different accounts can have the same asset pair - Oracle oracle(env, {.owner = owner, .documentID = i}); + Oracle oracle( + env, {.owner = owner, .documentID = i, .fee = baseFee}); accounts.push_back(owner.id()); oracles.push_back(oracle.documentID()); // same account can have different asset pair - Oracle oracle1(env, {.owner = owner, .documentID = i + 10}); + Oracle oracle1( + env, {.owner = owner, .documentID = i + 10, .fee = baseFee}); accounts.push_back(owner.id()); oracles.push_back(oracle1.documentID()); } diff --git a/src/test/rpc/LedgerRequestRPC_test.cpp b/src/test/rpc/LedgerRequestRPC_test.cpp index 221f63981..b34233991 100644 --- a/src/test/rpc/LedgerRequestRPC_test.cpp +++ b/src/test/rpc/LedgerRequestRPC_test.cpp @@ -169,8 +169,14 @@ public: testEvolution() { using namespace test::jtx; - Env env{*this, FeatureBitset{}}; // the hashes being checked below - // assume no amendments + + auto cfg = envconfig(); + cfg->FEES.reference_fee = 10; + Env env{ + *this, + std::move(cfg), + FeatureBitset{}}; // the hashes being checked below + // assume no amendments Account const gw{"gateway"}; auto const USD = gw["USD"]; env.fund(XRP(100000), gw); @@ -313,6 +319,7 @@ public: using namespace test::jtx; using namespace std::chrono_literals; Env env{*this, envconfig([](std::unique_ptr cfg) { + cfg->FEES.reference_fee = 10; cfg->NODE_SIZE = 0; return cfg; })}; diff --git a/src/test/rpc/OwnerInfo_test.cpp b/src/test/rpc/OwnerInfo_test.cpp index f9153ed80..c129fb429 100644 --- a/src/test/rpc/OwnerInfo_test.cpp +++ b/src/test/rpc/OwnerInfo_test.cpp @@ -94,6 +94,7 @@ class OwnerInfo_test : public beast::unit_test::suite auto const alice = Account{"alice"}; auto const gw = Account{"gateway"}; env.fund(XRP(10000), alice, gw); + env.close(); auto const USD = gw["USD"]; auto const CNY = gw["CNY"]; env(trust(alice, USD(1000))); diff --git a/src/test/rpc/RobustTransaction_test.cpp b/src/test/rpc/RobustTransaction_test.cpp index ccef6e297..aa53bd6e0 100644 --- a/src/test/rpc/RobustTransaction_test.cpp +++ b/src/test/rpc/RobustTransaction_test.cpp @@ -460,7 +460,8 @@ public: Json::Value jv; jv[jss::secret] = toBase58(generateSeed("alice")); jv[jss::tx_json] = fset("alice", 0); - jv[jss::tx_json][jss::Fee] = 10; + jv[jss::tx_json][jss::Fee] = + static_cast(env.current()->fees().base.drops()); jv = wsc->invoke("submit", jv); if (wsc->version() == 2) { diff --git a/src/test/rpc/Simulate_test.cpp b/src/test/rpc/Simulate_test.cpp index 6eaf9059e..e7c8b1072 100644 --- a/src/test/rpc/Simulate_test.cpp +++ b/src/test/rpc/Simulate_test.cpp @@ -466,9 +466,6 @@ class Simulate_test : public beast::unit_test::suite { BEAST_EXPECT(result[jss::error] == "highFee"); BEAST_EXPECT(result[jss::error_code] == rpcHIGH_FEE); - BEAST_EXPECT( - result[jss::error_message] == - "Fee of 8889 exceeds the requested tx limit of 100"); } } } @@ -642,7 +639,9 @@ class Simulate_test : public beast::unit_test::suite auto finalFields = modifiedNode[sfFinalFields]; BEAST_EXPECT( finalFields[sfBalance] == - "99999999999999990"); + std::to_string( + 100'000'000'000'000'000 - + env.current()->fees().base.drops())); } } BEAST_EXPECT( diff --git a/src/test/rpc/Subscribe_test.cpp b/src/test/rpc/Subscribe_test.cpp index 6a9e58a66..8499af209 100644 --- a/src/test/rpc/Subscribe_test.cpp +++ b/src/test/rpc/Subscribe_test.cpp @@ -172,6 +172,7 @@ public: using namespace std::chrono_literals; using namespace jtx; Env env(*this, supported_amendments() - featureXahauGenesis); + auto baseFee = env.current()->fees().base.drops(); auto wsc = makeWSClient(env.app().config()); Json::Value stream; @@ -203,9 +204,9 @@ public: jv[jss::transaction][jss::TransactionType] // == jss::Payment && jv[jss::transaction][jss::DeliverMax] // - == "10000000010" && + == std::to_string(10000000000 + baseFee) && jv[jss::transaction][jss::Fee] // - == "10" && + == std::to_string(baseFee) && jv[jss::transaction][jss::Sequence] // == 1; })); @@ -228,9 +229,9 @@ public: jv[jss::transaction][jss::TransactionType] // == jss::Payment && jv[jss::transaction][jss::DeliverMax] // - == "10000000010" && + == std::to_string(10000000000 + baseFee) && jv[jss::transaction][jss::Fee] // - == "10" && + == std::to_string(baseFee) && jv[jss::transaction][jss::Sequence] // == 2; })); @@ -319,7 +320,12 @@ public: using namespace std::chrono_literals; using namespace jtx; Env env( - *this, supported_amendments() - featureXahauGenesis - featureTouch); + *this, + envconfig([](std::unique_ptr cfg) { + cfg->FEES.reference_fee = 10; + return cfg; + }), + supported_amendments() - featureXahauGenesis - featureTouch); auto wsc = makeWSClient(env.app().config()); Json::Value stream{Json::objectValue}; diff --git a/src/test/rpc/TransactionEntry_test.cpp b/src/test/rpc/TransactionEntry_test.cpp index 974c03184..b90f4417c 100644 --- a/src/test/rpc/TransactionEntry_test.cpp +++ b/src/test/rpc/TransactionEntry_test.cpp @@ -37,7 +37,10 @@ class TransactionEntry_test : public beast::unit_test::suite { testcase("Invalid request params"); using namespace test::jtx; - Env env{*this}; + Env env{*this, envconfig([](std::unique_ptr cfg) { + cfg->FEES.reference_fee = 10; + return cfg; + })}; { // no params @@ -154,6 +157,10 @@ class TransactionEntry_test : public beast::unit_test::suite using namespace test::jtx; Env env{ *this, + envconfig([](std::unique_ptr cfg) { + cfg->FEES.reference_fee = 10; + return cfg; + }), supported_amendments() - featureXahauGenesis - featureTouch - fixHookAPI20251128, }; diff --git a/src/test/rpc/Transaction_test.cpp b/src/test/rpc/Transaction_test.cpp index 34d528efa..a1e156e7a 100644 --- a/src/test/rpc/Transaction_test.cpp +++ b/src/test/rpc/Transaction_test.cpp @@ -774,7 +774,13 @@ class Transaction_test : public beast::unit_test::suite using namespace test::jtx; using std::to_string; - Env env{*this, features}; + Env env{ + *this, + envconfig([](std::unique_ptr cfg) { + cfg->FEES.reference_fee = 10; + return cfg; + }), + features}; Account const alice{"alice"}; Account const alie{"alie"}; Account const gw{"gw"}; @@ -856,7 +862,13 @@ class Transaction_test : public beast::unit_test::suite using namespace test::jtx; using std::to_string; - Env env{*this, features}; + Env env{ + *this, + envconfig([](std::unique_ptr cfg) { + cfg->FEES.reference_fee = 10; + return cfg; + }), + features}; Account const alice{"alice"}; Account const gw{"gw"}; auto const USD{gw["USD"]};