From d734fe600b763bb2ba478a71473e8fbf8681a616 Mon Sep 17 00:00:00 2001 From: Denis Angell Date: Wed, 18 Oct 2023 10:06:29 +0200 Subject: [PATCH] Fix tests re: xahau genesis (#135) * Update AccountTxPaging_test.cpp * fix failing tests * fix failing tests * Update Import_test.cpp --- src/test/app/AccountTxPaging_test.cpp | 8 +- src/test/app/DepositAuth_test.cpp | 41 ++--- src/test/app/Freeze_test.cpp | 2 +- src/test/app/LedgerMaster_test.cpp | 12 +- src/test/app/NFTokenBurn_test.cpp | 2 +- src/test/app/Offer_test.cpp | 2 +- src/test/app/Regression_test.cpp | 32 ++-- src/test/app/Ticket_test.cpp | 50 ++++--- src/test/app/TxQ_test.cpp | 208 +++++++++++++------------- src/test/jtx/Env_test.cpp | 114 +++++++------- src/test/rpc/AccountObjects_test.cpp | 26 ++-- src/test/rpc/AccountOffers_test.cpp | 22 +-- src/test/rpc/Book_test.cpp | 82 +++++----- src/test/rpc/DeliveredAmount_test.cpp | 14 +- src/test/rpc/OwnerInfo_test.cpp | 14 +- src/test/rpc/ReportingETL_test.cpp | 33 ++-- 16 files changed, 345 insertions(+), 317 deletions(-) diff --git a/src/test/app/AccountTxPaging_test.cpp b/src/test/app/AccountTxPaging_test.cpp index d3969e279..1ac7c38d1 100644 --- a/src/test/app/AccountTxPaging_test.cpp +++ b/src/test/app/AccountTxPaging_test.cpp @@ -61,12 +61,12 @@ class AccountTxPaging_test : public beast::unit_test::suite } void - testAccountTxPaging() + testAccountTxPaging(FeatureBitset features) { testcase("Paging for Single Account"); using namespace test::jtx; - Env env(*this); + Env env(*this, features); Account A1{"A1"}; Account A2{"A2"}; Account A3{"A3"}; @@ -267,7 +267,9 @@ public: void run() override { - testAccountTxPaging(); + using namespace test::jtx; + auto const sa = supported_amendments(); + testAccountTxPaging(sa - featureXahauGenesis); } }; diff --git a/src/test/app/DepositAuth_test.cpp b/src/test/app/DepositAuth_test.cpp index f10633c5e..641d2e61e 100644 --- a/src/test/app/DepositAuth_test.cpp +++ b/src/test/app/DepositAuth_test.cpp @@ -41,7 +41,7 @@ hasDepositAuth(jtx::Env const& env, jtx::Account const& acct) struct DepositAuth_test : public beast::unit_test::suite { void - testEnable() + testEnable(FeatureBitset features) { testcase("Enable"); @@ -50,7 +50,7 @@ struct DepositAuth_test : public beast::unit_test::suite { // featureDepositAuth is disabled. - Env env(*this, supported_amendments() - featureDepositAuth); + Env env(*this, features - featureDepositAuth); env.fund(XRP(10000), alice); // Note that, to support old behavior, invalid flags are ignored. @@ -78,7 +78,7 @@ struct DepositAuth_test : public beast::unit_test::suite } void - testPayIOU() + testPayIOU(FeatureBitset features) { // Exercise IOU payments and non-direct XRP payments to an account // that has the lsfDepositAuth flag set. @@ -91,7 +91,7 @@ struct DepositAuth_test : public beast::unit_test::suite Account const gw{"gw"}; IOU const USD = gw["USD"]; - Env env(*this); + Env env(*this, features); env.fund(XRP(10000), alice, bob, carol, gw); env.trust(USD(1000), alice, bob); @@ -173,7 +173,7 @@ struct DepositAuth_test : public beast::unit_test::suite } void - testPayXRP() + testPayXRP(FeatureBitset features) { // Exercise direct XRP payments to an account that has the // lsfDepositAuth flag set. @@ -183,7 +183,7 @@ struct DepositAuth_test : public beast::unit_test::suite Account const alice{"alice"}; Account const bob{"bob"}; - Env env(*this); + Env env(*this, features); env.fund(XRP(10000), alice, bob); @@ -274,7 +274,7 @@ struct DepositAuth_test : public beast::unit_test::suite } void - testNoRipple() + testNoRipple(FeatureBitset features) { // It its current incarnation the DepositAuth flag does not change // any behaviors regarding rippling and the NoRipple flag. @@ -374,17 +374,18 @@ struct DepositAuth_test : public beast::unit_test::suite void run() override { - testEnable(); - testPayIOU(); - testPayXRP(); - testNoRipple(); + auto const all{jtx::supported_amendments() - featureXahauGenesis}; + testEnable(all); + testPayIOU(all); + testPayXRP(all); + testNoRipple(all); } }; struct DepositPreauth_test : public beast::unit_test::suite { void - testEnable() + testEnable(FeatureBitset features) { testcase("Enable"); @@ -393,7 +394,7 @@ struct DepositPreauth_test : public beast::unit_test::suite Account const becky{"becky"}; { // featureDepositPreauth is disabled. - Env env(*this, supported_amendments() - featureDepositPreauth); + Env env(*this, features - featureDepositPreauth); env.fund(XRP(10000), alice, becky); env.close(); @@ -466,7 +467,7 @@ struct DepositPreauth_test : public beast::unit_test::suite } void - testInvalid() + testInvalid(FeatureBitset features) { testcase("Invalid"); @@ -475,7 +476,7 @@ struct DepositPreauth_test : public beast::unit_test::suite Account const becky{"becky"}; Account const carol{"carol"}; - Env env(*this); + Env env(*this, features); // Tell env about alice, becky and carol since they are not yet funded. env.memoize(alice); @@ -727,11 +728,11 @@ struct DepositPreauth_test : public beast::unit_test::suite void run() override { - testEnable(); - testInvalid(); - auto const supported{jtx::supported_amendments()}; - testPayment(supported - featureDepositPreauth); - testPayment(supported); + auto const all{jtx::supported_amendments() - featureXahauGenesis}; + testEnable(all); + testInvalid(all); + testPayment(all - featureDepositPreauth); + testPayment(all); } }; diff --git a/src/test/app/Freeze_test.cpp b/src/test/app/Freeze_test.cpp index 960975a3b..7d4bd57eb 100644 --- a/src/test/app/Freeze_test.cpp +++ b/src/test/app/Freeze_test.cpp @@ -543,7 +543,7 @@ public: testOffersWhenFrozen(features); }; using namespace test::jtx; - auto const sa = supported_amendments(); + auto const sa = supported_amendments() - featureXahauGenesis; testAll(sa - featureFlowCross); testAll(sa); } diff --git a/src/test/app/LedgerMaster_test.cpp b/src/test/app/LedgerMaster_test.cpp index 87639c42f..6729772b4 100644 --- a/src/test/app/LedgerMaster_test.cpp +++ b/src/test/app/LedgerMaster_test.cpp @@ -100,20 +100,22 @@ class LedgerMaster_test : public beast::unit_test::suite uint32_t txnIndex = metas[0]->getFieldU32(sfTransactionIndex); auto result = env.app().getLedgerMaster().txnIdFromIndex( startLegSeq, txnIndex); + std::cout << "RESULT: " << *result << "\n"; BEAST_EXPECT( *result == - uint256("277F4FD89C20B92457FEF05FF63F6405563AD0563C73D967A29727" - "72679ADC65")); + uint256("0CC11AD1AD89661689F6B6148D82CB6A7101DA4D66EC843670262D" + "0B618F5745")); } // success (second tx) { uint32_t txnIndex = metas[1]->getFieldU32(sfTransactionIndex); auto result = env.app().getLedgerMaster().txnIdFromIndex( startLegSeq + 1, txnIndex); + std::cout << "RESULT: " << *result << "\n"; BEAST_EXPECT( *result == - uint256("293DF7335EBBAF4420D52E70ABF470EB4C5792CAEA2F91F76193C2" - "819F538FDE")); + uint256("DCAECE52F028B9D0F7CA43CBE15AB4EF7B84A8EF5D455238992E1E" + "DF2BDA1637")); } } @@ -122,7 +124,7 @@ public: run() override { using namespace test::jtx; - FeatureBitset const all{supported_amendments()}; + FeatureBitset const all{supported_amendments() - featureXahauGenesis}; testWithFeats(all); } diff --git a/src/test/app/NFTokenBurn_test.cpp b/src/test/app/NFTokenBurn_test.cpp index 75c32385a..44dde0c33 100644 --- a/src/test/app/NFTokenBurn_test.cpp +++ b/src/test/app/NFTokenBurn_test.cpp @@ -791,7 +791,7 @@ public: run() override { using namespace test::jtx; - FeatureBitset const all{supported_amendments()}; + FeatureBitset const all{supported_amendments() - featureXahauGenesis}; FeatureBitset const fixNFTDir{fixNFTokenDirV1}; testWithFeats( diff --git a/src/test/app/Offer_test.cpp b/src/test/app/Offer_test.cpp index d743d7c50..2632b7425 100644 --- a/src/test/app/Offer_test.cpp +++ b/src/test/app/Offer_test.cpp @@ -5185,7 +5185,7 @@ public: run() override { using namespace jtx; - FeatureBitset const all{supported_amendments()}; + FeatureBitset const all{supported_amendments() - featureXahauGenesis}; FeatureBitset const flowCross{featureFlowCross}; FeatureBitset const takerDryOffer{fixTakerDryOfferRemoval}; FeatureBitset const rmSmallIncreasedQOffers{fixRmSmallIncreasedQOffers}; diff --git a/src/test/app/Regression_test.cpp b/src/test/app/Regression_test.cpp index 6431f81db..80cef224c 100644 --- a/src/test/app/Regression_test.cpp +++ b/src/test/app/Regression_test.cpp @@ -30,10 +30,10 @@ struct Regression_test : public beast::unit_test::suite { // OfferCreate, then OfferCreate with cancel void - testOffer1() + testOffer1(FeatureBitset features) { using namespace jtx; - Env env(*this); + Env env(*this, features); auto const gw = Account("gw"); auto const USD = gw["USD"]; env.fund(XRP(10000), "alice", gw); @@ -46,11 +46,11 @@ struct Regression_test : public beast::unit_test::suite } void - testLowBalanceDestroy() + testLowBalanceDestroy(FeatureBitset features) { testcase("Account balance < fee destroys correct amount of XRP"); using namespace jtx; - Env env(*this); + Env env(*this, features); env.memoize("alice"); // The low balance scenario can not deterministically @@ -117,11 +117,11 @@ struct Regression_test : public beast::unit_test::suite } void - testSecp256r1key() + testSecp256r1key(FeatureBitset features) { testcase("Signing with a secp256r1 key should fail gracefully"); using namespace jtx; - Env env(*this); + Env env(*this, features); // Test case we'll use. auto test256r1key = [&env](Account const& acct) { @@ -162,7 +162,7 @@ struct Regression_test : public beast::unit_test::suite } void - testFeeEscalationAutofill() + testFeeEscalationAutofill(FeatureBitset features) { testcase("Autofilled fee should use the escalated fee"); using namespace jtx; @@ -170,7 +170,7 @@ struct Regression_test : public beast::unit_test::suite cfg->section("transaction_queue") .set("minimum_txn_in_ledger_standalone", "3"); return cfg; - })); + }), features); Env_ss envs(env); auto const alice = Account("alice"); @@ -199,7 +199,7 @@ struct Regression_test : public beast::unit_test::suite } void - testFeeEscalationExtremeConfig() + testFeeEscalationExtremeConfig(FeatureBitset features) { testcase("Fee escalation shouldn't allocate extreme memory"); using clock_type = std::chrono::steady_clock; @@ -214,7 +214,7 @@ struct Regression_test : public beast::unit_test::suite s.set("normal_consensus_increase_percent", "4294967295"); return cfg; - })); + }), features); env(noop(env.master)); // This test will probably fail if any breakpoints are encountered, @@ -248,11 +248,13 @@ struct Regression_test : public beast::unit_test::suite void run() override { - testOffer1(); - testLowBalanceDestroy(); - testSecp256r1key(); - testFeeEscalationAutofill(); - testFeeEscalationExtremeConfig(); + using namespace test::jtx; + auto const all{jtx::supported_amendments() - featureXahauGenesis}; + testOffer1(all); + testLowBalanceDestroy(all); + testSecp256r1key(all); + testFeeEscalationAutofill(all); + testFeeEscalationExtremeConfig(all); testJsonInvalid(); } }; diff --git a/src/test/app/Ticket_test.cpp b/src/test/app/Ticket_test.cpp index b50059711..4e456a0b6 100644 --- a/src/test/app/Ticket_test.cpp +++ b/src/test/app/Ticket_test.cpp @@ -378,12 +378,12 @@ class Ticket_test : public beast::unit_test::suite } void - testTicketNotEnabled() + testTicketNotEnabled(FeatureBitset features) { testcase("Feature Not Enabled"); using namespace test::jtx; - Env env{*this, supported_amendments() - featureTicketBatch}; + Env env{*this, features - featureTicketBatch}; env(ticket::create(env.master, 1), ter(temDISABLED)); env.close(); @@ -424,12 +424,12 @@ class Ticket_test : public beast::unit_test::suite } void - testTicketCreatePreflightFail() + testTicketCreatePreflightFail(FeatureBitset features) { testcase("Create Tickets that fail Preflight"); using namespace test::jtx; - Env env{*this}; + Env env{*this, features}; Account const master{env.master}; @@ -471,14 +471,14 @@ class Ticket_test : public beast::unit_test::suite } void - testTicketCreatePreclaimFail() + testTicketCreatePreclaimFail(FeatureBitset features) { testcase("Create Tickets that fail Preclaim"); using namespace test::jtx; { // Create tickets on a non-existent account. - Env env{*this}; + Env env{*this, features}; Account alice{"alice"}; env.memoize(alice); @@ -563,12 +563,12 @@ class Ticket_test : public beast::unit_test::suite } void - testTicketInsufficientReserve() + testTicketInsufficientReserve(FeatureBitset features) { testcase("Create Ticket Insufficient Reserve"); using namespace test::jtx; - Env env{*this}; + Env env{*this, features}; Account alice{"alice"}; // Fund alice not quite enough to make the reserve for a Ticket. @@ -623,12 +623,12 @@ class Ticket_test : public beast::unit_test::suite } void - testUsingTickets() + testUsingTickets(FeatureBitset features) { testcase("Using Tickets"); using namespace test::jtx; - Env env{*this}; + Env env{*this, features}; Account alice{"alice"}; env.fund(XRP(10000), alice); @@ -709,7 +709,7 @@ class Ticket_test : public beast::unit_test::suite } void - testTransactionDatabaseWithTickets() + testTransactionDatabaseWithTickets(FeatureBitset features) { // The Transaction database keeps each transaction's sequence number // in an entry (called "FromSeq"). Until the introduction of tickets @@ -724,7 +724,7 @@ class Ticket_test : public beast::unit_test::suite testcase("Transaction Database With Tickets"); using namespace test::jtx; - Env env{*this}; + Env env{*this, features}; Account alice{"alice"}; env.fund(XRP(10000), alice); @@ -831,7 +831,7 @@ class Ticket_test : public beast::unit_test::suite } void - testSignWithTicketSequence() + testSignWithTicketSequence(FeatureBitset features) { // The sign and the submit RPC commands automatically fill in the // Sequence field of a transaction if none is provided. If a @@ -840,7 +840,7 @@ class Ticket_test : public beast::unit_test::suite testcase("Sign with TicketSequence"); using namespace test::jtx; - Env env{*this}; + Env env{*this, features}; Account alice{"alice"}; env.fund(XRP(10000), alice); @@ -922,7 +922,7 @@ class Ticket_test : public beast::unit_test::suite } void - testFixBothSeqAndTicket() + testFixBothSeqAndTicket(FeatureBitset features) { // It is an error if a transaction contains a non-zero Sequence field // and a TicketSequence field. Verify that the error is detected. @@ -931,7 +931,7 @@ class Ticket_test : public beast::unit_test::suite // Try the test without featureTicketBatch enabled. using namespace test::jtx; { - Env env{*this, supported_amendments() - featureTicketBatch}; + Env env{*this, features - featureTicketBatch}; Account alice{"alice"}; env.fund(XRP(10000), alice); @@ -987,14 +987,16 @@ public: void run() override { - testTicketNotEnabled(); - testTicketCreatePreflightFail(); - testTicketCreatePreclaimFail(); - testTicketInsufficientReserve(); - testUsingTickets(); - testTransactionDatabaseWithTickets(); - testSignWithTicketSequence(); - testFixBothSeqAndTicket(); + using namespace test::jtx; + FeatureBitset const all{supported_amendments() - featureXahauGenesis}; + testTicketNotEnabled(all); + testTicketCreatePreflightFail(all); + testTicketCreatePreclaimFail(all); + testTicketInsufficientReserve(all); + testUsingTickets(all); + testTransactionDatabaseWithTickets(all); + testSignWithTicketSequence(all); + testFixBothSeqAndTicket(all); } }; diff --git a/src/test/app/TxQ_test.cpp b/src/test/app/TxQ_test.cpp index ddb7cf298..b5a39c70f 100644 --- a/src/test/app/TxQ_test.cpp +++ b/src/test/app/TxQ_test.cpp @@ -232,13 +232,13 @@ class TxQ1_test : public beast::unit_test::suite public: void - testQueueSeq() + testQueueSeq(FeatureBitset features) { using namespace jtx; using namespace std::chrono; testcase("queue sequence"); - Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "3"}})); + Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "3"}}), features); auto alice = Account("alice"); auto bob = Account("bob"); @@ -444,12 +444,12 @@ public: } void - testQueueTicket() + testQueueTicket(FeatureBitset features) { using namespace jtx; testcase("queue ticket"); - Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "3"}})); + Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "3"}}), features); auto alice = Account("alice"); @@ -701,12 +701,12 @@ public: } void - testTecResult() + testTecResult(FeatureBitset features) { using namespace jtx; testcase("queue tec"); - Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "2"}})); + Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "2"}}), features); auto alice = Account("alice"); auto gw = Account("gw"); @@ -737,7 +737,7 @@ public: } void - testLocalTxRetry() + testLocalTxRetry(FeatureBitset features) { using namespace jtx; using namespace std::chrono; @@ -794,13 +794,13 @@ public: } void - testLastLedgerSeq() + testLastLedgerSeq(FeatureBitset features) { using namespace jtx; using namespace std::chrono; testcase("last ledger sequence"); - Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "2"}})); + Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "2"}}), features); auto alice = Account("alice"); auto bob = Account("bob"); @@ -904,13 +904,13 @@ public: } void - testZeroFeeTxn() + testZeroFeeTxn(FeatureBitset features) { using namespace jtx; using namespace std::chrono; testcase("zero transaction fee"); - Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "2"}})); + Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "2"}}), features); auto alice = Account("alice"); auto bob = Account("bob"); @@ -1001,11 +1001,11 @@ public: } void - testFailInPreclaim() + testFailInPreclaim(FeatureBitset features) { using namespace jtx; - Env env(*this, makeConfig()); + Env env(*this, makeConfig(), features); testcase("fail in preclaim"); auto alice = Account("alice"); @@ -1025,12 +1025,12 @@ public: } void - testQueuedTxFails() + testQueuedTxFails(FeatureBitset features) { using namespace jtx; testcase("queued tx fails"); - Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "2"}})); + Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "2"}}), features); auto alice = Account("alice"); auto bob = Account("bob"); @@ -1076,7 +1076,7 @@ public: } void - testMultiTxnPerAccount() + testMultiTxnPerAccount(FeatureBitset features) { using namespace jtx; testcase("multi tx per account"); @@ -1085,7 +1085,7 @@ public: *this, makeConfig( {{"minimum_txn_in_ledger_standalone", "3"}}, - {{"account_reserve", "200"}, {"owner_reserve", "50"}})); + {{"account_reserve", "200"}, {"owner_reserve", "50"}}), features); auto alice = Account("alice"); auto bob = Account("bob"); @@ -1346,13 +1346,13 @@ public: } void - testTieBreaking() + testTieBreaking(FeatureBitset features) { using namespace jtx; using namespace std::chrono; testcase("tie breaking"); - Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "4"}})); + Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "4"}}), features); auto alice = Account("alice"); auto bob = Account("bob"); @@ -1640,12 +1640,12 @@ public: } void - testAcctTxnID() + testAcctTxnID(FeatureBitset features) { using namespace jtx; testcase("acct tx id"); - Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "1"}})); + Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "1"}}), features); auto alice = Account("alice"); @@ -1679,7 +1679,7 @@ public: } void - testMaximum() + testMaximum(FeatureBitset features) { using namespace jtx; using namespace std::string_literals; @@ -1692,7 +1692,7 @@ public: {{"minimum_txn_in_ledger_standalone", "2"}, {"minimum_txn_in_ledger", "5"}, {"target_txn_in_ledger", "4"}, - {"maximum_txn_in_ledger", "5"}})); + {"maximum_txn_in_ledger", "5"}}), features); auto alice = Account("alice"); @@ -1719,7 +1719,7 @@ public: {{"minimum_txn_in_ledger", "200"}, {"minimum_txn_in_ledger_standalone", "200"}, {"target_txn_in_ledger", "4"}, - {"maximum_txn_in_ledger", "5"}})); + {"maximum_txn_in_ledger", "5"}}), features); // should throw fail(); } @@ -1740,7 +1740,7 @@ public: {{"minimum_txn_in_ledger", "200"}, {"minimum_txn_in_ledger_standalone", "2"}, {"target_txn_in_ledger", "4"}, - {"maximum_txn_in_ledger", "5"}})); + {"maximum_txn_in_ledger", "5"}}), features); // should throw fail(); } @@ -1761,7 +1761,7 @@ public: {{"minimum_txn_in_ledger", "2"}, {"minimum_txn_in_ledger_standalone", "200"}, {"target_txn_in_ledger", "4"}, - {"maximum_txn_in_ledger", "5"}})); + {"maximum_txn_in_ledger", "5"}}), features); // should throw fail(); } @@ -1777,7 +1777,7 @@ public: } void - testUnexpectedBalanceChange() + testUnexpectedBalanceChange(FeatureBitset features) { using namespace jtx; testcase("unexpected balance change"); @@ -1786,7 +1786,7 @@ public: *this, makeConfig( {{"minimum_txn_in_ledger_standalone", "3"}}, - {{"account_reserve", "200"}, {"owner_reserve", "50"}})); + {{"account_reserve", "200"}, {"owner_reserve", "50"}}), features); auto alice = Account("alice"); auto bob = Account("bob"); @@ -1874,7 +1874,7 @@ public: } void - testBlockersSeq() + testBlockersSeq(FeatureBitset features) { using namespace jtx; testcase("blockers sequence"); @@ -1886,7 +1886,7 @@ public: auto queued = ter(terQUEUED); - Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "3"}})); + Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "3"}}), features); BEAST_EXPECT(env.current()->fees().base == 10); @@ -2004,7 +2004,7 @@ public: } void - testBlockersTicket() + testBlockersTicket(FeatureBitset features) { using namespace jtx; testcase("blockers ticket"); @@ -2016,7 +2016,7 @@ public: auto queued = ter(terQUEUED); - Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "3"}})); + Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "3"}}), features); BEAST_EXPECT(env.current()->fees().base == 10); @@ -2166,7 +2166,7 @@ public: } void - testInFlightBalance() + testInFlightBalance(FeatureBitset features) { using namespace jtx; testcase("In-flight balance checks"); @@ -2175,7 +2175,7 @@ public: *this, makeConfig( {{"minimum_txn_in_ledger_standalone", "3"}}, - {{"account_reserve", "200"}, {"owner_reserve", "50"}})); + {{"account_reserve", "200"}, {"owner_reserve", "50"}}), features); auto alice = Account("alice"); auto charlie = Account("charlie"); @@ -2520,13 +2520,13 @@ public: } void - testConsequences() + testConsequences(FeatureBitset features) { using namespace jtx; using namespace std::chrono; testcase("consequences"); - Env env(*this); + Env env(*this, features); auto const alice = Account("alice"); env.memoize(alice); env.memoize("bob"); @@ -2578,7 +2578,7 @@ public: } void - testAcctInQueueButEmpty() + testAcctInQueueButEmpty(FeatureBitset features) { // It is possible for an account to be present in the queue but have // no queued transactions. This has been the source of at least one @@ -2597,7 +2597,7 @@ public: auto queued = ter(terQUEUED); - Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "3"}})); + Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "3"}}), features); BEAST_EXPECT(env.current()->fees().base == 10); @@ -2683,12 +2683,12 @@ public: } void - testRPC() + testRPC(FeatureBitset features) { using namespace jtx; testcase("rpc"); - Env env(*this); + Env env(*this, features); auto fee = env.rpc("fee"); @@ -2747,7 +2747,7 @@ public: } void - testExpirationReplacement() + testExpirationReplacement(FeatureBitset features) { /* This test is based on a reported regression where a replacement candidate transaction found the tx it was trying @@ -2768,7 +2768,7 @@ public: makeConfig( {{"minimum_txn_in_ledger_standalone", "1"}, {"ledgers_in_queue", "10"}, - {"maximum_txn_per_account", "20"}})); + {"maximum_txn_per_account", "20"}}), features); // Alice will recreate the scenario. Bob will block. auto const alice = Account("alice"); @@ -2848,7 +2848,7 @@ public: } void - testFullQueueGapFill() + testFullQueueGapFill(FeatureBitset features) { // This test focuses on which gaps in queued transactions are // allowed to be filled even when the account's queue is full. @@ -2860,7 +2860,7 @@ public: makeConfig( {{"minimum_txn_in_ledger_standalone", "1"}, {"ledgers_in_queue", "10"}, - {"maximum_txn_per_account", "11"}})); + {"maximum_txn_per_account", "11"}}), features); // Alice will have the gaps. Bob will keep the queue busy with // high fee transactions so alice's transactions can expire to leave @@ -3015,11 +3015,11 @@ public: } void - testSignAndSubmitSequence() + testSignAndSubmitSequence(FeatureBitset features) { testcase("Autofilled sequence should account for TxQ"); using namespace jtx; - Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "6"}})); + Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "6"}}), features); Env_ss envs(env); auto const& txQ = env.app().getTxQ(); @@ -3145,12 +3145,12 @@ public: } void - testAccountInfo() + testAccountInfo(FeatureBitset features) { using namespace jtx; testcase("account info"); - Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "3"}})); + Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "3"}}), features); Env_ss envs(env); Account const alice{"alice"}; @@ -3424,12 +3424,12 @@ public: } void - testServerInfo() + testServerInfo(FeatureBitset features) { using namespace jtx; testcase("server info"); - Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "3"}})); + Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "3"}}), features); Env_ss envs(env); Account const alice{"alice"}; @@ -3685,12 +3685,12 @@ public: } void - testServerSubscribe() + testServerSubscribe(FeatureBitset features) { using namespace jtx; testcase("server subscribe"); - Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "3"}})); + Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "3"}}), features); Json::Value stream; stream[jss::streams] = Json::arrayValue; @@ -3830,12 +3830,12 @@ public: } void - testClearQueuedAccountTxs() + testClearQueuedAccountTxs(FeatureBitset features) { using namespace jtx; testcase("clear queued acct txs"); - Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "3"}})); + Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "3"}}), features); auto alice = Account("alice"); auto bob = Account("bob"); @@ -4036,7 +4036,7 @@ public: } void - testScaling() + testScaling(FeatureBitset features) { using namespace jtx; using namespace std::chrono_literals; @@ -4050,7 +4050,7 @@ public: {"normal_consensus_increase_percent", "25"}, {"slow_consensus_decrease_percent", "50"}, {"target_txn_in_ledger", "10"}, - {"maximum_txn_per_account", "200"}})); + {"maximum_txn_per_account", "200"}}), features); auto alice = Account("alice"); checkMetrics(__LINE__, env, 0, std::nullopt, 0, 3, 256); @@ -4136,7 +4136,7 @@ public: {"normal_consensus_increase_percent", "150"}, {"slow_consensus_decrease_percent", "150"}, {"target_txn_in_ledger", "10"}, - {"maximum_txn_per_account", "200"}})); + {"maximum_txn_per_account", "200"}}), features); auto alice = Account("alice"); checkMetrics(__LINE__, env, 0, std::nullopt, 0, 3, 256); @@ -4176,7 +4176,7 @@ public: } void - testInLedgerSeq() + testInLedgerSeq(FeatureBitset features) { // Test the situation where a transaction with an account and // sequence that's in the queue also appears in the ledger. @@ -4189,7 +4189,7 @@ public: testcase("Sequence in queue and open ledger"); using namespace jtx; - Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "3"}})); + Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "3"}}), features); auto const alice = Account("alice"); @@ -4245,7 +4245,7 @@ public: } void - testInLedgerTicket() + testInLedgerTicket(FeatureBitset features) { // Test the situation where a transaction with an account and // ticket that's in the queue also appears in the ledger. @@ -4256,7 +4256,7 @@ public: testcase("Ticket in queue and open ledger"); using namespace jtx; - Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "3"}})); + Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "3"}}), features); auto alice = Account("alice"); @@ -4340,7 +4340,7 @@ public: } void - testReexecutePreflight() + testReexecutePreflight(FeatureBitset features) { // The TxQ caches preflight results. But there are situations where // that cache must become invalidated, like if amendments change. @@ -4365,7 +4365,7 @@ public: {"maximum_txn_per_account", "10"}}, {{"account_reserve", "1000"}, {"owner_reserve", "50"}}); - Env env(*this, std::move(cfg)); + Env env(*this, std::move(cfg), features); env.fund(XRP(10000), alice); env.close(); @@ -4496,7 +4496,7 @@ public: } void - testQueueFullDropPenalty() + testQueueFullDropPenalty(FeatureBitset features) { // If... // o The queue is close to full, @@ -4531,7 +4531,7 @@ public: {"maximum_txn_per_account", "30"}, {"minimum_queue_size", "50"}}); - Env env(*this, std::move(cfg)); + Env env(*this, std::move(cfg), features); // The noripple is to reduce the number of transactions required to // fund the accounts. There is no rippling in this test. @@ -4733,7 +4733,7 @@ public: } void - testCancelQueuedOffers() + testCancelQueuedOffers(FeatureBitset features) { testcase("Cancel queued offers"); using namespace jtx; @@ -4748,7 +4748,7 @@ public: {"maximum_txn_per_account", "30"}, {"minimum_queue_size", "50"}}); - Env env(*this, std::move(cfg)); + Env env(*this, std::move(cfg), features); // The noripple is to reduce the number of transactions required to // fund the accounts. There is no rippling in this test. @@ -4846,7 +4846,7 @@ public: } void - testZeroReferenceFee() + testZeroReferenceFee(FeatureBitset features) { testcase("Zero reference fee"); using namespace jtx; @@ -4860,7 +4860,7 @@ public: {{"minimum_txn_in_ledger_standalone", "3"}}, {{"reference_fee", "0"}, {"account_reserve", "0"}, - {"owner_reserve", "0"}})); + {"owner_reserve", "0"}}), features); BEAST_EXPECT(env.current()->fees().base == 10); @@ -4986,44 +4986,48 @@ public: void run() override { - testQueueSeq(); - testQueueTicket(); - testTecResult(); - testLocalTxRetry(); - testLastLedgerSeq(); - testZeroFeeTxn(); - testFailInPreclaim(); - testQueuedTxFails(); - testMultiTxnPerAccount(); - testTieBreaking(); - testAcctTxnID(); - testMaximum(); - testUnexpectedBalanceChange(); - testBlockersSeq(); - testBlockersTicket(); - testInFlightBalance(); - testConsequences(); + using namespace test::jtx; + FeatureBitset const all{supported_amendments() - featureXahauGenesis}; + testQueueSeq(all); + testQueueTicket(all); + testTecResult(all); + testLocalTxRetry(all); + testLastLedgerSeq(all); + testZeroFeeTxn(all); + testFailInPreclaim(all); + testQueuedTxFails(all); + testMultiTxnPerAccount(all); + testTieBreaking(all); + testAcctTxnID(all); + testMaximum(all); + testUnexpectedBalanceChange(all); + testBlockersSeq(all); + testBlockersTicket(all); + testInFlightBalance(all); + testConsequences(all); } void run2() { - testAcctInQueueButEmpty(); - testRPC(); - testExpirationReplacement(); - testFullQueueGapFill(); - testSignAndSubmitSequence(); - testAccountInfo(); - testServerInfo(); - testServerSubscribe(); - testClearQueuedAccountTxs(); - testScaling(); - testInLedgerSeq(); - testInLedgerTicket(); - testReexecutePreflight(); - testQueueFullDropPenalty(); - testCancelQueuedOffers(); - testZeroReferenceFee(); + using namespace test::jtx; + FeatureBitset const all{supported_amendments() - featureXahauGenesis}; + testAcctInQueueButEmpty(all); + testRPC(all); + testExpirationReplacement(all); + testFullQueueGapFill(all); + testSignAndSubmitSequence(all); + testAccountInfo(all); + testServerInfo(all); + testServerSubscribe(all); + testClearQueuedAccountTxs(all); + testScaling(all); + testInLedgerSeq(all); + testInLedgerTicket(all); + testReexecutePreflight(all); + testQueueFullDropPenalty(all); + testCancelQueuedOffers(all); + testZeroReferenceFee(all); } }; diff --git a/src/test/jtx/Env_test.cpp b/src/test/jtx/Env_test.cpp index c983abfe0..dba4d8bef 100644 --- a/src/test/jtx/Env_test.cpp +++ b/src/test/jtx/Env_test.cpp @@ -145,7 +145,7 @@ public: // Test Env void - testEnv() + testEnv(FeatureBitset features) { using namespace jtx; auto const n = XRP(10000); @@ -155,7 +155,7 @@ public: // unfunded { - Env env(*this); + Env env(*this, features); env.memoize(alice); env(pay("alice", "bob", XRP(1000)), seq(1), @@ -166,7 +166,7 @@ public: // fund { - Env env(*this); + Env env(*this, features); // variadics env.fund(n, "alice"); @@ -186,14 +186,14 @@ public: // trust { - Env env(*this); + Env env(*this, features); env.fund(n, "alice", "bob", gw); env(trust("alice", USD(100)), require(lines("alice", 1))); } // balance { - Env env(*this); + Env env(*this, features); BEAST_EXPECT(env.balance(alice) == 0); BEAST_EXPECT(env.balance(alice, USD) != 0); BEAST_EXPECT(env.balance(alice, USD) == USD(0)); @@ -209,7 +209,7 @@ public: // seq { - Env env(*this); + Env env(*this, features); env.fund(n, noripple("alice", gw)); BEAST_EXPECT(env.seq("alice") == 3); BEAST_EXPECT(env.seq(gw) == 3); @@ -217,7 +217,7 @@ public: // autofill { - Env env(*this); + Env env(*this, features); env.fund(n, "alice"); env.require(balance("alice", n)); env(noop("alice"), fee(1), ter(telINSUF_FEE_P)); @@ -233,10 +233,10 @@ public: // Env::require void - testRequire() + testRequire(FeatureBitset features) { using namespace jtx; - Env env(*this); + Env env(*this, features); auto const gw = Account("gw"); auto const USD = gw["USD"]; env.require(balance("alice", none)); @@ -257,11 +257,11 @@ public: // Signing with secp256k1 and ed25519 keys void - testKeyType() + testKeyType(FeatureBitset features) { using namespace jtx; - Env env{*this, supported_amendments() | fixMasterKeyAsRegularKey}; + Env env{*this, features | fixMasterKeyAsRegularKey}; Account const alice("alice", KeyType::ed25519); Account const bob("bob", KeyType::secp256k1); Account const carol("carol"); @@ -297,10 +297,10 @@ public: // Payment basics void - testPayments() + testPayments(FeatureBitset features) { using namespace jtx; - Env env(*this); + Env env(*this, features); auto const gw = Account("gateway"); auto const USD = gw["USD"]; @@ -370,10 +370,10 @@ public: // transactions are neither queued nor // held. void - testFailHard() + testFailHard(FeatureBitset features) { using namespace jtx; - Env env(*this); + Env env(*this, features); auto const gw = Account("gateway"); auto const USD = gw["USD"]; @@ -454,11 +454,11 @@ public: // Multi-sign basics void - testMultiSign() + testMultiSign(FeatureBitset features) { using namespace jtx; - Env env(*this); + Env env(*this, features); env.fund(XRP(10000), "alice"); env(signers("alice", 1, {{"alice", 1}, {"bob", 2}}), ter(temBAD_SIGNER)); @@ -478,14 +478,14 @@ public: } void - testTicket() + testTicket(FeatureBitset features) { using namespace jtx; // create syntax ticket::create("alice", 1); { - Env env(*this); + Env env(*this, features); env.fund(XRP(10000), "alice"); env(noop("alice"), require(owners("alice", 0), tickets("alice", 0))); @@ -536,10 +536,10 @@ public: } void - testProp() + testProp(FeatureBitset features) { using namespace jtx; - Env env(*this); + Env env(*this, features); env.fund(XRP(100000), "alice"); auto jt1 = env.jt(noop("alice")); BEAST_EXPECT(!jt1.get()); @@ -606,10 +606,10 @@ public: } void - testMemo() + testMemo(FeatureBitset features) { using namespace jtx; - Env env(*this); + Env env(*this, features); env.fund(XRP(10000), "alice"); env(noop("alice"), memodata("data"), fee(1000)); env(noop("alice"), memoformat("format"), fee(1000)); @@ -624,10 +624,10 @@ public: } void - testMemoResult() + testMemoResult(FeatureBitset features) { using namespace jtx; - Env env(*this); + Env env(*this, features); JTx jt(noop("alice")); memo("data", "format", "type")(env, jt); @@ -641,10 +641,10 @@ public: } void - testAdvance() + testAdvance(FeatureBitset features) { using namespace jtx; - Env env(*this); + Env env(*this, features); auto seq = env.current()->seq(); BEAST_EXPECT(seq == env.closed()->seq() + 1); env.close(); @@ -656,10 +656,10 @@ public: } void - testClose() + testClose(FeatureBitset features) { using namespace jtx; - Env env(*this); + Env env(*this, features); env.close(); env.close(); env.fund(XRP(100000), "alice", "bob"); @@ -672,10 +672,10 @@ public: } void - testPath() + testPath(FeatureBitset features) { using namespace jtx; - Env env(*this); + Env env(*this, features); auto const gw = Account("gw"); auto const USD = gw["USD"]; env.fund(XRP(10000), "alice", "bob"); @@ -691,10 +691,10 @@ public: // Test that jtx can re-sign a transaction that's already been signed. void - testResignSigned() + testResignSigned(FeatureBitset features) { using namespace jtx; - Env env(*this); + Env env(*this, features); env.fund(XRP(10000), "alice"); auto const baseFee = env.current()->fees().base; @@ -709,10 +709,10 @@ public: } void - testSignAndSubmit() + testSignAndSubmit(FeatureBitset features) { using namespace jtx; - Env env(*this); + Env env(*this, features); Env_ss envs(env); auto const alice = Account("alice"); @@ -757,11 +757,11 @@ public: } void - testFeatures() + testFeatures(FeatureBitset features) { testcase("Env features"); using namespace jtx; - auto const supported = supported_amendments(); + auto const supported = features; // this finds a feature that is not in // the supported amendments list and tests that it can be @@ -792,7 +792,7 @@ public: { // default Env has all supported features - Env env{*this}; + Env env{*this, features}; BEAST_EXPECT( supported.count() == env.app().config().features.size()); foreachFeature(supported, [&](uint256 const& f) { @@ -812,7 +812,7 @@ public: } auto const missingSomeFeatures = - supported_amendments() - featureMultiSignReserve - featureFlow; + features - featureMultiSignReserve - featureFlow; BEAST_EXPECT(missingSomeFeatures.count() == (supported.count() - 2)); { // a Env supported_features_except is missing *only* those features @@ -872,7 +872,7 @@ public: // add a feature that is NOT in the supported amendments list // along with all supported amendments // the unsupported features should be enabled - Env env{*this, supported_amendments().set(*neverSupportedFeat)}; + Env env{*this, features.set(*neverSupportedFeat)}; // this app will have all supported amendments and then the // one additional never supported feature flag @@ -904,27 +904,29 @@ public: void run() override { + using namespace test::jtx; + FeatureBitset const all{supported_amendments() - featureXahauGenesis}; testAccount(); testAmount(); - testEnv(); - testRequire(); - testKeyType(); - testPayments(); - testFailHard(); - testMultiSign(); - testTicket(); + testEnv(all); + testRequire(all); + testKeyType(all); + testPayments(all); + testFailHard(all); + testMultiSign(all); + testTicket(all); testJTxProperties(); - testProp(); + testProp(all); testJTxCopy(); testJTxMove(); - testMemo(); - testMemoResult(); - testAdvance(); - testClose(); - testPath(); - testResignSigned(); - testSignAndSubmit(); - testFeatures(); + testMemo(all); + testMemoResult(all); + testAdvance(all); + testClose(all); + testPath(all); + testResignSigned(all); + testSignAndSubmit(all); + testFeatures(all); testExceptionalShutdown(); } }; diff --git a/src/test/rpc/AccountObjects_test.cpp b/src/test/rpc/AccountObjects_test.cpp index b452be838..0ccdbe90c 100644 --- a/src/test/rpc/AccountObjects_test.cpp +++ b/src/test/rpc/AccountObjects_test.cpp @@ -114,12 +114,12 @@ class AccountObjects_test : public beast::unit_test::suite public: #define HSFEE fee(100'000'000) void - testErrors() + testErrors(FeatureBitset features) { testcase("error cases"); using namespace jtx; - Env env(*this); + Env env(*this, features); // test error on no account { @@ -247,12 +247,12 @@ public: } void - testUnsteppedThenStepped() + testUnsteppedThenStepped(FeatureBitset features) { testcase("unsteppedThenStepped"); using namespace jtx; - Env env(*this); + Env env(*this, features); Account const gw1{"G1"}; Account const gw2{"G2"}; @@ -337,7 +337,7 @@ public: } void - testUnsteppedThenSteppedWithNFTs() + testUnsteppedThenSteppedWithNFTs(FeatureBitset features) { // The preceding test case, unsteppedThenStepped(), found a bug in the // support for NFToken Pages. So we're leaving that test alone when @@ -345,7 +345,7 @@ public: testcase("unsteppedThenSteppedWithNFTs"); using namespace jtx; - Env env(*this); + Env env(*this, features); Account const gw1{"G1"}; Account const gw2{"G2"}; @@ -539,7 +539,7 @@ public: } void - testObjectTypes() + testObjectTypes(FeatureBitset features) { testcase("object types"); @@ -551,7 +551,7 @@ public: Account const gw{"gateway"}; auto const USD = gw["USD"]; - Env env(*this); + Env env(*this, features); // Make a lambda we can use to get "account_objects" easily. auto acct_objs = [&env](Account const& acct, char const* type) { @@ -847,10 +847,12 @@ public: void run() override { - testErrors(); - testUnsteppedThenStepped(); - testUnsteppedThenSteppedWithNFTs(); - testObjectTypes(); + using namespace jtx; + FeatureBitset const all{supported_amendments() - featureXahauGenesis}; + testErrors(all); + testUnsteppedThenStepped(all); + testUnsteppedThenSteppedWithNFTs(all); + testObjectTypes(all); } }; diff --git a/src/test/rpc/AccountOffers_test.cpp b/src/test/rpc/AccountOffers_test.cpp index f4ad0a725..58b908f73 100644 --- a/src/test/rpc/AccountOffers_test.cpp +++ b/src/test/rpc/AccountOffers_test.cpp @@ -42,10 +42,10 @@ public: } void - testNonAdminMinLimit() + testNonAdminMinLimit(FeatureBitset features) { using namespace jtx; - Env env{*this, envconfig(no_admin)}; + Env env{*this, envconfig(no_admin), features}; Account const gw("G1"); auto const USD_gw = gw["USD"]; Account const bob("bob"); @@ -86,10 +86,10 @@ public: } void - testSequential(bool asAdmin) + testSequential(FeatureBitset features, bool asAdmin) { using namespace jtx; - Env env{*this, asAdmin ? envconfig() : envconfig(no_admin)}; + Env env{*this, asAdmin ? envconfig() : envconfig(no_admin), features}; Account const gw("G1"); auto const USD_gw = gw["USD"]; Account const bob("bob"); @@ -220,10 +220,10 @@ public: } void - testBadInput() + testBadInput(FeatureBitset features) { using namespace jtx; - Env env(*this); + Env env(*this, features); Account const gw("G1"); auto const USD_gw = gw["USD"]; Account const bob("bob"); @@ -326,10 +326,12 @@ public: void run() override { - testSequential(true); - testSequential(false); - testBadInput(); - testNonAdminMinLimit(); + using namespace jtx; + FeatureBitset const all{supported_amendments() - featureXahauGenesis}; + testSequential(all, true); + testSequential(all, false); + testBadInput(all); + testNonAdminMinLimit(all); } }; diff --git a/src/test/rpc/Book_test.cpp b/src/test/rpc/Book_test.cpp index fcc0017f5..d930cd571 100644 --- a/src/test/rpc/Book_test.cpp +++ b/src/test/rpc/Book_test.cpp @@ -50,12 +50,12 @@ class Book_test : public beast::unit_test::suite public: void - testOneSideEmptyBook() + testOneSideEmptyBook(FeatureBitset features) { testcase("One Side Empty Book"); using namespace std::chrono_literals; using namespace jtx; - Env env(*this); + Env env(*this, features); env.fund(XRP(10000), "alice"); auto USD = Account("alice")["USD"]; auto wsc = makeWSClient(env.app().config()); @@ -128,12 +128,12 @@ public: } void - testOneSideOffersInBook() + testOneSideOffersInBook(FeatureBitset features) { testcase("One Side Offers In Book"); using namespace std::chrono_literals; using namespace jtx; - Env env(*this); + Env env(*this, features); env.fund(XRP(10000), "alice"); auto USD = Account("alice")["USD"]; auto wsc = makeWSClient(env.app().config()); @@ -219,12 +219,12 @@ public: } void - testBothSidesEmptyBook() + testBothSidesEmptyBook(FeatureBitset features) { testcase("Both Sides Empty Book"); using namespace std::chrono_literals; using namespace jtx; - Env env(*this); + Env env(*this, features); env.fund(XRP(10000), "alice"); auto USD = Account("alice")["USD"]; auto wsc = makeWSClient(env.app().config()); @@ -309,12 +309,12 @@ public: } void - testBothSidesOffersInBook() + testBothSidesOffersInBook(FeatureBitset features) { testcase("Both Sides Offers In Book"); using namespace std::chrono_literals; using namespace jtx; - Env env(*this); + Env env(*this, features); env.fund(XRP(10000), "alice"); auto USD = Account("alice")["USD"]; auto wsc = makeWSClient(env.app().config()); @@ -418,12 +418,12 @@ public: } void - testMultipleBooksOneSideEmptyBook() + testMultipleBooksOneSideEmptyBook(FeatureBitset features) { testcase("Multiple Books, One Side Empty"); using namespace std::chrono_literals; using namespace jtx; - Env env(*this); + Env env(*this, features); env.fund(XRP(10000), "alice"); auto USD = Account("alice")["USD"]; auto CNY = Account("alice")["CNY"]; @@ -530,12 +530,12 @@ public: } void - testMultipleBooksOneSideOffersInBook() + testMultipleBooksOneSideOffersInBook(FeatureBitset features) { testcase("Multiple Books, One Side Offers In Book"); using namespace std::chrono_literals; using namespace jtx; - Env env(*this); + Env env(*this, features); env.fund(XRP(10000), "alice"); auto USD = Account("alice")["USD"]; auto CNY = Account("alice")["CNY"]; @@ -667,12 +667,12 @@ public: } void - testMultipleBooksBothSidesEmptyBook() + testMultipleBooksBothSidesEmptyBook(FeatureBitset features) { testcase("Multiple Books, Both Sides Empty Book"); using namespace std::chrono_literals; using namespace jtx; - Env env(*this); + Env env(*this, features); env.fund(XRP(10000), "alice"); auto USD = Account("alice")["USD"]; auto CNY = Account("alice")["CNY"]; @@ -801,12 +801,12 @@ public: } void - testMultipleBooksBothSidesOffersInBook() + testMultipleBooksBothSidesOffersInBook(FeatureBitset features) { testcase("Multiple Books, Both Sides Offers In Book"); using namespace std::chrono_literals; using namespace jtx; - Env env(*this); + Env env(*this, features); env.fund(XRP(10000), "alice"); auto USD = Account("alice")["USD"]; auto CNY = Account("alice")["CNY"]; @@ -973,11 +973,11 @@ public: } void - testTrackOffers() + testTrackOffers(FeatureBitset features) { testcase("TrackOffers"); using namespace jtx; - Env env(*this); + Env env(*this, features); Account gw{"gw"}; Account alice{"alice"}; Account bob{"bob"}; @@ -1156,7 +1156,7 @@ public: } void - testCrossingSingleBookOffer() + testCrossingSingleBookOffer(FeatureBitset features) { testcase("Crossing single book offer"); @@ -1165,7 +1165,7 @@ public: // ledger entries using namespace jtx; - Env env(*this); + Env env(*this, features); // Scenario is: // - Alice and Bob place identical offers for USD -> XRP @@ -1224,7 +1224,7 @@ public: } void - testCrossingMultiBookOffer() + testCrossingMultiBookOffer(FeatureBitset features) { testcase("Crossing multi-book offer"); @@ -1233,7 +1233,7 @@ public: // books that are under subscription using namespace jtx; - Env env(*this); + Env env(*this, features); // Scenario is: // - Alice has 1 USD and wants 100 XRP @@ -1307,11 +1307,11 @@ public: } void - testBookOfferErrors() + testBookOfferErrors(FeatureBitset features) { testcase("BookOffersRPC Errors"); using namespace jtx; - Env env(*this); + Env env(*this, features); Account gw{"gw"}; Account alice{"alice"}; env.fund(XRP(10000), alice, gw); @@ -1658,11 +1658,11 @@ public: } void - testBookOfferLimits(bool asAdmin) + testBookOfferLimits(FeatureBitset features, bool asAdmin) { testcase("BookOffer Limits"); using namespace jtx; - Env env{*this, asAdmin ? envconfig() : envconfig(no_admin)}; + Env env{*this, asAdmin ? envconfig() : envconfig(no_admin), features}; Account gw{"gw"}; env.fund(XRP(200000), gw); // Note that calls to env.close() fail without admin permission. @@ -1712,20 +1712,22 @@ public: void run() override { - testOneSideEmptyBook(); - testOneSideOffersInBook(); - testBothSidesEmptyBook(); - testBothSidesOffersInBook(); - testMultipleBooksOneSideEmptyBook(); - testMultipleBooksOneSideOffersInBook(); - testMultipleBooksBothSidesEmptyBook(); - testMultipleBooksBothSidesOffersInBook(); - testTrackOffers(); - testCrossingSingleBookOffer(); - testCrossingMultiBookOffer(); - testBookOfferErrors(); - testBookOfferLimits(true); - testBookOfferLimits(false); + using namespace test::jtx; + FeatureBitset const all{supported_amendments() - featureXahauGenesis}; + testOneSideEmptyBook(all); + testOneSideOffersInBook(all); + testBothSidesEmptyBook(all); + testBothSidesOffersInBook(all); + testMultipleBooksOneSideEmptyBook(all); + testMultipleBooksOneSideOffersInBook(all); + testMultipleBooksBothSidesEmptyBook(all); + testMultipleBooksBothSidesOffersInBook(all); + testTrackOffers(all); + testCrossingSingleBookOffer(all); + testCrossingMultiBookOffer(all); + testBookOfferErrors(all); + testBookOfferLimits(all, true); + testBookOfferLimits(all, false); } }; diff --git a/src/test/rpc/DeliveredAmount_test.cpp b/src/test/rpc/DeliveredAmount_test.cpp index c17bd0c02..869409ad7 100644 --- a/src/test/rpc/DeliveredAmount_test.cpp +++ b/src/test/rpc/DeliveredAmount_test.cpp @@ -178,7 +178,7 @@ public: class DeliveredAmount_test : public beast::unit_test::suite { void - testAccountDeliveredAmountSubscribe() + testAccountDeliveredAmountSubscribe(FeatureBitset features) { testcase("Ledger Request Subscribe DeliveredAmount"); @@ -193,7 +193,7 @@ class DeliveredAmount_test : public beast::unit_test::suite for (bool const afterSwitchTime : {true, false}) { - Env env{*this}; + Env env{*this, features}; env.fund(XRP(10000), alice, bob, carol, gw); env.trust(USD(1000), alice, bob, carol); if (afterSwitchTime) @@ -267,7 +267,7 @@ class DeliveredAmount_test : public beast::unit_test::suite } } void - testTxDeliveredAmountRPC() + testTxDeliveredAmountRPC(FeatureBitset features) { testcase("Ledger Request RPC DeliveredAmount"); @@ -282,7 +282,7 @@ class DeliveredAmount_test : public beast::unit_test::suite for (bool const afterSwitchTime : {true, false}) { - Env env{*this}; + Env env{*this, features}; env.fund(XRP(10000), alice, bob, carol, gw); env.trust(USD(1000), alice, bob, carol); if (afterSwitchTime) @@ -329,8 +329,10 @@ public: void run() override { - testTxDeliveredAmountRPC(); - testAccountDeliveredAmountSubscribe(); + using namespace test::jtx; + FeatureBitset const all{supported_amendments() - featureXahauGenesis}; + testTxDeliveredAmountRPC(all); + testAccountDeliveredAmountSubscribe(all); } }; diff --git a/src/test/rpc/OwnerInfo_test.cpp b/src/test/rpc/OwnerInfo_test.cpp index 0de4ef2bd..1dbfdb4ae 100644 --- a/src/test/rpc/OwnerInfo_test.cpp +++ b/src/test/rpc/OwnerInfo_test.cpp @@ -28,12 +28,12 @@ namespace ripple { class OwnerInfo_test : public beast::unit_test::suite { void - testBadInput() + testBadInput(FeatureBitset features) { testcase("Bad input to owner_info"); using namespace test::jtx; - Env env{*this}; + Env env{*this, features}; auto const alice = Account{"alice"}; env.fund(XRP(10000), alice); @@ -81,12 +81,12 @@ class OwnerInfo_test : public beast::unit_test::suite } void - testBasic() + testBasic(FeatureBitset features) { testcase("Basic request for owner_info"); using namespace test::jtx; - Env env{*this}; + Env env{*this, features}; auto const alice = Account{"alice"}; auto const gw = Account{"gateway"}; @@ -210,8 +210,10 @@ public: void run() override { - testBadInput(); - testBasic(); + using namespace test::jtx; + FeatureBitset const all{supported_amendments() - featureXahauGenesis}; + testBadInput(all); + testBasic(all); } }; diff --git a/src/test/rpc/ReportingETL_test.cpp b/src/test/rpc/ReportingETL_test.cpp index 77284dd77..f8a1999a9 100644 --- a/src/test/rpc/ReportingETL_test.cpp +++ b/src/test/rpc/ReportingETL_test.cpp @@ -52,13 +52,13 @@ class ReportingETL_test : public beast::unit_test::suite } }; void - testGetLedger() + testGetLedger(FeatureBitset features) { testcase("GetLedger"); using namespace test::jtx; std::unique_ptr config = envconfig(addGrpcConfig); std::string grpcPort = *(*config)["port_grpc"].get("port"); - Env env(*this, std::move(config)); + Env env(*this, std::move(config), features); env.close(); @@ -494,13 +494,13 @@ class ReportingETL_test : public beast::unit_test::suite } }; void - testGetLedgerData() + testGetLedgerData(FeatureBitset features) { testcase("GetLedgerData"); using namespace test::jtx; std::unique_ptr config = envconfig(addGrpcConfig); std::string grpcPort = *(*config)["port_grpc"].get("port"); - Env env(*this, std::move(config)); + Env env(*this, std::move(config), features); auto grpcLedgerData = [&grpcPort]( auto sequence, std::string marker = "") { GrpcLedgerDataClient grpcClient{grpcPort}; @@ -616,13 +616,13 @@ class ReportingETL_test : public beast::unit_test::suite }; void - testGetLedgerDiff() + testGetLedgerDiff(FeatureBitset features) { testcase("GetLedgerDiff"); using namespace test::jtx; std::unique_ptr config = envconfig(addGrpcConfig); std::string grpcPort = *(*config)["port_grpc"].get("port"); - Env env(*this, std::move(config)); + Env env(*this, std::move(config), features); auto grpcLedgerDiff = [&grpcPort]( auto baseSequence, auto desiredSequence) { @@ -731,13 +731,13 @@ class ReportingETL_test : public beast::unit_test::suite }; void - testGetLedgerEntry() + testGetLedgerEntry(FeatureBitset features) { testcase("GetLedgerDiff"); using namespace test::jtx; std::unique_ptr config = envconfig(addGrpcConfig); std::string grpcPort = *(*config)["port_grpc"].get("port"); - Env env(*this, std::move(config)); + Env env(*this, std::move(config), features); auto grpcLedgerEntry = [&grpcPort](auto sequence, auto key) { GrpcLedgerEntryClient grpcClient{grpcPort}; @@ -888,7 +888,7 @@ class ReportingETL_test : public beast::unit_test::suite } void - testSecureGateway() + testSecureGateway(FeatureBitset features) { testcase("SecureGateway"); using namespace test::jtx; @@ -897,7 +897,7 @@ class ReportingETL_test : public beast::unit_test::suite addGrpcConfigWithSecureGateway, getEnvLocalhostAddr()); std::string grpcPort = *(*config)["port_grpc"].get("port"); - Env env(*this, std::move(config)); + Env env(*this, std::move(config), features); env.close(); @@ -1120,17 +1120,20 @@ public: void run() override { - testGetLedger(); + using namespace test::jtx; + FeatureBitset const all{supported_amendments() - featureXahauGenesis}; + + testGetLedger(all); - testGetLedgerData(); + testGetLedgerData(all); - testGetLedgerDiff(); + testGetLedgerDiff(all); - testGetLedgerEntry(); + testGetLedgerEntry(all); testNeedCurrentOrClosed(); - testSecureGateway(); + testSecureGateway(all); } };