Refactor FeatureBitset:

* Remove composite helper functions
* Add set difference and Bitset/uint256 operators
* Convert tests to use new feature bitset set difference operator
This commit is contained in:
seelabs
2017-11-28 13:34:11 -05:00
parent 3523cee63d
commit e8d02c1333
29 changed files with 400 additions and 354 deletions

View File

@@ -237,7 +237,7 @@ public:
{
testcase ("Setting transfer rate (without fix1201)");
doTests (supported_features_except(fix1201),
doTests (supported_amendments().reset(fix1201),
{
{ 1.0, tesSUCCESS, 1.0 },
{ 1.1, tesSUCCESS, 1.1 },
@@ -290,16 +290,17 @@ public:
};
// Test gateway with allowed transfer rates
runTest (Env{*this, supported_features_except(fix1201)}, 1.02);
runTest (Env{*this, supported_features_except(fix1201)}, 1);
runTest (Env{*this, supported_features_except(fix1201)}, 2);
runTest (Env{*this, supported_features_except(fix1201)}, 2.1);
auto const noFix1201 = supported_amendments().reset(fix1201);
runTest (Env{*this, noFix1201}, 1.02);
runTest (Env{*this, noFix1201}, 1);
runTest (Env{*this, noFix1201}, 2);
runTest (Env{*this, noFix1201}, 2.1);
runTest (Env{*this, supported_amendments()}, 1.02);
runTest (Env{*this, supported_amendments()}, 2);
// Test gateway when amendment is set after transfer rate
{
Env env (*this, supported_features_except(fix1201));
Env env (*this, noFix1201);
Account const alice ("alice");
Account const bob ("bob");
Account const gw ("gateway");
@@ -330,7 +331,7 @@ public:
{
using namespace test::jtx;
std::unique_ptr<Env> penv {
withFeatures ? new Env(*this) : new Env(*this, no_features)};
withFeatures ? new Env(*this) : new Env(*this, FeatureBitset{})};
Env& env = *penv;
Account const alice ("alice");
env.fund(XRP(10000), alice);

View File

@@ -116,7 +116,7 @@ class Feature_test : public beast::unit_test::suite
using namespace test::jtx;
Env env {*this,
with_only_features(featureEscrow, featureCryptoConditions)};
FeatureBitset(featureEscrow, featureCryptoConditions)};
auto jrr = env.rpc("feature") [jss::result];
if(! BEAST_EXPECT(jrr.isMember(jss::features)))
@@ -216,7 +216,7 @@ class Feature_test : public beast::unit_test::suite
using namespace test::jtx;
Env env {*this,
with_only_features(featureCryptoConditions)};
FeatureBitset(featureCryptoConditions)};
auto jrr = env.rpc("feature", "CryptoConditions") [jss::result];
if(! BEAST_EXPECTS(jrr[jss::status] == jss::success, "status"))

View File

@@ -154,11 +154,10 @@ public:
run() override
{
using namespace jtx;
testGWB(
supported_features_except (featureFlow, fix1373, featureFlowCross));
testGWB(
supported_features_except ( featureFlowCross));
testGWB(supported_amendments());
auto const sa = supported_amendments();
testGWB(sa - featureFlow - fix1373 - featureFlowCross);
testGWB(sa - featureFlowCross);
testGWB(sa);
}
};

View File

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

View File

@@ -267,8 +267,9 @@ public:
// Put a bunch of different LedgerEntryTypes into a ledger
using namespace test::jtx;
using namespace std::chrono;
Env env { *this, envconfig(validator, ""),
supported_features_plus(featureTickets) };
Env env{*this,
envconfig(validator, ""),
supported_amendments().set(featureTickets)};
Account const gw { "gateway" };
auto const USD = gw["USD"];

View File

@@ -286,7 +286,7 @@ class LedgerRPC_test : public beast::unit_test::suite
void testLookupLedger()
{
using namespace test::jtx;
Env env {*this, no_features}; // hashes requested below assume
Env env {*this, FeatureBitset{}}; // hashes requested below assume
//no amendments
env.fund(XRP(10000), "alice");
env.close();

View File

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

View File

@@ -218,13 +218,11 @@ public:
testDefaultRipple(features);
};
using namespace jtx;
withFeatsTests(
supported_features_except (featureFlow, fix1373, featureFlowCross));
withFeatsTests(
supported_features_except ( fix1373, featureFlowCross));
withFeatsTests(
supported_features_except ( featureFlowCross));
withFeatsTests(supported_amendments());
auto const sa = supported_amendments();
withFeatsTests(sa - featureFlow - fix1373 - featureFlowCross);
withFeatsTests(sa - fix1373 - featureFlowCross);
withFeatsTests(sa - featureFlowCross);
withFeatsTests(sa);
}
};