From 3f922eb8c50688f7376620cbb1d40bfcd5341d46 Mon Sep 17 00:00:00 2001 From: dangell7 Date: Mon, 16 Jan 2023 06:26:08 -0500 Subject: [PATCH] enable test w/ features --- src/test/app/Escrow_test.cpp | 213 ++++++++++++++++-------------- src/test/app/PayChan_test.cpp | 241 ++++++++++++++++++---------------- 2 files changed, 236 insertions(+), 218 deletions(-) diff --git a/src/test/app/Escrow_test.cpp b/src/test/app/Escrow_test.cpp index a5b20bbce..e1f3219f1 100644 --- a/src/test/app/Escrow_test.cpp +++ b/src/test/app/Escrow_test.cpp @@ -203,14 +203,14 @@ struct Escrow_test : public beast::unit_test::suite } void - testEnablement() + testEnablement(FeatureBitset features) { testcase("Enablement"); using namespace jtx; using namespace std::chrono; - Env env(*this); + Env env(*this, features); env.fund(XRP(5000), "alice", "bob"); env(escrow("alice", "bob", XRP(1000)), finish_time(env.now() + 1s)); env.close(); @@ -239,14 +239,14 @@ struct Escrow_test : public beast::unit_test::suite } void - testTiming() + testTiming(FeatureBitset features) { using namespace jtx; using namespace std::chrono; { testcase("Timing: Finish Only"); - Env env(*this); + Env env(*this, features); env.fund(XRP(5000), "alice", "bob"); env.close(); @@ -268,7 +268,7 @@ struct Escrow_test : public beast::unit_test::suite { testcase("Timing: Cancel Only"); - Env env(*this); + Env env(*this, features); env.fund(XRP(5000), "alice", "bob"); env.close(); @@ -300,7 +300,7 @@ struct Escrow_test : public beast::unit_test::suite { testcase("Timing: Finish and Cancel -> Finish"); - Env env(*this); + Env env(*this, features); env.fund(XRP(5000), "alice", "bob"); env.close(); @@ -334,7 +334,7 @@ struct Escrow_test : public beast::unit_test::suite { testcase("Timing: Finish and Cancel -> Cancel"); - Env env(*this); + Env env(*this, features); env.fund(XRP(5000), "alice", "bob"); env.close(); @@ -376,14 +376,14 @@ struct Escrow_test : public beast::unit_test::suite } void - testTags() + testTags(FeatureBitset features) { testcase("Tags"); using namespace jtx; using namespace std::chrono; - Env env(*this); + Env env(*this, features); auto const alice = Account("alice"); auto const bob = Account("bob"); @@ -412,7 +412,7 @@ struct Escrow_test : public beast::unit_test::suite } void - testDisallowXRP() + testDisallowXRP(FeatureBitset features) { testcase("Disallow XRP"); @@ -432,7 +432,7 @@ struct Escrow_test : public beast::unit_test::suite { // Ignore the "asfDisallowXRP" account flag, which we should // have been doing before. - Env env(*this); + Env env(*this, features); env.fund(XRP(5000), "bob", "george"); env(fset("george", asfDisallowXRP)); @@ -441,7 +441,7 @@ struct Escrow_test : public beast::unit_test::suite } void - test1571() + test1571(FeatureBitset features) { using namespace jtx; using namespace std::chrono; @@ -483,7 +483,7 @@ struct Escrow_test : public beast::unit_test::suite { testcase("Implied Finish Time (with fix1571)"); - Env env(*this); + Env env(*this, features); env.fund(XRP(5000), "alice", "bob", "carol"); env.close(); @@ -510,14 +510,14 @@ struct Escrow_test : public beast::unit_test::suite } void - testFails() + testFails(FeatureBitset features) { testcase("Failure Cases"); using namespace jtx; using namespace std::chrono; - Env env(*this); + Env env(*this, features); env.fund(XRP(5000), "alice", "bob"); env.close(); @@ -642,7 +642,7 @@ struct Escrow_test : public beast::unit_test::suite } void - testLockup() + testLockup(FeatureBitset features) { testcase("Lockup"); @@ -651,7 +651,7 @@ struct Escrow_test : public beast::unit_test::suite { // Unconditional - Env env(*this); + Env env(*this, features); env.fund(XRP(5000), "alice", "bob"); auto const seq = env.seq("alice"); env(escrow("alice", "alice", XRP(1000)), @@ -675,7 +675,7 @@ struct Escrow_test : public beast::unit_test::suite // 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); + Env env(*this, features); env.fund(XRP(5000), "alice", "bob", "zelda"); auto const seq = env.seq("alice"); env(escrow("alice", "bob", XRP(1000)), finish_time(env.now() + 5s)); @@ -700,7 +700,7 @@ struct Escrow_test : public beast::unit_test::suite } { // Bob sets DepositAuth so only Bob can finish the escrow. - Env env(*this); + Env env(*this, features); env.fund(XRP(5000), "alice", "bob", "zelda"); env(fset("bob", asfDepositAuth)); @@ -738,7 +738,7 @@ struct Escrow_test : public beast::unit_test::suite { // Bob sets DepositAuth but preauthorizes Zelda, so Zelda can // finish the escrow. - Env env(*this); + Env env(*this, features); env.fund(XRP(5000), "alice", "bob", "zelda"); env(fset("bob", asfDepositAuth)); @@ -765,7 +765,7 @@ struct Escrow_test : public beast::unit_test::suite } { // Conditional - Env env(*this); + Env env(*this, features); env.fund(XRP(5000), "alice", "bob"); auto const seq = env.seq("alice"); env(escrow("alice", "alice", XRP(1000)), @@ -806,7 +806,7 @@ struct Escrow_test : public beast::unit_test::suite } { // Self-escrowed conditional with DepositAuth. - Env env(*this); + Env env(*this, features); env.fund(XRP(5000), "alice", "bob"); auto const seq = env.seq("alice"); @@ -842,7 +842,7 @@ struct Escrow_test : public beast::unit_test::suite } { // Self-escrowed conditional with DepositAuth and DepositPreauth. - Env env(*this); + Env env(*this, features); env.fund(XRP(5000), "alice", "bob", "zelda"); auto const seq = env.seq("alice"); @@ -885,7 +885,7 @@ struct Escrow_test : public beast::unit_test::suite } void - testEscrowConditions() + testEscrowConditions(FeatureBitset features) { testcase("Escrow with CryptoConditions"); @@ -893,7 +893,7 @@ struct Escrow_test : public beast::unit_test::suite using namespace std::chrono; { // Test cryptoconditions - Env env(*this); + Env env(*this, features); env.fund(XRP(5000), "alice", "bob", "carol"); auto const seq = env.seq("alice"); BEAST_EXPECT((*env.le("alice"))[sfOwnerCount] == 0); @@ -966,7 +966,7 @@ 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); + Env env(*this, features); env.fund(XRP(5000), "alice", "bob", "carol"); auto const seq = env.seq("alice"); BEAST_EXPECT((*env.le("alice"))[sfOwnerCount] == 0); @@ -982,7 +982,7 @@ struct Escrow_test : public beast::unit_test::suite BEAST_EXPECT(!env.le(keylet::escrow(Account("alice").id(), seq))); } { - Env env(*this); + Env env(*this, features); env.fund(XRP(5000), "alice", "bob", "carol"); env.close(); auto const seq = env.seq("alice"); @@ -1004,7 +1004,7 @@ struct Escrow_test : public beast::unit_test::suite env.require(balance("carol", XRP(5000))); } { // Test long & short conditions during creation - Env env(*this); + Env env(*this, features); env.fund(XRP(5000), "alice", "bob", "carol"); std::vector v; @@ -1061,7 +1061,7 @@ struct Escrow_test : public beast::unit_test::suite env.require(balance("carol", XRP(6000))); } { // Test long and short conditions & fulfillments during finish - Env env(*this); + Env env(*this, features); env.fund(XRP(5000), "alice", "bob", "carol"); std::vector cv; @@ -1207,7 +1207,7 @@ struct Escrow_test : public beast::unit_test::suite } { // Test empty condition during creation and // empty condition & fulfillment during finish - Env env(*this); + Env env(*this, features); env.fund(XRP(5000), "alice", "bob", "carol"); env(escrow("alice", "carol", XRP(1000)), @@ -1253,7 +1253,7 @@ struct Escrow_test : public beast::unit_test::suite } { // Test a condition other than PreimageSha256, which // would require a separate amendment - Env env(*this); + Env env(*this, features); env.fund(XRP(5000), "alice", "bob"); std::array cb = { @@ -1273,7 +1273,7 @@ struct Escrow_test : public beast::unit_test::suite } void - testMetaAndOwnership() + testMetaAndOwnership(FeatureBitset features) { using namespace jtx; using namespace std::chrono; @@ -1285,7 +1285,7 @@ struct Escrow_test : public beast::unit_test::suite { testcase("Metadata to self"); - Env env(*this); + Env env(*this, features); env.fund(XRP(5000), alice, bruce, carol); auto const aseq = env.seq(alice); auto const bseq = env.seq(bruce); @@ -1360,7 +1360,7 @@ struct Escrow_test : public beast::unit_test::suite { testcase("Metadata to other"); - Env env(*this); + Env env(*this, features); env.fund(XRP(5000), alice, bruce, carol); auto const aseq = env.seq(alice); auto const bseq = env.seq(bruce); @@ -1450,13 +1450,13 @@ struct Escrow_test : public beast::unit_test::suite } void - testConsequences() + testConsequences(FeatureBitset features) { testcase("Consequences"); using namespace jtx; using namespace std::chrono; - Env env(*this); + Env env(*this, features); env.memoize("alice"); env.memoize("bob"); @@ -1510,7 +1510,7 @@ struct Escrow_test : public beast::unit_test::suite } void - testEscrowWithTickets() + testEscrowWithTickets(FeatureBitset features) { testcase("Escrow with tickets"); @@ -1521,7 +1521,7 @@ struct Escrow_test : public beast::unit_test::suite { // Create escrow and finish using tickets. - Env env(*this); + Env env(*this, features); env.fund(XRP(5000), alice, bob); env.close(); @@ -1582,7 +1582,7 @@ struct Escrow_test : public beast::unit_test::suite { // Create escrow and cancel using tickets. - Env env(*this); + Env env(*this, features); env.fund(XRP(5000), alice, bob); env.close(); @@ -1649,14 +1649,14 @@ struct Escrow_test : public beast::unit_test::suite } void - testICEnablement() + testICEnablement(FeatureBitset features) { testcase("IC Enablement"); using namespace jtx; using namespace std::chrono; - Env env(*this); + Env env(*this, features); // <- setup tests auto const alice = Account("alice"); @@ -1699,14 +1699,14 @@ struct Escrow_test : public beast::unit_test::suite } void - testICTiming() + testICTiming(FeatureBitset features) { using namespace jtx; using namespace std::chrono; { testcase("Timing: IC Finish Only"); - Env env(*this); + Env env(*this, features); // <- setup tests auto const alice = Account("alice"); @@ -1738,7 +1738,7 @@ struct Escrow_test : public beast::unit_test::suite { testcase("Timing: IC Cancel Only"); - Env env(*this); + Env env(*this, features); // <- setup tests auto const alice = Account("alice"); @@ -1782,7 +1782,7 @@ struct Escrow_test : public beast::unit_test::suite { testcase("Timing: IC Finish and Cancel -> Finish"); - Env env(*this); + Env env(*this, features); // <- setup tests auto const alice = Account("alice"); @@ -1828,7 +1828,7 @@ struct Escrow_test : public beast::unit_test::suite { testcase("Timing: IC Finish and Cancel -> Cancel"); - Env env(*this); + Env env(*this, features); // <- setup tests auto const alice = Account("alice"); @@ -1882,14 +1882,14 @@ struct Escrow_test : public beast::unit_test::suite } void - testICTags() + testICTags(FeatureBitset features) { testcase("IC Tags"); using namespace jtx; using namespace std::chrono; - Env env(*this); + Env env(*this, features); // <- setup tests auto const alice = Account("alice"); @@ -1927,7 +1927,7 @@ struct Escrow_test : public beast::unit_test::suite } void - testIC1571() + testIC1571(FeatureBitset features) { using namespace jtx; using namespace std::chrono; @@ -1963,7 +1963,7 @@ struct Escrow_test : public beast::unit_test::suite fee(1500)); env.close(); env(finish(carol, alice, seq1), fee(1500)); - BEAST_EXPECT(env.balance(bob).value() == USD(5100)); + BEAST_EXPECT(env.balance(bob, USD.issue()).value() == USD(5100)); env.close(); @@ -1979,13 +1979,13 @@ struct Escrow_test : public beast::unit_test::suite condition(cb1), fulfillment(fb1), fee(1500)); - BEAST_EXPECT(env.balance(bob).value() == USD(5200)); + BEAST_EXPECT(env.balance(bob, USD.issue()).value() == USD(5200)); } { testcase("IC Implied Finish Time (with fix1571)"); - Env env(*this); + Env env(*this, features); // <- setup tests auto const alice = Account("alice"); @@ -2021,19 +2021,19 @@ struct Escrow_test : public beast::unit_test::suite condition(cb1), fulfillment(fb1), fee(1500)); - BEAST_EXPECT(env.balance(bob).value() == USD(5100)); + BEAST_EXPECT(env.balance(bob, USD.issue()).value() == USD(5100)); } } void - testICFails() + testICFails(FeatureBitset features) { testcase("IC Failure Cases"); using namespace jtx; using namespace std::chrono; - Env env(*this); + Env env(*this, features); // <- setup tests auto const alice = Account("alice"); @@ -2234,7 +2234,7 @@ struct Escrow_test : public beast::unit_test::suite } void - testICLockup() + testICLockup(FeatureBitset features) { testcase("IC Lockup"); @@ -2243,7 +2243,7 @@ struct Escrow_test : public beast::unit_test::suite { // Unconditional - Env env(*this); + Env env(*this, features); // <- setup tests auto const alice = Account("alice"); @@ -2288,7 +2288,7 @@ struct Escrow_test : public beast::unit_test::suite // 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); + Env env(*this, features); // <- setup tests auto const alice = Account("alice"); @@ -2337,7 +2337,7 @@ struct Escrow_test : public beast::unit_test::suite } { // Bob sets DepositAuth so only Bob can finish the escrow. - Env env(*this); + Env env(*this, features); // <- setup tests auto const alice = Account("alice"); @@ -2401,7 +2401,7 @@ struct Escrow_test : public beast::unit_test::suite { // Bob sets DepositAuth but preauthorizes Zelda, so Zelda can // finish the escrow. - Env env(*this); + Env env(*this, features); // <- setup tests auto const alice = Account("alice"); @@ -2452,7 +2452,7 @@ struct Escrow_test : public beast::unit_test::suite } { // Conditional - Env env(*this); + Env env(*this, features); // <- setup tests auto const alice = Account("alice"); @@ -2511,7 +2511,7 @@ struct Escrow_test : public beast::unit_test::suite } { // Self-escrowed conditional with DepositAuth. - Env env(*this); + Env env(*this, features); // <- setup tests auto const alice = Account("alice"); @@ -2565,7 +2565,7 @@ struct Escrow_test : public beast::unit_test::suite } { // Self-escrowed conditional with DepositAuth and DepositPreauth. - Env env(*this); + Env env(*this, features); // <- setup tests auto const alice = Account("alice"); @@ -2629,7 +2629,7 @@ struct Escrow_test : public beast::unit_test::suite } void - testICEscrowConditions() + testICEscrowConditions(FeatureBitset features) { testcase("IC Escrow with CryptoConditions"); @@ -2637,7 +2637,7 @@ struct Escrow_test : public beast::unit_test::suite using namespace std::chrono; { // Test cryptoconditions - Env env(*this); + Env env(*this, features); // <- setup tests auto const alice = Account("alice"); @@ -2730,7 +2730,7 @@ 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); + Env env(*this, features); // <- setup tests auto const alice = Account("alice"); @@ -2770,7 +2770,7 @@ struct Escrow_test : public beast::unit_test::suite BEAST_EXPECT(!env.le(keylet::escrow(Account(alice).id(), seq))); } { - Env env(*this); + Env env(*this, features); // <- setup tests auto const alice = Account("alice"); @@ -2808,7 +2808,7 @@ struct Escrow_test : public beast::unit_test::suite env.require(balance(carol, USD(5000))); } { // Test long & short conditions during creation - Env env(*this); + Env env(*this, features); // <- setup tests auto const alice = Account("alice"); @@ -2886,7 +2886,7 @@ struct Escrow_test : public beast::unit_test::suite env.require(balance(carol, USD(6000))); } { // Test long and short conditions & fulfillments during finish - Env env(*this); + Env env(*this, features); // <- setup tests auto const alice = Account("alice"); @@ -3052,7 +3052,7 @@ struct Escrow_test : public beast::unit_test::suite } { // Test empty condition during creation and // empty condition & fulfillment during finish - Env env(*this); + Env env(*this, features); // <- setup tests auto const alice = Account("alice"); @@ -3119,7 +3119,7 @@ struct Escrow_test : public beast::unit_test::suite } { // Test a condition other than PreimageSha256, which // would require a separate amendment - Env env(*this); + Env env(*this, features); // <- setup tests auto const alice = Account("alice"); @@ -3152,7 +3152,7 @@ struct Escrow_test : public beast::unit_test::suite } void - testICMetaAndOwnership() + testICMetaAndOwnership(FeatureBitset features) { using namespace jtx; using namespace std::chrono; @@ -3164,7 +3164,7 @@ struct Escrow_test : public beast::unit_test::suite { testcase("Metadata to self"); - Env env(*this); + Env env(*this, features); env.fund(XRP(5000), alice, bruce, carol); auto const aseq = env.seq(alice); auto const bseq = env.seq(bruce); @@ -3239,7 +3239,7 @@ struct Escrow_test : public beast::unit_test::suite { testcase("Metadata to other"); - Env env(*this); + Env env(*this, features); env.fund(XRP(5000), alice, bruce, carol); auto const aseq = env.seq(alice); auto const bseq = env.seq(bruce); @@ -3329,13 +3329,13 @@ struct Escrow_test : public beast::unit_test::suite } void - testICConsequences() + testICConsequences(FeatureBitset features) { testcase("Consequences"); using namespace jtx; using namespace std::chrono; - Env env(*this); + Env env(*this, features); env.memoize("alice"); env.memoize("bob"); @@ -3389,7 +3389,7 @@ struct Escrow_test : public beast::unit_test::suite } void - testICEscrowWithTickets() + testICEscrowWithTickets(FeatureBitset features) { testcase("Escrow with tickets"); @@ -3400,7 +3400,7 @@ struct Escrow_test : public beast::unit_test::suite { // Create escrow and finish using tickets. - Env env(*this); + Env env(*this, features); env.fund(XRP(5000), alice, bob); @@ -3463,7 +3463,7 @@ struct Escrow_test : public beast::unit_test::suite { // Create escrow and cancel using tickets. - Env env(*this); + Env env(*this, features); env.fund(XRP(5000), alice, bob); env.close(); @@ -3530,30 +3530,39 @@ struct Escrow_test : public beast::unit_test::suite } void - run() override + testWithFeats(FeatureBitset features) { - testEnablement(); - testTiming(); - testTags(); - testDisallowXRP(); - test1571(); - testFails(); - testLockup(); - testEscrowConditions(); - testMetaAndOwnership(); - testConsequences(); - testEscrowWithTickets(); - testICEnablement(); - testICTiming(); - testICTags(); - // testICDisallowXRP() - testIC1571(); - testICFails(); - testICLockup(); - testICEscrowConditions(); - // testICMetaAndOwnership(); - // testICConsequences(); - // testEscrowWithTickets(); + testEnablement(features); + testTiming(features); + testTags(features); + testDisallowXRP(features); + test1571(features); + testFails(features); + testLockup(features); + testEscrowConditions(features); + testMetaAndOwnership(features); + testConsequences(features); + testEscrowWithTickets(features); + testICEnablement(features); + testICTiming(features); + testICTags(features); + // testICDisallowXRP(features) + testIC1571(features); + testICFails(features); + testICLockup(features); + testICEscrowConditions(features); + // testICMetaAndOwnership(features); + // testICConsequences(features); + // testEscrowWithTickets(features); + } + +public: + void + run() override + { + using namespace test::jtx; + FeatureBitset const all{supported_amendments()}; + testWithFeats(all); } }; diff --git a/src/test/app/PayChan_test.cpp b/src/test/app/PayChan_test.cpp index afcfbbf78..f170f8e71 100644 --- a/src/test/app/PayChan_test.cpp +++ b/src/test/app/PayChan_test.cpp @@ -206,12 +206,12 @@ struct PayChan_test : public beast::unit_test::suite } void - testSimple() + testSimple(FeatureBitset features) { testcase("simple"); using namespace jtx; using namespace std::literals::chrono_literals; - Env env(*this); + Env env(*this, features); auto const alice = Account("alice"); auto const bob = Account("bob"); env.fund(XRP(10000), alice, bob); @@ -373,7 +373,7 @@ struct PayChan_test : public beast::unit_test::suite } void - testCancelAfter() + testCancelAfter(FeatureBitset features) { testcase("cancel after"); using namespace jtx; @@ -383,7 +383,7 @@ struct PayChan_test : public beast::unit_test::suite auto const carol = Account("carol"); { // If dst claims after cancel after, channel closes - Env env(*this); + Env env(*this, features); env.fund(XRP(10000), alice, bob); auto const pk = alice.pk(); auto const settleDelay = 100s; @@ -415,7 +415,7 @@ struct PayChan_test : public beast::unit_test::suite } { // Third party can close after cancel after - Env env(*this); + Env env(*this, features); env.fund(XRP(10000), alice, bob, carol); auto const pk = alice.pk(); auto const settleDelay = 100s; @@ -438,12 +438,12 @@ struct PayChan_test : public beast::unit_test::suite } void - testExpiration() + testExpiration(FeatureBitset features) { testcase("expiration"); using namespace jtx; using namespace std::literals::chrono_literals; - Env env(*this); + Env env(*this, features); auto const alice = Account("alice"); auto const bob = Account("bob"); auto const carol = Account("carol"); @@ -504,12 +504,12 @@ struct PayChan_test : public beast::unit_test::suite } void - testSettleDelay() + testSettleDelay(FeatureBitset features) { testcase("settle delay"); using namespace jtx; using namespace std::literals::chrono_literals; - Env env(*this); + Env env(*this, features); auto const alice = Account("alice"); auto const bob = Account("bob"); env.fund(XRP(10000), alice, bob); @@ -565,12 +565,12 @@ struct PayChan_test : public beast::unit_test::suite } void - testCloseDry() + testCloseDry(FeatureBitset features) { testcase("close dry"); using namespace jtx; using namespace std::literals::chrono_literals; - Env env(*this); + Env env(*this, features); auto const alice = Account("alice"); auto const bob = Account("bob"); env.fund(XRP(10000), alice, bob); @@ -599,13 +599,13 @@ struct PayChan_test : public beast::unit_test::suite } void - testDefaultAmount() + testDefaultAmount(FeatureBitset features) { // auth amount defaults to balance if not present testcase("default amount"); using namespace jtx; using namespace std::literals::chrono_literals; - Env env(*this); + Env env(*this, features); auto const alice = Account("alice"); auto const bob = Account("bob"); env.fund(XRP(10000), alice, bob); @@ -653,7 +653,7 @@ struct PayChan_test : public beast::unit_test::suite } void - testDisallowXRP() + testDisallowXRP(FeatureBitset features) { // auth amount defaults to balance if not present testcase("Disallow XRP"); @@ -675,7 +675,7 @@ struct PayChan_test : public beast::unit_test::suite { // Create a channel where dst disallows XRP. Ignore that flag, // since it's just advisory. - Env env(*this); + Env env(*this, features); env.fund(XRP(10000), alice, bob); env(fset(bob, asfDisallowXRP)); auto const chan = channel(alice, bob, env.seq(alice)); @@ -700,7 +700,7 @@ struct PayChan_test : public beast::unit_test::suite // Claim to a channel where dst disallows XRP (channel is // created before disallow xrp is set). Ignore that flag // since it is just advisory. - Env env(*this); + Env env(*this, features); env.fund(XRP(10000), alice, bob); auto const chan = channel(alice, bob, env.seq(alice)); env(create(alice, bob, XRP(1000), 3600s, alice.pk())); @@ -713,14 +713,14 @@ struct PayChan_test : public beast::unit_test::suite } void - testDstTag() + testDstTag(FeatureBitset features) { // auth amount defaults to balance if not present testcase("Dst Tag"); using namespace jtx; using namespace std::literals::chrono_literals; // Create a channel where dst disallows XRP - Env env(*this); + Env env(*this, features); auto const alice = Account("alice"); auto const bob = Account("bob"); env.fund(XRP(10000), alice, bob); @@ -743,7 +743,7 @@ struct PayChan_test : public beast::unit_test::suite } void - testDepositAuth() + testDepositAuth(FeatureBitset features) { testcase("Deposit Authorization"); using namespace jtx; @@ -753,7 +753,7 @@ struct PayChan_test : public beast::unit_test::suite auto const bob = Account("bob"); auto const carol = Account("carol"); { - Env env(*this); + Env env(*this, features); env.fund(XRP(10000), alice, bob, carol); env(fset(bob, asfDepositAuth)); @@ -866,13 +866,13 @@ struct PayChan_test : public beast::unit_test::suite } void - testMultiple() + testMultiple(FeatureBitset features) { // auth amount defaults to balance if not present testcase("Multiple channels to the same account"); using namespace jtx; using namespace std::literals::chrono_literals; - Env env(*this); + Env env(*this, features); auto const alice = Account("alice"); auto const bob = Account("bob"); env.fund(XRP(10000), alice, bob); @@ -889,13 +889,13 @@ struct PayChan_test : public beast::unit_test::suite } void - testAccountChannelsRPC() + testAccountChannelsRPC(FeatureBitset features) { testcase("AccountChannels RPC"); using namespace jtx; using namespace std::literals::chrono_literals; - Env env(*this); + Env env(*this, features); auto const alice = Account("alice"); auto const bob = Account("bob"); auto const charlie = Account("charlie", KeyType::ed25519); @@ -944,7 +944,7 @@ struct PayChan_test : public beast::unit_test::suite } void - testAccountChannelsRPCMarkers() + testAccountChannelsRPCMarkers(FeatureBitset features) { testcase("Account channels RPC markers"); @@ -963,7 +963,7 @@ struct PayChan_test : public beast::unit_test::suite return r; }(); - Env env(*this); + Env env(*this, features); env.fund(XRP(10000), alice); for (auto const& a : bobs) { @@ -1060,7 +1060,7 @@ struct PayChan_test : public beast::unit_test::suite } void - testAccountChannelsRPCSenderOnly() + testAccountChannelsRPCSenderOnly(FeatureBitset features) { // Check that the account_channels command only returns channels owned // by the account @@ -1071,7 +1071,7 @@ struct PayChan_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); - Env env(*this); + Env env(*this, features); env.fund(XRP(10000), alice, bob); // Create a channel from alice to bob and from bob to alice @@ -1097,12 +1097,12 @@ struct PayChan_test : public beast::unit_test::suite } void - testAuthVerifyRPC() + testAuthVerifyRPC(FeatureBitset features) { testcase("PayChan Auth/Verify RPC"); using namespace jtx; using namespace std::literals::chrono_literals; - Env env(*this); + Env env(*this, features); auto const alice = Account("alice"); auto const bob = Account("bob"); auto const charlie = Account("charlie", KeyType::ed25519); @@ -1437,12 +1437,12 @@ struct PayChan_test : public beast::unit_test::suite } void - testOptionalFields() + testOptionalFields(FeatureBitset features) { testcase("Optional Fields"); using namespace jtx; using namespace std::literals::chrono_literals; - Env env(*this); + Env env(*this, features); auto const alice = Account("alice"); auto const bob = Account("bob"); auto const carol = Account("carol"); @@ -1488,12 +1488,12 @@ struct PayChan_test : public beast::unit_test::suite } void - testMalformedPK() + testMalformedPK(FeatureBitset features) { testcase("malformed pk"); using namespace jtx; using namespace std::literals::chrono_literals; - Env env(*this); + Env env(*this, features); auto const alice = Account("alice"); auto const bob = Account("bob"); env.fund(XRP(10000), alice, bob); @@ -1557,7 +1557,7 @@ struct PayChan_test : public beast::unit_test::suite } void - testMetaAndOwnership() + testMetaAndOwnership(FeatureBitset features) { testcase("Metadata & Ownership"); @@ -1608,7 +1608,7 @@ struct PayChan_test : public beast::unit_test::suite { // Test with adding the paychan to the recipient's owner directory - Env env(*this); + Env env(*this, features); env.fund(XRP(10000), alice, bob); env(create(alice, bob, XRP(1000), settleDelay, pk)); env.close(); @@ -1665,7 +1665,7 @@ struct PayChan_test : public beast::unit_test::suite } void - testAccountDelete() + testAccountDelete(FeatureBitset features) { testcase("Account Delete"); using namespace test::jtx; @@ -1899,12 +1899,12 @@ struct PayChan_test : public beast::unit_test::suite } void - testUsingTickets() + testUsingTickets(FeatureBitset features) { testcase("using tickets"); using namespace jtx; using namespace std::literals::chrono_literals; - Env env(*this); + Env env(*this, features); auto const alice = Account("alice"); auto const bob = Account("bob"); env.fund(XRP(10000), alice, bob); @@ -2060,12 +2060,12 @@ struct PayChan_test : public beast::unit_test::suite } void - testICSimple() + testICSimple(FeatureBitset features) { testcase("ic simple"); using namespace jtx; using namespace std::literals::chrono_literals; - Env env(*this); + Env env(*this, features); // <- setup tests auto const alice = Account("alice"); @@ -2261,7 +2261,7 @@ struct PayChan_test : public beast::unit_test::suite } void - testICCancelAfter() + testICCancelAfter(FeatureBitset features) { testcase("ic cancel after"); using namespace jtx; @@ -2274,7 +2274,7 @@ struct PayChan_test : public beast::unit_test::suite { // If dst claims after cancel after, channel closes - Env env(*this); + Env env(*this, features); env.fund(XRP(10000), alice, bob, gw); env.close(); @@ -2324,7 +2324,7 @@ struct PayChan_test : public beast::unit_test::suite } { // Third party can close after cancel after - Env env(*this); + Env env(*this, features); env.fund(XRP(10000), alice, bob, carol, gw); env.close(); env.trust(USD(100000), alice, bob, carol); @@ -2358,12 +2358,12 @@ struct PayChan_test : public beast::unit_test::suite } void - testICSettleDelay() + testICSettleDelay(FeatureBitset features) { testcase("ic settle delay"); using namespace jtx; using namespace std::literals::chrono_literals; - Env env(*this); + Env env(*this, features); auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account{"gateway"}; @@ -2439,12 +2439,12 @@ struct PayChan_test : public beast::unit_test::suite } void - testICExpiration() + testICExpiration(FeatureBitset features) { testcase("ic expiration"); using namespace jtx; using namespace std::literals::chrono_literals; - Env env(*this); + Env env(*this, features); auto const alice = Account("alice"); auto const bob = Account("bob"); auto const carol = Account("carol"); @@ -2514,12 +2514,12 @@ struct PayChan_test : public beast::unit_test::suite } void - testICCloseDry() + testICCloseDry(FeatureBitset features) { testcase("ic close dry"); using namespace jtx; using namespace std::literals::chrono_literals; - Env env(*this); + Env env(*this, features); auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account{"gateway"}; @@ -2558,13 +2558,13 @@ struct PayChan_test : public beast::unit_test::suite } void - testICDefaultAmount() + testICDefaultAmount(FeatureBitset features) { // auth amount defaults to balance if not present testcase("ic default amount"); using namespace jtx; using namespace std::literals::chrono_literals; - Env env(*this); + Env env(*this, features); auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account{"gateway"}; @@ -2633,14 +2633,14 @@ struct PayChan_test : public beast::unit_test::suite } void - testICDstTag() + testICDstTag(FeatureBitset features) { // auth amount defaults to balance if not present testcase("IC Dst Tag"); using namespace jtx; using namespace std::literals::chrono_literals; // Create a channel where dst disallows XRP - Env env(*this); + Env env(*this, features); auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account{"gateway"}; @@ -2673,7 +2673,7 @@ struct PayChan_test : public beast::unit_test::suite } void - testICDepositAuth() + testICDepositAuth(FeatureBitset features) { testcase("IC Deposit Authorization"); using namespace jtx; @@ -2686,7 +2686,7 @@ struct PayChan_test : public beast::unit_test::suite auto const USD = gw["USD"]; { - Env env(*this); + Env env(*this, features); env.fund(XRP(10000), alice, bob, carol, gw); env.close(); env.trust(USD(100000), alice, bob, carol); @@ -2807,13 +2807,13 @@ struct PayChan_test : public beast::unit_test::suite } void - testICMultiple() + testICMultiple(FeatureBitset features) { // auth amount defaults to balance if not present testcase("IC Multiple channels to the same account"); using namespace jtx; using namespace std::literals::chrono_literals; - Env env(*this); + Env env(*this, features); auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account{"gateway"}; @@ -2838,13 +2838,13 @@ struct PayChan_test : public beast::unit_test::suite } void - testICAccountChannelsRPC() + testICAccountChannelsRPC(FeatureBitset features) { testcase("AccountChannels RPC"); using namespace jtx; using namespace std::literals::chrono_literals; - Env env(*this); + Env env(*this, features); auto const alice = Account("alice"); auto const bob = Account("bob"); auto const charlie = Account("charlie", KeyType::ed25519); @@ -2902,7 +2902,7 @@ struct PayChan_test : public beast::unit_test::suite } void - testICAccountChannelsRPCMarkers() + testICAccountChannelsRPCMarkers(FeatureBitset features) { testcase("IC Account channels RPC markers"); @@ -2923,7 +2923,7 @@ struct PayChan_test : public beast::unit_test::suite return r; }(); - Env env(*this); + Env env(*this, features); env.fund(XRP(10000), alice, gw); env.close(); env.trust(USD(100000), alice); @@ -3029,7 +3029,7 @@ struct PayChan_test : public beast::unit_test::suite } void - testICAccountChannelsRPCSenderOnly() + testICAccountChannelsRPCSenderOnly(FeatureBitset features) { // Check that the account_channels command only returns channels owned // by the account @@ -3043,7 +3043,7 @@ struct PayChan_test : public beast::unit_test::suite auto const gw = Account{"gateway"}; auto const USD = gw["USD"]; - Env env(*this); + Env env(*this, features); env.fund(XRP(10000), alice, bob, gw); env.close(); env.trust(USD(100000), alice, bob); @@ -3074,12 +3074,12 @@ struct PayChan_test : public beast::unit_test::suite } void - testICAuthVerifyRPC() + testICAuthVerifyRPC(FeatureBitset features) { testcase("IC PayChan Auth/Verify RPC"); using namespace jtx; using namespace std::literals::chrono_literals; - Env env(*this); + Env env(*this, features); auto const alice = Account("alice"); auto const bob = Account("bob"); auto const charlie = Account("charlie", KeyType::ed25519); @@ -3423,12 +3423,12 @@ struct PayChan_test : public beast::unit_test::suite } void - testICOptionalFields() + testICOptionalFields(FeatureBitset features) { testcase("IC Optional Fields"); using namespace jtx; using namespace std::literals::chrono_literals; - Env env(*this); + Env env(*this, features); auto const alice = Account("alice"); auto const bob = Account("bob"); auto const carol = Account("carol"); @@ -3484,12 +3484,12 @@ struct PayChan_test : public beast::unit_test::suite } void - testICMalformedPK() + testICMalformedPK(FeatureBitset features) { testcase("ic malformed pk"); using namespace jtx; using namespace std::literals::chrono_literals; - Env env(*this); + Env env(*this, features); auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account{"gateway"}; @@ -3561,7 +3561,7 @@ struct PayChan_test : public beast::unit_test::suite } void - testICMetaAndOwnership() + testICMetaAndOwnership(FeatureBitset features) { testcase("IC Metadata & Ownership"); @@ -3622,7 +3622,7 @@ struct PayChan_test : public beast::unit_test::suite { // Test with adding the paychan to the recipient's owner directory - Env env(*this); + Env env(*this, features); env.fund(XRP(10000), alice, bob, gw); env.close(); env.trust(USD(100000), alice, bob); @@ -3693,7 +3693,7 @@ struct PayChan_test : public beast::unit_test::suite } void - testICAccountDelete() + testICAccountDelete(FeatureBitset features) { testcase("IC Account Delete"); using namespace test::jtx; @@ -3958,12 +3958,12 @@ struct PayChan_test : public beast::unit_test::suite } void - testICUsingTickets() + testICUsingTickets(FeatureBitset features) { testcase("ic using tickets"); using namespace jtx; using namespace std::literals::chrono_literals; - Env env(*this); + Env env(*this, features); auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account{"gateway"}; @@ -4135,7 +4135,7 @@ struct PayChan_test : public beast::unit_test::suite } void - testICAutoTL() + testICAutoTL(FeatureBitset features) { testcase("IC Auto Trust Line"); using namespace test::jtx; @@ -4149,7 +4149,7 @@ struct PayChan_test : public beast::unit_test::suite { // test trust line missing - Env env(*this); + Env env(*this, features); env.fund(XRP(10000), alice, bob, gw); env.close(); env.trust(USD(100000), alice); @@ -4207,48 +4207,57 @@ struct PayChan_test : public beast::unit_test::suite } void - run() override + testWithFeats(FeatureBitset features) { - testSimple(); - testCancelAfter(); - testSettleDelay(); - testExpiration(); - testCloseDry(); - testDefaultAmount(); - testDisallowXRP(); - testDstTag(); - testDepositAuth(); - testMultiple(); - testAccountChannelsRPC(); - testAccountChannelsRPCMarkers(); - testAccountChannelsRPCSenderOnly(); - testAuthVerifyRPC(); - testOptionalFields(); - testMalformedPK(); - testMetaAndOwnership(); - testAccountDelete(); - testUsingTickets(); - testICSimple(); - testICCancelAfter(); - testICSettleDelay(); - testICExpiration(); - testICCloseDry(); - testICDefaultAmount(); - testICDstTag(); - testICDepositAuth(); - testICMultiple(); + testSimple(features); + testCancelAfter(features); + testSettleDelay(features); + testExpiration(features); + testCloseDry(features); + testDefaultAmount(features); + testDisallowXRP(features); + testDstTag(features); + testDepositAuth(features); + testMultiple(features); + testAccountChannelsRPC(features); + testAccountChannelsRPCMarkers(features); + testAccountChannelsRPCSenderOnly(features); + testAuthVerifyRPC(features); + testOptionalFields(features); + testMalformedPK(features); + testMetaAndOwnership(features); + testAccountDelete(features); + testUsingTickets(features); + testICSimple(features); + testICCancelAfter(features); + testICSettleDelay(features); + testICExpiration(features); + testICCloseDry(features); + testICDefaultAmount(features); + testICDstTag(features); + testICDepositAuth(features); + testICMultiple(features); /* - // testICAccountChannelsRPC(); - // testICAccountChannelsRPCMarkers(); - // testICAccountChannelsRPCSenderOnly(); - // testICAuthVerifyRPC(); + // testICAccountChannelsRPC(features); + // testICAccountChannelsRPCMarkers(features); + // testICAccountChannelsRPCSenderOnly(features); + // testICAuthVerifyRPC(features); */ - testICOptionalFields(); - testICMalformedPK(); - testICMetaAndOwnership(); - // testICAccountDelete(); - testICUsingTickets(); - testICAutoTL(); + testICOptionalFields(features); + testICMalformedPK(features); + testICMetaAndOwnership(features); + // testICAccountDelete(features); + testICUsingTickets(features); + testICAutoTL(features); + } + +public: + void + run() override + { + using namespace test::jtx; + FeatureBitset const all{supported_amendments()}; + testWithFeats(all); } };