mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Minimize use of jtx::with_only_features (RIPD-1515):
In order to automatically run unit tests with newly created amendments, prefer to start with jtx::supported_features() and then subtract unwanted features. These changes identified a few bugs that were hiding in amendments. One of those bugs, in FlowCross, is not yet fixed. By uncommenting the test in CrossingLimits_test.cpp you can see failures relating to that bug. Since FlowCross is not yet enabled on the network we can fix the bug at our convenience.
This commit is contained in:
@@ -25,10 +25,10 @@ namespace test {
|
||||
|
||||
struct BookDirs_test : public beast::unit_test::suite
|
||||
{
|
||||
void test_bookdir(std::initializer_list<uint256> fs)
|
||||
void test_bookdir(FeatureBitset features)
|
||||
{
|
||||
using namespace jtx;
|
||||
Env env(*this, with_only_features(fs));
|
||||
Env env(*this, features);
|
||||
auto gw = Account("gw");
|
||||
auto USD = gw["USD"];
|
||||
env.fund(XRP(1000000), "alice", "bob", "gw");
|
||||
@@ -94,9 +94,12 @@ struct BookDirs_test : public beast::unit_test::suite
|
||||
|
||||
void run() override
|
||||
{
|
||||
test_bookdir({});
|
||||
test_bookdir({featureFlow, fix1373});
|
||||
test_bookdir({featureFlow, fix1373, featureFlowCross});
|
||||
using namespace jtx;
|
||||
test_bookdir(
|
||||
supported_features_except (featureFlow, fix1373, featureFlowCross));
|
||||
test_bookdir(
|
||||
supported_features_except ( featureFlowCross));
|
||||
test_bookdir(supported_amendments ());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ struct Directory_test : public beast::unit_test::suite
|
||||
{
|
||||
testcase ("Directory Ordering (with 'SortedDirectories' amendment)");
|
||||
|
||||
Env env(*this, with_only_features(featureSortedDirectories));
|
||||
Env env(*this);
|
||||
env.fund(XRP(10000000), alice, gw);
|
||||
|
||||
for (std::size_t i = 1; i <= 400; ++i)
|
||||
@@ -184,8 +184,7 @@ struct Directory_test : public beast::unit_test::suite
|
||||
|
||||
beast::xor_shift_engine eng;
|
||||
|
||||
Env env(*this,
|
||||
with_only_features(featureSortedDirectories, featureMultiSign));
|
||||
Env env(*this);
|
||||
|
||||
env.fund(XRP(1000000), alice, charlie, gw);
|
||||
env.close();
|
||||
@@ -289,7 +288,7 @@ struct Directory_test : public beast::unit_test::suite
|
||||
testcase("RIPD-1353 Empty Offer Directories");
|
||||
|
||||
using namespace jtx;
|
||||
Env env(*this, with_only_features(featureSortedDirectories));
|
||||
Env env(*this);
|
||||
|
||||
auto const gw = Account{"gateway"};
|
||||
auto const alice = Account{"alice"};
|
||||
@@ -349,7 +348,7 @@ struct Directory_test : public beast::unit_test::suite
|
||||
testcase("Empty Chain on Delete");
|
||||
|
||||
using namespace jtx;
|
||||
Env env(*this, with_only_features(featureSortedDirectories));
|
||||
Env env(*this);
|
||||
|
||||
auto const gw = Account{"gateway"};
|
||||
auto const alice = Account{"alice"};
|
||||
|
||||
@@ -55,12 +55,12 @@ class PaymentSandbox_test : public beast::unit_test::suite
|
||||
2) New code: Path is dry because sender does not have any
|
||||
GW1 to spend until the end of the transaction.
|
||||
*/
|
||||
void testSelfFunding (std::initializer_list<uint256> fs)
|
||||
void testSelfFunding (FeatureBitset features)
|
||||
{
|
||||
testcase ("selfFunding");
|
||||
|
||||
using namespace jtx;
|
||||
Env env (*this, with_only_features(fs));
|
||||
Env env (*this, features);
|
||||
Account const gw1 ("gw1");
|
||||
Account const gw2 ("gw2");
|
||||
Account const snd ("snd");
|
||||
@@ -96,12 +96,12 @@ class PaymentSandbox_test : public beast::unit_test::suite
|
||||
env.require (balance ("rcv", USD_gw2 (2)));
|
||||
}
|
||||
|
||||
void testSubtractCredits (std::initializer_list<uint256> fs)
|
||||
void testSubtractCredits (FeatureBitset features)
|
||||
{
|
||||
testcase ("subtractCredits");
|
||||
|
||||
using namespace jtx;
|
||||
Env env (*this, with_only_features(fs));
|
||||
Env env (*this, features);
|
||||
Account const gw1 ("gw1");
|
||||
Account const gw2 ("gw2");
|
||||
Account const alice ("alice");
|
||||
@@ -256,7 +256,7 @@ class PaymentSandbox_test : public beast::unit_test::suite
|
||||
}
|
||||
}
|
||||
|
||||
void testTinyBalance (std::initializer_list<uint256> fs)
|
||||
void testTinyBalance (FeatureBitset features)
|
||||
{
|
||||
testcase ("Tiny balance");
|
||||
|
||||
@@ -266,7 +266,7 @@ class PaymentSandbox_test : public beast::unit_test::suite
|
||||
|
||||
using namespace jtx;
|
||||
|
||||
Env env (*this, with_only_features(fs));
|
||||
Env env (*this, features);
|
||||
|
||||
Account const gw ("gw");
|
||||
Account const alice ("alice");
|
||||
@@ -293,7 +293,7 @@ class PaymentSandbox_test : public beast::unit_test::suite
|
||||
}
|
||||
}
|
||||
|
||||
void testReserve(std::initializer_list<uint256> fs)
|
||||
void testReserve(FeatureBitset features)
|
||||
{
|
||||
testcase ("Reserve");
|
||||
using namespace jtx;
|
||||
@@ -312,7 +312,7 @@ class PaymentSandbox_test : public beast::unit_test::suite
|
||||
return env.current ()->fees ().accountReserve (count);
|
||||
};
|
||||
|
||||
Env env (*this, with_only_features(fs));
|
||||
Env env (*this, features);
|
||||
|
||||
Account const alice ("alice");
|
||||
env.fund (reserve(env, 1), alice);
|
||||
@@ -333,14 +333,14 @@ class PaymentSandbox_test : public beast::unit_test::suite
|
||||
}
|
||||
}
|
||||
|
||||
void testBalanceHook(std::initializer_list<uint256> fs)
|
||||
void testBalanceHook(FeatureBitset features)
|
||||
{
|
||||
// Make sure the Issue::Account returned by PAymentSandbox::balanceHook
|
||||
// is correct.
|
||||
testcase ("balanceHook");
|
||||
|
||||
using namespace jtx;
|
||||
Env env (*this, with_only_features(fs));
|
||||
Env env (*this, features);
|
||||
|
||||
Account const gw ("gw");
|
||||
auto const USD = gw["USD"];
|
||||
@@ -370,16 +370,19 @@ class PaymentSandbox_test : public beast::unit_test::suite
|
||||
public:
|
||||
void run ()
|
||||
{
|
||||
auto testAll = [this](std::initializer_list<uint256> fs) {
|
||||
testSelfFunding(fs);
|
||||
testSubtractCredits(fs);
|
||||
testTinyBalance(fs);
|
||||
testReserve(fs);
|
||||
testBalanceHook(fs);
|
||||
auto testAll = [this](FeatureBitset features) {
|
||||
testSelfFunding(features);
|
||||
testSubtractCredits(features);
|
||||
testTinyBalance(features);
|
||||
testReserve(features);
|
||||
testBalanceHook(features);
|
||||
};
|
||||
testAll({});
|
||||
testAll({featureFlow, fix1373});
|
||||
testAll({featureFlow, fix1373, featureFlowCross});
|
||||
using namespace jtx;
|
||||
testAll(
|
||||
supported_features_except (featureFlow, fix1373, featureFlowCross));
|
||||
testAll(
|
||||
supported_features_except ( featureFlowCross));
|
||||
testAll(supported_amendments());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user