Change features default behavior in Env (RIPD-1460):

Enable all supported amendments in Env by default. Rename `features()`
to `with_features()` and add `all_features_except()` to support feature
subsets in Env. Refactor internal feature handling based on a bitset.
This commit is contained in:
Mike Ellery
2017-05-01 16:03:44 -07:00
committed by seelabs
parent 3dfb4a13f1
commit 56946e8128
36 changed files with 749 additions and 367 deletions

View File

@@ -59,7 +59,7 @@ public:
void testSignerLists()
{
using namespace jtx;
Env env(*this, features(featureMultiSign));
Env env(*this, with_features(featureMultiSign));
Account const alice {"alice"};
env.fund(XRP(1000), alice);
@@ -165,7 +165,7 @@ public:
void testSignerListsV2()
{
using namespace jtx;
Env env(*this, features(featureMultiSign));
Env env(*this, with_features(featureMultiSign));
Account const alice {"alice"};
env.fund(XRP(1000), alice);

View File

@@ -223,10 +223,12 @@ public:
env(jt, ter(temBAD_TRANSFER_RATE));
}
void testBadInputs()
void testBadInputs(bool withFeatures)
{
using namespace test::jtx;
Env env(*this);
std::unique_ptr<Env> penv {
withFeatures ? new Env(*this) : new Env(*this, no_features)};
Env& env = *penv;
Account const alice ("alice");
env.fund(XRP(10000), alice);
@@ -259,13 +261,14 @@ public:
env(jt, ter(temINVALID_FLAG));
env(fset (alice, asfDisableMaster),
sig(alice), ter(tecNO_REGULAR_KEY));
sig(alice),
ter(withFeatures ? tecNO_ALTERNATIVE_KEY : tecNO_REGULAR_KEY));
}
void testRequireAuthWithDir()
{
using namespace test::jtx;
Env env(*this, features(featureMultiSign));
Env env(*this, with_features(featureMultiSign));
Account const alice ("alice");
Account const bob ("bob");
@@ -303,7 +306,8 @@ public:
testMessageKey();
testWalletID();
testEmailHash();
testBadInputs();
testBadInputs(true);
testBadInputs(false);
testRequireAuthWithDir();
testTransferRate();
}

View File

@@ -116,8 +116,7 @@ class Feature_test : public beast::unit_test::suite
using namespace test::jtx;
Env env {*this,
features(featureEscrow),
features(featureCryptoConditions)};
with_features(featureEscrow, featureCryptoConditions)};
// The amendment table has to be modified
// since that is what feature RPC actually checks
env.app().getAmendmentTable().enable(featureEscrow);
@@ -221,7 +220,7 @@ class Feature_test : public beast::unit_test::suite
using namespace test::jtx;
Env env {*this,
features(featureCryptoConditions)};
with_features(featureCryptoConditions)};
// The amendment table has to be modified
// since that is what feature RPC actually checks
env.app().getAmendmentTable().enable(featureCryptoConditions);

View File

@@ -34,7 +34,7 @@ public:
{
using namespace std::chrono_literals;
using namespace jtx;
Env env(*this, features(fs));
Env env(*this, with_features(fs));
// Gateway account and assets
Account const alice {"alice"};

View File

@@ -1942,7 +1942,7 @@ public:
.set("minimum_txn_in_ledger_standalone", "3");
return cfg;
}),
test::jtx::features(featureFeeEscalation)};
with_features(featureFeeEscalation)};
LoadFeeTrack const& feeTrack = env.app().getFeeTrack();
{
@@ -2254,7 +2254,7 @@ public:
// "b" (not in the ledger) is rDg53Haik2475DJx8bjMDSDPj4VX7htaMd.
// "c" (phantom signer) is rPcNzota6B8YBokhYtcTNqQVCngtbnWfux.
test::jtx::Env env(*this, test::jtx::features(featureMultiSign));
test::jtx::Env env(*this, test::jtx::with_features(featureMultiSign));
env.fund(test::jtx::XRP(100000), a, ed, g);
env.close();

View File

@@ -30,7 +30,7 @@ public:
void testMonitorRoot()
{
using namespace test::jtx;
Env env {*this};
Env env {*this, no_features};
Account const alice {"alice"};
env.fund(XRP(10000), alice);

View File

@@ -268,7 +268,7 @@ public:
using namespace test::jtx;
using namespace std::chrono;
Env env { *this, envconfig(validator, ""),
features(featureMultiSign, featureTickets,
with_features(featureMultiSign, featureTickets,
featureEscrow, featurePayChan) };
Account const gw { "gateway" };
auto const USD = gw["USD"];

View File

@@ -286,7 +286,8 @@ class LedgerRPC_test : public beast::unit_test::suite
void testLookupLedger()
{
using namespace test::jtx;
Env env { *this };
Env env {*this, no_features}; // hashes requested below assume
//no amendments
env.fund(XRP(10000), "alice");
env.close();
env.fund(XRP(10000), "bob");
@@ -476,7 +477,7 @@ class LedgerRPC_test : public beast::unit_test::suite
.set("minimum_txn_in_ledger_standalone", "3");
return cfg;
}),
features(featureFeeEscalation)};
with_features(featureFeeEscalation)};
Json::Value jv;
jv[jss::ledger_index] = "current";

View File

@@ -150,7 +150,8 @@ public:
void testEvolution()
{
using namespace test::jtx;
Env env { *this };
Env env {*this, no_features}; //the hashes being checked below assume
//no amendments
Account const gw { "gateway" };
auto const USD = gw["USD"];
env.fund(XRP(100000), gw);

View File

@@ -72,7 +72,7 @@ public:
testcase("Set noripple on a line with negative balance");
using namespace jtx;
Env env(*this, features(fs));
Env env(*this, with_features(fs));
auto const gw = Account("gateway");
auto const alice = Account("alice");
@@ -118,7 +118,7 @@ public:
testcase("pairwise NoRipple");
using namespace jtx;
Env env(*this, features(fs));
Env env(*this, with_features(fs));
auto const alice = Account("alice");
auto const bob = Account("bob");
@@ -155,7 +155,7 @@ public:
testcase("Set default ripple on an account and check new trustlines");
using namespace jtx;
Env env(*this, features(fs));
Env env(*this, with_features(fs));
auto const gw = Account("gateway");
auto const alice = Account("alice");