Unit tests don't enable Tickets or SHAMapV2 by default:

Both Tickets and SHAMapV2 have been around for a while and don't
look like they will be enabled on the network soon.  So they are
removed from the supportedAmendments list.  This prevents Env
from automatically testing with Tickets or SHAMapV2 enabled,
although testing with those features can still be explicitly
specified.

Drive-by cleanups:

o supportedAmendments() returns a const reference rather than
  a fresh vector on each call.

o supportedAmendments() implementation moved from Amendments.cpp
  to Feature.cpp.  Amendments.cpp deleted.

o supportedAmendments() declared in Feature.h.  All other
  declarations deleted.

o preEnabledAmendments() removed, since it was empty and only
  used in one place.  It will be easy to re-add when it is needed.

o jtx::all_features_except() renamed to
  jtx::supported_features_except(), which is more descriptive.

o jtx::all_amendments() renamed to jxt::supported_amendments()

o jtx::with_features() renamed to with_only_features()

o Env_test.cpp adjusted since featureTickets is no longer
  automatically enabled for unit tests.
This commit is contained in:
Scott Schurr
2017-08-03 16:26:40 -07:00
committed by seelabs
parent 07e3f81b76
commit feb7582aca
34 changed files with 282 additions and 345 deletions

View File

@@ -82,7 +82,7 @@ struct Flow_test : public beast::unit_test::suite
auto const USD = gw["USD"];
{
// Pay USD, trivial path
Env env (*this, with_features(fs));
Env env (*this, with_only_features(fs));
env.fund (XRP (10000), alice, bob, gw);
env.trust (USD (1000), alice, bob);
@@ -92,7 +92,7 @@ struct Flow_test : public beast::unit_test::suite
}
{
// XRP transfer
Env env (*this, with_features(fs));
Env env (*this, with_only_features(fs));
env.fund (XRP (10000), alice, bob);
env (pay (alice, bob, XRP (100)));
@@ -101,7 +101,7 @@ struct Flow_test : public beast::unit_test::suite
}
{
// Partial payments
Env env (*this, with_features(fs));
Env env (*this, with_only_features(fs));
env.fund (XRP (10000), alice, bob, gw);
env.trust (USD (1000), alice, bob);
@@ -115,7 +115,7 @@ struct Flow_test : public beast::unit_test::suite
}
{
// Pay by rippling through accounts, use path finder
Env env (*this, with_features(fs));
Env env (*this, with_only_features(fs));
env.fund (XRP (10000), alice, bob, carol, dan);
env.trust (USDA (10), bob);
@@ -130,7 +130,7 @@ struct Flow_test : public beast::unit_test::suite
{
// Pay by rippling through accounts, specify path
// and charge a transfer fee
Env env (*this, with_features(fs));
Env env (*this, with_only_features(fs));
env.fund (XRP (10000), alice, bob, carol, dan);
env.trust (USDA (10), bob);
@@ -148,7 +148,7 @@ struct Flow_test : public beast::unit_test::suite
{
// Pay by rippling through accounts, specify path and transfer fee
// Test that the transfer fee is not charged when alice issues
Env env (*this, with_features(fs));
Env env (*this, with_only_features(fs));
env.fund (XRP (10000), alice, bob, carol, dan);
env.trust (USDA (10), bob);
@@ -164,7 +164,7 @@ struct Flow_test : public beast::unit_test::suite
{
// test best quality path is taken
// Paths: A->B->D->E ; A->C->D->E
Env env (*this, with_features(fs));
Env env (*this, with_only_features(fs));
env.fund (XRP (10000), alice, bob, carol, dan, erin);
env.trust (USDA (10), bob, carol);
@@ -185,7 +185,7 @@ struct Flow_test : public beast::unit_test::suite
}
{
// Limit quality
Env env (*this, with_features(fs));
Env env (*this, with_only_features(fs));
env.fund (XRP (10000), alice, bob, carol);
env.trust (USDA (10), bob);
@@ -222,7 +222,7 @@ struct Flow_test : public beast::unit_test::suite
if (!hasFeature(featureFlow, fs) && bobDanQIn < 100 &&
bobAliceQOut < 100)
continue; // Bug in flow v1
Env env(*this, with_features(fs));
Env env(*this, with_only_features(fs));
env.fund(XRP(10000), alice, bob, carol, dan);
env(trust(bob, USDD(100)), qualityInPercent(bobDanQIn));
env(trust(bob, USDA(100)), qualityOutPercent(bobAliceQOut));
@@ -245,7 +245,7 @@ struct Flow_test : public beast::unit_test::suite
// bob -> alice -> carol; vary carolAliceQIn
for (auto carolAliceQIn : {80, 100, 120})
{
Env env(*this, with_features(fs));
Env env(*this, with_only_features(fs));
env.fund(XRP(10000), alice, bob, carol);
env(trust(bob, USDA(10)));
env(trust(carol, USDA(10)), qualityInPercent(carolAliceQIn));
@@ -261,7 +261,7 @@ struct Flow_test : public beast::unit_test::suite
// bob -> alice -> carol; bobAliceQOut varies.
for (auto bobAliceQOut : {80, 100, 120})
{
Env env(*this, with_features(fs));
Env env(*this, with_only_features(fs));
env.fund(XRP(10000), alice, bob, carol);
env(trust(bob, USDA(10)), qualityOutPercent(bobAliceQOut));
env(trust(carol, USDA(10)));
@@ -290,7 +290,7 @@ struct Flow_test : public beast::unit_test::suite
{
// simple IOU/IOU offer
Env env (*this, with_features(fs));
Env env (*this, with_only_features(fs));
env.fund (XRP (10000), alice, bob, carol, gw);
env.trust (USD (1000), alice, bob, carol);
@@ -311,7 +311,7 @@ struct Flow_test : public beast::unit_test::suite
}
{
// simple IOU/XRP XRP/IOU offer
Env env (*this, with_features(fs));
Env env (*this, with_only_features(fs));
env.fund (XRP (10000), alice, bob, carol, gw);
env.trust (USD (1000), alice, bob, carol);
@@ -335,7 +335,7 @@ struct Flow_test : public beast::unit_test::suite
}
{
// simple XRP -> USD through offer and sendmax
Env env (*this, with_features(fs));
Env env (*this, with_only_features(fs));
env.fund (XRP (10000), alice, bob, carol, gw);
env.trust (USD (1000), alice, bob, carol);
@@ -356,7 +356,7 @@ struct Flow_test : public beast::unit_test::suite
}
{
// simple USD -> XRP through offer and sendmax
Env env (*this, with_features(fs));
Env env (*this, with_only_features(fs));
env.fund (XRP (10000), alice, bob, carol, gw);
env.trust (USD (1000), alice, bob, carol);
@@ -377,7 +377,7 @@ struct Flow_test : public beast::unit_test::suite
}
{
// test unfunded offers are removed when payment succeeds
Env env (*this, with_features(fs));
Env env (*this, with_only_features(fs));
env.fund (XRP (10000), alice, bob, carol, gw);
env.trust (USD (1000), alice, bob, carol);
@@ -423,7 +423,7 @@ struct Flow_test : public beast::unit_test::suite
// offer. When the payment fails `flow` should return the unfunded
// offer. This test is intentionally similar to the one that removes
// unfunded offers when the payment succeeds.
Env env (*this, with_features(fs));
Env env (*this, with_only_features(fs));
env.fund (XRP (10000), alice, bob, carol, gw);
env.trust (USD (1000), alice, bob, carol);
@@ -498,7 +498,7 @@ struct Flow_test : public beast::unit_test::suite
// Without limits, the 0.4 USD would produce 1000 EUR in the forward
// pass. This test checks that the payment produces 1 EUR, as expected.
Env env (*this, with_features (fs));
Env env (*this, with_only_features (fs));
auto const closeTime = STAmountSO::soTime2 +
100 * env.closed ()->info ().closeTimeResolution;
@@ -541,7 +541,7 @@ struct Flow_test : public beast::unit_test::suite
{
// Simple payment through a gateway with a
// transfer rate
Env env (*this, with_features(fs));
Env env (*this, with_only_features(fs));
env.fund (XRP (10000), alice, bob, carol, gw);
env(rate(gw, 1.25));
@@ -553,7 +553,7 @@ struct Flow_test : public beast::unit_test::suite
}
{
// transfer rate is not charged when issuer is src or dst
Env env (*this, with_features(fs));
Env env (*this, with_only_features(fs));
env.fund (XRP (10000), alice, bob, carol, gw);
env(rate(gw, 1.25));
@@ -565,7 +565,7 @@ struct Flow_test : public beast::unit_test::suite
}
{
// transfer fee on an offer
Env env (*this, with_features(fs));
Env env (*this, with_only_features(fs));
env.fund (XRP (10000), alice, bob, carol, gw);
env(rate(gw, 1.25));
@@ -583,7 +583,7 @@ struct Flow_test : public beast::unit_test::suite
{
// Transfer fee two consecutive offers
Env env (*this, with_features(fs));
Env env (*this, with_only_features(fs));
env.fund (XRP (10000), alice, bob, carol, gw);
env(rate(gw, 1.25));
@@ -606,7 +606,7 @@ struct Flow_test : public beast::unit_test::suite
{
// First pass through a strand redeems, second pass issues, no offers
// limiting step is not an endpoint
Env env (*this, with_features(fs));
Env env (*this, with_only_features(fs));
auto const USDA = alice["USD"];
auto const USDB = bob["USD"];
@@ -626,7 +626,7 @@ struct Flow_test : public beast::unit_test::suite
{
// First pass through a strand redeems, second pass issues, through an offer
// limiting step is not an endpoint
Env env (*this, with_features(fs));
Env env (*this, with_only_features(fs));
auto const USDA = alice["USD"];
auto const USDB = bob["USD"];
Account const dan ("dan");
@@ -653,7 +653,7 @@ struct Flow_test : public beast::unit_test::suite
{
// Offer where the owner is also the issuer, owner pays fee
Env env (*this, with_features(fs));
Env env (*this, with_only_features(fs));
env.fund (XRP (10000), alice, bob, gw);
env(rate(gw, 1.25));
@@ -668,7 +668,7 @@ struct Flow_test : public beast::unit_test::suite
if (!hasFeature(featureOwnerPaysFee, fs))
{
// Offer where the owner is also the issuer, sender pays fee
Env env (*this, with_features(fs));
Env env (*this, with_only_features(fs));
env.fund (XRP (10000), alice, bob, gw);
env(rate(gw, 1.25));
@@ -696,7 +696,7 @@ struct Flow_test : public beast::unit_test::suite
Account const bob ("bob");
Account const carol ("carol");
Env env (*this, with_features (fs));
Env env (*this, with_only_features (fs));
auto const closeTime = fix1141Time() +
100 * env.closed ()->info ().closeTimeResolution;
@@ -810,7 +810,7 @@ struct Flow_test : public beast::unit_test::suite
auto const USD = gw1["USD"];
auto const EUR = gw2["EUR"];
Env env (*this, with_features (fs));
Env env (*this, with_only_features (fs));
auto const closeTime =
fix1141Time () + 100 * env.closed ()->info ().closeTimeResolution;
@@ -884,7 +884,7 @@ struct Flow_test : public beast::unit_test::suite
auto const USD = gw1["USD"];
auto const EUR = gw2["EUR"];
Env env (*this, with_features (fs));
Env env (*this, with_only_features (fs));
auto const closeTime =
fix1141Time () + 100 * env.closed ()->info ().closeTimeResolution;
@@ -952,7 +952,7 @@ struct Flow_test : public beast::unit_test::suite
using namespace jtx;
Env env(*this, with_features(fs));
Env env(*this, with_only_features(fs));
// Need new behavior from `accountHolds`
auto const closeTime = fix1141Time() +
@@ -983,7 +983,7 @@ struct Flow_test : public beast::unit_test::suite
using namespace jtx;
{
// Test reverse
Env env(*this, with_features(fs));
Env env(*this, with_only_features(fs));
auto closeTime = fix1298Time();
if (withFix)
closeTime += env.closed()->info().closeTimeResolution;
@@ -1015,7 +1015,7 @@ struct Flow_test : public beast::unit_test::suite
}
{
// Test forward
Env env(*this, with_features(fs));
Env env(*this, with_only_features(fs));
auto closeTime = fix1298Time();
if (withFix)
closeTime += env.closed()->info().closeTimeResolution;
@@ -1055,7 +1055,7 @@ struct Flow_test : public beast::unit_test::suite
testcase("ReexecuteDirectStep");
using namespace jtx;
Env env(*this, with_features(fs));
Env env(*this, with_only_features(fs));
auto const alice = Account("alice");
auto const bob = Account("bob");
@@ -1111,7 +1111,7 @@ struct Flow_test : public beast::unit_test::suite
testcase("ripd1443");
using namespace jtx;
Env env(*this, with_features(featureFlow));
Env env(*this, with_only_features(featureFlow));
auto const timeDelta = env.closed ()->info ().closeTimeResolution;
auto const d = withFix ? 100*timeDelta : -100*timeDelta;
auto closeTime = fix1443Time() + d;
@@ -1164,7 +1164,7 @@ struct Flow_test : public beast::unit_test::suite
testcase("ripd1449");
using namespace jtx;
Env env(*this, with_features(featureFlow));
Env env(*this, with_only_features(featureFlow));
auto const timeDelta = env.closed ()->info ().closeTimeResolution;
auto const d = withFix ? 100*timeDelta : -100*timeDelta;
auto closeTime = fix1449Time() + d;
@@ -1210,7 +1210,7 @@ struct Flow_test : public beast::unit_test::suite
using namespace jtx;
Env env(*this, with_features (fs));
Env env(*this, with_only_features (fs));
auto const ann = Account("ann");
auto const gw = Account("gateway");
@@ -1244,7 +1244,7 @@ struct Flow_test : public beast::unit_test::suite
auto const alice = Account("alice");
Env env(*this, with_features(fs));
Env env(*this, with_only_features(fs));
env.fund(XRP(10000), alice);