mirror of
https://github.com/XRPLF/rippled.git
synced 2026-10-26 21:47:06 +00:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
807e763bbc | ||
|
|
a903cab4c8 | ||
|
|
d560d8be6d |
No files matched your search
@@ -846,7 +846,7 @@ to_string(Number const& amount)
|
||||
bool const negative = amount.negative_;
|
||||
|
||||
// Use scientific notation for exponents that are too small or too large
|
||||
auto const rangeLog = Number::mantissaLog();
|
||||
auto rangeLog = Number::mantissaLog();
|
||||
if (((exponent != 0) && ((exponent < -(rangeLog + 10)) || (exponent > -(rangeLog - 10)))))
|
||||
{
|
||||
while (mantissa != 0 && mantissa % 10 == 0 && exponent < Number::maxExponent)
|
||||
|
||||
@@ -105,7 +105,9 @@ AMMClawback::preclaim(PreclaimContext const& ctx)
|
||||
// permission
|
||||
if (((issuerFlagsIn & lsfAllowTrustLineClawback) == 0u) ||
|
||||
((issuerFlagsIn & lsfNoFreeze) != 0u))
|
||||
return tesSUCCESS;
|
||||
{
|
||||
return tecNO_PERMISSION;
|
||||
}
|
||||
}
|
||||
|
||||
auto const checkClawAsset = [&](Asset const asset) -> bool {
|
||||
|
||||
@@ -10,14 +10,14 @@ namespace test {
|
||||
class AMMClawback_test : public beast::unit_test::suite
|
||||
{
|
||||
void
|
||||
testInvalidRequest()
|
||||
testInvalidRequest(FeatureBitset features)
|
||||
{
|
||||
testcase("test invalid request");
|
||||
using namespace jtx;
|
||||
|
||||
// Test if holder does not exist.
|
||||
{
|
||||
Env env(*this);
|
||||
Env env(*this, features);
|
||||
Account const gw{"gateway"};
|
||||
Account const alice{"alice"};
|
||||
env.fund(XRP(100000), gw, alice);
|
||||
@@ -42,7 +42,7 @@ class AMMClawback_test : public beast::unit_test::suite
|
||||
// Test if asset pair provided does not exist. This should
|
||||
// return terNO_AMM error.
|
||||
{
|
||||
Env env(*this);
|
||||
Env env(*this, features);
|
||||
Account const gw{"gateway"};
|
||||
Account const alice{"alice"};
|
||||
env.fund(XRP(100000), gw, alice);
|
||||
@@ -74,7 +74,7 @@ class AMMClawback_test : public beast::unit_test::suite
|
||||
// Test if the issuer field and holder field is the same. This should
|
||||
// return temMALFORMED error.
|
||||
{
|
||||
Env env(*this);
|
||||
Env env(*this, features);
|
||||
Account const gw{"gateway"};
|
||||
Account const alice{"alice"};
|
||||
env.fund(XRP(10000), gw, alice);
|
||||
@@ -102,7 +102,7 @@ class AMMClawback_test : public beast::unit_test::suite
|
||||
|
||||
// Test if the Asset field matches the Account field.
|
||||
{
|
||||
Env env(*this);
|
||||
Env env(*this, features);
|
||||
Account const gw{"gateway"};
|
||||
Account const alice{"alice"};
|
||||
env.fund(XRP(10000), gw, alice);
|
||||
@@ -130,7 +130,7 @@ class AMMClawback_test : public beast::unit_test::suite
|
||||
|
||||
// Test if the Amount field matches the Asset field.
|
||||
{
|
||||
Env env(*this);
|
||||
Env env(*this, features);
|
||||
Account const gw{"gateway"};
|
||||
Account const alice{"alice"};
|
||||
env.fund(XRP(10000), gw, alice);
|
||||
@@ -159,7 +159,7 @@ class AMMClawback_test : public beast::unit_test::suite
|
||||
|
||||
// Test if the Amount is invalid, which is less than zero.
|
||||
{
|
||||
Env env(*this);
|
||||
Env env(*this, features);
|
||||
Account const gw{"gateway"};
|
||||
Account const alice{"alice"};
|
||||
env.fund(XRP(10000), gw, alice);
|
||||
@@ -192,7 +192,7 @@ class AMMClawback_test : public beast::unit_test::suite
|
||||
// Test if the issuer did not set asfAllowTrustLineClawback, AMMClawback
|
||||
// transaction is prohibited.
|
||||
{
|
||||
Env env(*this);
|
||||
Env env(*this, features);
|
||||
Account const gw{"gateway"};
|
||||
Account const alice{"alice"};
|
||||
env.fund(XRP(10000), gw, alice);
|
||||
@@ -216,7 +216,7 @@ class AMMClawback_test : public beast::unit_test::suite
|
||||
|
||||
// Test invalid flag.
|
||||
{
|
||||
Env env(*this);
|
||||
Env env(*this, features);
|
||||
Account const gw{"gateway"};
|
||||
Account const alice{"alice"};
|
||||
env.fund(XRP(10000), gw, alice);
|
||||
@@ -244,7 +244,7 @@ class AMMClawback_test : public beast::unit_test::suite
|
||||
// Test if tfClawTwoAssets is set when the two assets in the AMM pool
|
||||
// are not issued by the same issuer.
|
||||
{
|
||||
Env env(*this);
|
||||
Env env(*this, features);
|
||||
Account const gw{"gateway"};
|
||||
Account const alice{"alice"};
|
||||
env.fund(XRP(10000), gw, alice);
|
||||
@@ -275,7 +275,7 @@ class AMMClawback_test : public beast::unit_test::suite
|
||||
|
||||
// Test clawing back XRP is being prohibited.
|
||||
{
|
||||
Env env(*this);
|
||||
Env env(*this, features);
|
||||
Account const gw{"gateway"};
|
||||
Account const alice{"alice"};
|
||||
env.fund(XRP(1000000), gw, alice);
|
||||
@@ -2491,10 +2491,14 @@ class AMMClawback_test : public beast::unit_test::suite
|
||||
FeatureBitset const all =
|
||||
jtx::testable_amendments() - featureSingleAssetVault - featureLendingProtocol;
|
||||
|
||||
testInvalidRequest();
|
||||
testInvalidRequest(all);
|
||||
testInvalidRequest(all - featureMPTokensV2);
|
||||
testFeatureDisabled(all - featureAMMClawback);
|
||||
for (auto const& features :
|
||||
{all - fixAMMv1_3 - fixAMMClawbackRounding, all - fixAMMClawbackRounding, all})
|
||||
{all - fixAMMv1_3 - fixAMMClawbackRounding - featureMPTokensV2,
|
||||
all - fixAMMClawbackRounding - featureMPTokensV2,
|
||||
all - featureMPTokensV2,
|
||||
all})
|
||||
{
|
||||
testAMMClawbackSpecificAmount(features);
|
||||
testAMMClawbackExceedBalance(features);
|
||||
|
||||
@@ -1303,13 +1303,12 @@ private:
|
||||
}
|
||||
|
||||
void
|
||||
testOffers()
|
||||
testOffers(FeatureBitset features)
|
||||
{
|
||||
using namespace jtx;
|
||||
// For now, just disable SAV entirely, which locks in the small Number
|
||||
// mantissas
|
||||
FeatureBitset const all{
|
||||
testable_amendments() - featureSingleAssetVault - featureLendingProtocol};
|
||||
FeatureBitset const all{features - featureSingleAssetVault - featureLendingProtocol};
|
||||
|
||||
testRmFundedOffer(all);
|
||||
testRmFundedOffer(all - fixAMMv1_1 - fixAMMv1_3);
|
||||
@@ -1340,12 +1339,12 @@ private:
|
||||
}
|
||||
|
||||
void
|
||||
path_find_consume_all()
|
||||
path_find_consume_all(FeatureBitset features)
|
||||
{
|
||||
testcase("path find consume all");
|
||||
using namespace jtx;
|
||||
|
||||
Env env = pathTestEnv();
|
||||
Env env = pathTestEnv(features);
|
||||
env.fund(XRP(100'000'250), alice);
|
||||
fund(env, gw, {carol, bob}, {USD(100)}, Fund::All);
|
||||
fund(env, gw, {alice}, {USD(100)}, Fund::TokenOnly);
|
||||
@@ -1370,12 +1369,12 @@ private:
|
||||
// bob will hold gateway AUD
|
||||
// alice pays bob gateway AUD using XRP
|
||||
void
|
||||
via_offers_via_gateway()
|
||||
via_offers_via_gateway(FeatureBitset features)
|
||||
{
|
||||
testcase("via gateway");
|
||||
using namespace jtx;
|
||||
|
||||
Env env = pathTestEnv();
|
||||
Env env = pathTestEnv(features);
|
||||
auto const AUD = gw["AUD"];
|
||||
env.fund(XRP(10'000), alice, bob, carol, gw);
|
||||
env.close();
|
||||
@@ -1395,14 +1394,14 @@ private:
|
||||
}
|
||||
|
||||
void
|
||||
receive_max()
|
||||
receive_max(FeatureBitset features)
|
||||
{
|
||||
testcase("Receive max");
|
||||
using namespace jtx;
|
||||
auto const charlie = Account("charlie");
|
||||
{
|
||||
// XRP -> IOU receive max
|
||||
Env env = pathTestEnv();
|
||||
Env env = pathTestEnv(features);
|
||||
fund(env, gw, {alice, bob, charlie}, {USD(11)}, Fund::All);
|
||||
AMM const ammCharlie(env, charlie, XRP(10), USD(11));
|
||||
auto [st, sa, da] = find_paths(env, alice, bob, USD(-1), XRP(1).value());
|
||||
@@ -1418,7 +1417,7 @@ private:
|
||||
}
|
||||
{
|
||||
// IOU -> XRP receive max
|
||||
Env env = pathTestEnv();
|
||||
Env env = pathTestEnv(features);
|
||||
fund(env, gw, {alice, bob, charlie}, {USD(11)}, Fund::All);
|
||||
AMM const ammCharlie(env, charlie, XRP(11), USD(10));
|
||||
env.close();
|
||||
@@ -1436,11 +1435,11 @@ private:
|
||||
}
|
||||
|
||||
void
|
||||
path_find_01()
|
||||
path_find_01(FeatureBitset features)
|
||||
{
|
||||
testcase("Path Find: XRP -> XRP and XRP -> IOU");
|
||||
using namespace jtx;
|
||||
Env env = pathTestEnv();
|
||||
Env env = pathTestEnv(features);
|
||||
Account const A1{"A1"};
|
||||
Account const A2{"A2"};
|
||||
Account const A3{"A3"};
|
||||
@@ -1521,11 +1520,11 @@ private:
|
||||
}
|
||||
|
||||
void
|
||||
path_find_02()
|
||||
path_find_02(FeatureBitset features)
|
||||
{
|
||||
testcase("Path Find: non-XRP -> XRP");
|
||||
using namespace jtx;
|
||||
Env env = pathTestEnv();
|
||||
Env env = pathTestEnv(features);
|
||||
Account const A1{"A1"};
|
||||
Account const A2{"A2"};
|
||||
Account const G3{"G3"};
|
||||
@@ -1557,11 +1556,11 @@ private:
|
||||
}
|
||||
|
||||
void
|
||||
path_find_05()
|
||||
path_find_05(FeatureBitset features)
|
||||
{
|
||||
testcase("Path Find: non-XRP -> non-XRP, same currency");
|
||||
using namespace jtx;
|
||||
Env env = pathTestEnv();
|
||||
Env env = pathTestEnv(features);
|
||||
Account const A1{"A1"};
|
||||
Account const A2{"A2"};
|
||||
Account const A3{"A3"};
|
||||
@@ -1687,11 +1686,11 @@ private:
|
||||
}
|
||||
|
||||
void
|
||||
path_find_06()
|
||||
path_find_06(FeatureBitset features)
|
||||
{
|
||||
testcase("Path Find: non-XRP -> non-XRP, same currency");
|
||||
using namespace jtx;
|
||||
Env env = pathTestEnv();
|
||||
Env env = pathTestEnv(features);
|
||||
Account const A1{"A1"};
|
||||
Account const A2{"A2"};
|
||||
Account const A3{"A3"};
|
||||
@@ -3434,25 +3433,24 @@ private:
|
||||
}
|
||||
|
||||
void
|
||||
testPaths()
|
||||
testPaths(FeatureBitset features)
|
||||
{
|
||||
path_find_consume_all();
|
||||
via_offers_via_gateway();
|
||||
receive_max();
|
||||
path_find_01();
|
||||
path_find_02();
|
||||
path_find_05();
|
||||
path_find_06();
|
||||
path_find_consume_all(features);
|
||||
via_offers_via_gateway(features);
|
||||
receive_max(features);
|
||||
path_find_01(features);
|
||||
path_find_02(features);
|
||||
path_find_05(features);
|
||||
path_find_06(features);
|
||||
}
|
||||
|
||||
void
|
||||
testFlow()
|
||||
testFlow(FeatureBitset features)
|
||||
{
|
||||
using namespace jtx;
|
||||
// For now, just disable SAV entirely, which locks in the small Number
|
||||
// mantissas in the transaction engine
|
||||
FeatureBitset const all{
|
||||
testable_amendments() - featureSingleAssetVault - featureLendingProtocol};
|
||||
FeatureBitset const all{features - featureSingleAssetVault - featureLendingProtocol};
|
||||
|
||||
testFalseDry(all);
|
||||
testBookStep(all);
|
||||
@@ -3463,81 +3461,79 @@ private:
|
||||
}
|
||||
|
||||
void
|
||||
testCrossingLimits()
|
||||
testCrossingLimits(FeatureBitset features)
|
||||
{
|
||||
using namespace jtx;
|
||||
// For now, just disable SAV entirely, which locks in the small Number
|
||||
// mantissas in the transaction engine
|
||||
FeatureBitset const all{
|
||||
testable_amendments() - featureSingleAssetVault - featureLendingProtocol};
|
||||
FeatureBitset const all{features - featureSingleAssetVault - featureLendingProtocol};
|
||||
testStepLimit(all);
|
||||
testStepLimit(all - fixAMMv1_1 - fixAMMv1_3);
|
||||
}
|
||||
|
||||
void
|
||||
testDeliverMin()
|
||||
testDeliverMin(FeatureBitset features)
|
||||
{
|
||||
using namespace jtx;
|
||||
// For now, just disable SAV entirely, which locks in the small Number
|
||||
// mantissas in the transaction engine
|
||||
FeatureBitset const all{
|
||||
testable_amendments() - featureSingleAssetVault - featureLendingProtocol};
|
||||
FeatureBitset const all{features - featureSingleAssetVault - featureLendingProtocol};
|
||||
test_convert_all_of_an_asset(all);
|
||||
test_convert_all_of_an_asset(all - fixAMMv1_1 - fixAMMv1_3);
|
||||
}
|
||||
|
||||
void
|
||||
testDepositAuth()
|
||||
testDepositAuth(FeatureBitset features)
|
||||
{
|
||||
// For now, just disable SAV entirely, which locks in the small Number
|
||||
// mantissas in the transaction engine
|
||||
FeatureBitset const all{
|
||||
jtx::testable_amendments() - featureSingleAssetVault - featureLendingProtocol};
|
||||
FeatureBitset const all{features - featureSingleAssetVault - featureLendingProtocol};
|
||||
testPayment(all);
|
||||
testPayIOU();
|
||||
}
|
||||
|
||||
void
|
||||
testFreeze()
|
||||
testFreeze(FeatureBitset features)
|
||||
{
|
||||
using namespace test::jtx;
|
||||
// For now, just disable SAV entirely, which locks in the small Number
|
||||
// mantissas in the transaction engine
|
||||
FeatureBitset const sa{
|
||||
testable_amendments() - featureSingleAssetVault - featureLendingProtocol};
|
||||
FeatureBitset const sa{features - featureSingleAssetVault - featureLendingProtocol};
|
||||
testRippleState(sa);
|
||||
testGlobalFreeze(sa);
|
||||
testOffersWhenFrozen(sa);
|
||||
}
|
||||
|
||||
void
|
||||
testMultisign()
|
||||
testMultisign(FeatureBitset features)
|
||||
{
|
||||
testTxMultisign(jtx::testable_amendments());
|
||||
testTxMultisign(features);
|
||||
}
|
||||
|
||||
void
|
||||
testPayStrand()
|
||||
testPayStrand(FeatureBitset features)
|
||||
{
|
||||
auto const all = jtx::testable_amendments();
|
||||
|
||||
testToStrand(all);
|
||||
testRIPD1373(all);
|
||||
testLoop(all);
|
||||
testToStrand(features);
|
||||
testRIPD1373(features);
|
||||
testLoop(features);
|
||||
}
|
||||
|
||||
void
|
||||
run() override
|
||||
{
|
||||
testOffers();
|
||||
testPaths();
|
||||
testFlow();
|
||||
testCrossingLimits();
|
||||
testDeliverMin();
|
||||
testDepositAuth();
|
||||
testFreeze();
|
||||
testMultisign();
|
||||
testPayStrand();
|
||||
auto const all = testable_amendments();
|
||||
for (auto const& features : {all, all - featureMPTokensV2})
|
||||
{
|
||||
testOffers(features);
|
||||
testPaths(features);
|
||||
testFlow(features);
|
||||
testCrossingLimits(features);
|
||||
testDeliverMin(features);
|
||||
testDepositAuth(features);
|
||||
testFreeze(features);
|
||||
testMultisign(features);
|
||||
testPayStrand(features);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+1420
-1231
File diff suppressed because it is too large.
Load diff
@@ -2452,6 +2452,7 @@ public:
|
||||
{
|
||||
using namespace test::jtx;
|
||||
auto const sa = testable_amendments();
|
||||
testWithFeats(sa - featureMPTokensV2);
|
||||
testWithFeats(sa);
|
||||
testTrustLineCreation(sa);
|
||||
}
|
||||
|
||||
@@ -1275,10 +1275,12 @@ struct Flow_manual_test : public Flow_test
|
||||
auto const all = testable_amendments();
|
||||
FeatureBitset const permDex{featurePermissionedDEX};
|
||||
|
||||
testWithFeats(all - permDex);
|
||||
testWithFeats(all - permDex - featureMPTokensV2);
|
||||
testWithFeats(all - featureMPTokensV2);
|
||||
testWithFeats(all);
|
||||
|
||||
testEmptyStrand(all - permDex);
|
||||
testEmptyStrand(all - permDex - featureMPTokensV2);
|
||||
testEmptyStrand(all - featureMPTokensV2);
|
||||
testEmptyStrand(all);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -5132,7 +5132,7 @@ public:
|
||||
void
|
||||
run() override
|
||||
{
|
||||
testAll(allFeatures - featurePermissionedDEX);
|
||||
testAll(allFeatures - featurePermissionedDEX - featureMPTokensV2);
|
||||
testFalseAssert();
|
||||
}
|
||||
};
|
||||
@@ -5142,7 +5142,7 @@ class OfferWOSmallQOffers_test : public OfferBaseUtil_test
|
||||
void
|
||||
run() override
|
||||
{
|
||||
testAll(allFeatures - fixFillOrKill - featurePermissionedDEX);
|
||||
testAll(allFeatures - fixFillOrKill - featurePermissionedDEX - featureMPTokensV2);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -5152,6 +5152,7 @@ class OfferAllFeatures_test : public OfferBaseUtil_test
|
||||
run() override
|
||||
{
|
||||
testAll(allFeatures);
|
||||
testAll(allFeatures - featureMPTokensV2);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -5165,8 +5166,9 @@ class Offer_manual_test : public OfferBaseUtil_test
|
||||
FeatureBitset const fillOrKill{fixFillOrKill};
|
||||
FeatureBitset const permDEX{featurePermissionedDEX};
|
||||
|
||||
testAll(all - fillOrKill - permDEX);
|
||||
testAll(all - permDEX);
|
||||
testAll(all - fillOrKill - permDEX - featureMPTokensV2);
|
||||
testAll(all - permDEX - featureMPTokensV2);
|
||||
testAll(all - featureMPTokensV2);
|
||||
testAll(all);
|
||||
}
|
||||
};
|
||||
|
||||
+110
-101
@@ -60,18 +60,21 @@ rpf(jtx::Account const& src, jtx::Account const& dst, std::uint32_t num_src)
|
||||
class Path_test : public beast::unit_test::suite
|
||||
{
|
||||
jtx::Env
|
||||
pathTestEnv()
|
||||
pathTestEnv(FeatureBitset features = jtx::testable_amendments())
|
||||
{
|
||||
// These tests were originally written with search parameters that are
|
||||
// different from the current defaults. This function creates an env
|
||||
// with the search parameters that the tests were written for.
|
||||
using namespace jtx;
|
||||
return Env(*this, envconfig([](std::unique_ptr<Config> cfg) {
|
||||
cfg->PATH_SEARCH_OLD = 7;
|
||||
cfg->PATH_SEARCH = 7;
|
||||
cfg->PATH_SEARCH_MAX = 10;
|
||||
return cfg;
|
||||
}));
|
||||
return Env(
|
||||
*this,
|
||||
envconfig([](std::unique_ptr<Config> cfg) {
|
||||
cfg->PATH_SEARCH_OLD = 7;
|
||||
cfg->PATH_SEARCH = 7;
|
||||
cfg->PATH_SEARCH_MAX = 10;
|
||||
return cfg;
|
||||
}),
|
||||
features);
|
||||
}
|
||||
|
||||
public:
|
||||
@@ -215,12 +218,12 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
source_currencies_limit()
|
||||
source_currencies_limit(FeatureBitset features)
|
||||
{
|
||||
testcase("source currency limits");
|
||||
using namespace std::chrono_literals;
|
||||
using namespace jtx;
|
||||
Env env = pathTestEnv();
|
||||
Env env = pathTestEnv(features);
|
||||
auto const gw = Account("gateway");
|
||||
env.fund(XRP(10000), "alice", "bob", gw);
|
||||
env.close();
|
||||
@@ -291,11 +294,11 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
no_direct_path_no_intermediary_no_alternatives()
|
||||
no_direct_path_no_intermediary_no_alternatives(FeatureBitset features)
|
||||
{
|
||||
testcase("no direct path no intermediary no alternatives");
|
||||
using namespace jtx;
|
||||
Env env = pathTestEnv();
|
||||
Env env = pathTestEnv(features);
|
||||
env.fund(XRP(10000), "alice", "bob");
|
||||
env.close();
|
||||
|
||||
@@ -304,11 +307,11 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
direct_path_no_intermediary()
|
||||
direct_path_no_intermediary(FeatureBitset features)
|
||||
{
|
||||
testcase("direct path no intermediary");
|
||||
using namespace jtx;
|
||||
Env env = pathTestEnv();
|
||||
Env env = pathTestEnv(features);
|
||||
env.fund(XRP(10000), "alice", "bob");
|
||||
env.close();
|
||||
env.trust(Account("alice")["USD"](700), "bob");
|
||||
@@ -321,11 +324,11 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
payment_auto_path_find()
|
||||
payment_auto_path_find(FeatureBitset features)
|
||||
{
|
||||
testcase("payment auto path find");
|
||||
using namespace jtx;
|
||||
Env env = pathTestEnv();
|
||||
Env env = pathTestEnv(features);
|
||||
auto const gw = Account("gateway");
|
||||
auto const USD = gw["USD"];
|
||||
env.fund(XRP(10000), "alice", "bob", gw);
|
||||
@@ -341,11 +344,11 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
path_find(bool const domainEnabled)
|
||||
path_find(FeatureBitset features, bool const domainEnabled)
|
||||
{
|
||||
testcase(std::string("path find") + (domainEnabled ? " w/ " : " w/o ") + "domain");
|
||||
using namespace jtx;
|
||||
Env env = pathTestEnv();
|
||||
Env env = pathTestEnv(features);
|
||||
auto const gw = Account("gateway");
|
||||
auto const USD = gw["USD"];
|
||||
env.fund(XRP(10000), "alice", "bob", gw);
|
||||
@@ -368,11 +371,11 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
xrp_to_xrp(bool const domainEnabled)
|
||||
xrp_to_xrp(FeatureBitset features, bool const domainEnabled)
|
||||
{
|
||||
using namespace jtx;
|
||||
testcase(std::string("XRP to XRP") + (domainEnabled ? " w/ " : " w/o ") + "domain");
|
||||
Env env = pathTestEnv();
|
||||
Env env = pathTestEnv(features);
|
||||
env.fund(XRP(10000), "alice", "bob");
|
||||
env.close();
|
||||
|
||||
@@ -386,14 +389,14 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
path_find_consume_all(bool const domainEnabled)
|
||||
path_find_consume_all(FeatureBitset features, bool const domainEnabled)
|
||||
{
|
||||
testcase(
|
||||
std::string("path find consume all") + (domainEnabled ? " w/ " : " w/o ") + "domain");
|
||||
using namespace jtx;
|
||||
|
||||
{
|
||||
Env env = pathTestEnv();
|
||||
Env env = pathTestEnv(features);
|
||||
env.fund(XRP(10000), "alice", "bob", "carol", "dan", "edward");
|
||||
env.close();
|
||||
env.trust(Account("alice")["USD"](10), "bob");
|
||||
@@ -423,7 +426,7 @@ public:
|
||||
}
|
||||
|
||||
{
|
||||
Env env = pathTestEnv();
|
||||
Env env = pathTestEnv(features);
|
||||
auto const gw = Account("gateway");
|
||||
auto const USD = gw["USD"];
|
||||
env.fund(XRP(10000), "alice", "bob", "carol", gw);
|
||||
@@ -486,13 +489,13 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
alternative_path_consume_both(bool const domainEnabled)
|
||||
alternative_path_consume_both(FeatureBitset features, bool const domainEnabled)
|
||||
{
|
||||
testcase(
|
||||
std::string("alternative path consume both") + (domainEnabled ? " w/ " : " w/o ") +
|
||||
"domain");
|
||||
using namespace jtx;
|
||||
Env env = pathTestEnv();
|
||||
Env env = pathTestEnv(features);
|
||||
auto const gw = Account("gateway");
|
||||
auto const USD = gw["USD"];
|
||||
auto const gw2 = Account("gateway2");
|
||||
@@ -532,13 +535,13 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
alternative_paths_consume_best_transfer(bool const domainEnabled)
|
||||
alternative_paths_consume_best_transfer(FeatureBitset features, bool const domainEnabled)
|
||||
{
|
||||
testcase(
|
||||
std::string("alternative paths consume best transfer") +
|
||||
(domainEnabled ? " w/ " : " w/o ") + "domain");
|
||||
using namespace jtx;
|
||||
Env env = pathTestEnv();
|
||||
Env env = pathTestEnv(features);
|
||||
auto const gw = Account("gateway");
|
||||
auto const USD = gw["USD"];
|
||||
auto const gw2 = Account("gateway2");
|
||||
@@ -576,11 +579,11 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
alternative_paths_consume_best_transfer_first()
|
||||
alternative_paths_consume_best_transfer_first(FeatureBitset features)
|
||||
{
|
||||
testcase("alternative paths - consume best transfer first");
|
||||
using namespace jtx;
|
||||
Env env = pathTestEnv();
|
||||
Env env = pathTestEnv(features);
|
||||
auto const gw = Account("gateway");
|
||||
auto const USD = gw["USD"];
|
||||
auto const gw2 = Account("gateway2");
|
||||
@@ -608,13 +611,15 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
alternative_paths_limit_returned_paths_to_best_quality(bool const domainEnabled)
|
||||
alternative_paths_limit_returned_paths_to_best_quality(
|
||||
FeatureBitset features,
|
||||
bool const domainEnabled)
|
||||
{
|
||||
testcase(
|
||||
std::string("alternative paths - limit returned paths to best quality") +
|
||||
(domainEnabled ? " w/ " : " w/o ") + "domain");
|
||||
using namespace jtx;
|
||||
Env env = pathTestEnv();
|
||||
Env env = pathTestEnv(features);
|
||||
auto const gw = Account("gateway");
|
||||
auto const USD = gw["USD"];
|
||||
auto const gw2 = Account("gateway2");
|
||||
@@ -652,12 +657,12 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
issues_path_negative_issue(bool const domainEnabled)
|
||||
issues_path_negative_issue(FeatureBitset features, bool const domainEnabled)
|
||||
{
|
||||
testcase(
|
||||
std::string("path negative: Issue #5") + (domainEnabled ? " w/ " : " w/o ") + "domain");
|
||||
using namespace jtx;
|
||||
Env env = pathTestEnv();
|
||||
Env env = pathTestEnv(features);
|
||||
env.fund(XRP(10000), "alice", "bob", "carol", "dan");
|
||||
env.close();
|
||||
env.trust(Account("bob")["USD"](100), "alice", "carol", "dan");
|
||||
@@ -701,11 +706,11 @@ public:
|
||||
// alice --> carol --> dan --> bob
|
||||
// Balance of 100 USD Bob - Balance of 37 USD -> Rod
|
||||
void
|
||||
issues_path_negative_ripple_client_issue_23_smaller()
|
||||
issues_path_negative_ripple_client_issue_23_smaller(FeatureBitset features)
|
||||
{
|
||||
testcase("path negative: ripple-client issue #23: smaller");
|
||||
using namespace jtx;
|
||||
Env env = pathTestEnv();
|
||||
Env env = pathTestEnv(features);
|
||||
env.fund(XRP(10000), "alice", "bob", "carol", "dan");
|
||||
env.close();
|
||||
env.trust(Account("alice")["USD"](40), "bob");
|
||||
@@ -720,11 +725,11 @@ public:
|
||||
// alice -120 USD-> edward -25 USD-> bob
|
||||
// alice -25 USD-> carol -75 USD -> dan -100 USD-> bob
|
||||
void
|
||||
issues_path_negative_ripple_client_issue_23_larger()
|
||||
issues_path_negative_ripple_client_issue_23_larger(FeatureBitset features)
|
||||
{
|
||||
testcase("path negative: ripple-client issue #23: larger");
|
||||
using namespace jtx;
|
||||
Env env = pathTestEnv();
|
||||
Env env = pathTestEnv(features);
|
||||
env.fund(XRP(10000), "alice", "bob", "carol", "dan", "edward");
|
||||
env.close();
|
||||
env.trust(Account("alice")["USD"](120), "edward");
|
||||
@@ -747,11 +752,11 @@ public:
|
||||
// bob will hold gateway AUD
|
||||
// alice pays bob gateway AUD using XRP
|
||||
void
|
||||
via_offers_via_gateway(bool const domainEnabled)
|
||||
via_offers_via_gateway(FeatureBitset features, bool const domainEnabled)
|
||||
{
|
||||
testcase(std::string("via gateway") + (domainEnabled ? " w/ " : " w/o ") + "domain");
|
||||
using namespace jtx;
|
||||
Env env = pathTestEnv();
|
||||
Env env = pathTestEnv(features);
|
||||
auto const gw = Account("gateway");
|
||||
auto const AUD = gw["AUD"];
|
||||
env.fund(XRP(10000), "alice", "bob", "carol", gw);
|
||||
@@ -789,11 +794,11 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
indirect_paths_path_find()
|
||||
indirect_paths_path_find(FeatureBitset features)
|
||||
{
|
||||
testcase("path find");
|
||||
using namespace jtx;
|
||||
Env env = pathTestEnv();
|
||||
Env env = pathTestEnv(features);
|
||||
env.fund(XRP(10000), "alice", "bob", "carol");
|
||||
env.close();
|
||||
env.trust(Account("alice")["USD"](1000), "bob");
|
||||
@@ -808,11 +813,11 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
quality_paths_quality_set_and_test()
|
||||
quality_paths_quality_set_and_test(FeatureBitset features)
|
||||
{
|
||||
testcase("quality set and test");
|
||||
using namespace jtx;
|
||||
Env env = pathTestEnv();
|
||||
Env env = pathTestEnv(features);
|
||||
env.fund(XRP(10000), "alice", "bob");
|
||||
env.close();
|
||||
env(trust("bob", Account("alice")["USD"](1000)),
|
||||
@@ -853,11 +858,11 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
trust_auto_clear_trust_normal_clear()
|
||||
trust_auto_clear_trust_normal_clear(FeatureBitset features)
|
||||
{
|
||||
testcase("trust normal clear");
|
||||
using namespace jtx;
|
||||
Env env = pathTestEnv();
|
||||
Env env = pathTestEnv(features);
|
||||
env.fund(XRP(10000), "alice", "bob");
|
||||
env.close();
|
||||
env.trust(Account("bob")["USD"](1000), "alice");
|
||||
@@ -899,11 +904,11 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
trust_auto_clear_trust_auto_clear()
|
||||
trust_auto_clear_trust_auto_clear(FeatureBitset features)
|
||||
{
|
||||
testcase("trust auto clear");
|
||||
using namespace jtx;
|
||||
Env env = pathTestEnv();
|
||||
Env env = pathTestEnv(features);
|
||||
env.fund(XRP(10000), "alice", "bob");
|
||||
env.close();
|
||||
env.trust(Account("bob")["USD"](1000), "alice");
|
||||
@@ -948,13 +953,13 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
path_find_01(bool const domainEnabled)
|
||||
path_find_01(FeatureBitset features, bool const domainEnabled)
|
||||
{
|
||||
testcase(
|
||||
std::string("Path Find: XRP -> XRP and XRP -> IOU") +
|
||||
(domainEnabled ? " w/ " : " w/o ") + "domain");
|
||||
using namespace jtx;
|
||||
Env env = pathTestEnv();
|
||||
Env env = pathTestEnv(features);
|
||||
Account const A1{"A1"};
|
||||
Account const A2{"A2"};
|
||||
Account const A3{"A3"};
|
||||
@@ -1049,13 +1054,13 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
path_find_02(bool const domainEnabled)
|
||||
path_find_02(FeatureBitset features, bool const domainEnabled)
|
||||
{
|
||||
testcase(
|
||||
std::string("Path Find: non-XRP -> XRP") + (domainEnabled ? " w/ " : " w/o ") +
|
||||
"domain");
|
||||
using namespace jtx;
|
||||
Env env = pathTestEnv();
|
||||
Env env = pathTestEnv(features);
|
||||
Account const A1{"A1"};
|
||||
Account const A2{"A2"};
|
||||
Account const G3{"G3"};
|
||||
@@ -1109,13 +1114,13 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
path_find_04(bool const domainEnabled)
|
||||
path_find_04(FeatureBitset features, bool const domainEnabled)
|
||||
{
|
||||
testcase(
|
||||
std::string("Path Find: Bitstamp and SnapSwap, liquidity with no offers") +
|
||||
(domainEnabled ? " w/ " : " w/o ") + "domain");
|
||||
using namespace jtx;
|
||||
Env env = pathTestEnv();
|
||||
Env env = pathTestEnv(features);
|
||||
Account const A1{"A1"};
|
||||
Account const A2{"A2"};
|
||||
Account const G1BS{"G1BS"};
|
||||
@@ -1195,13 +1200,13 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
path_find_05(bool const domainEnabled)
|
||||
path_find_05(FeatureBitset features, bool const domainEnabled)
|
||||
{
|
||||
testcase(
|
||||
std::string("Path Find: non-XRP -> non-XRP, same currency") +
|
||||
(domainEnabled ? " w/ " : " w/o ") + "domain");
|
||||
using namespace jtx;
|
||||
Env env = pathTestEnv();
|
||||
Env env = pathTestEnv(features);
|
||||
Account const A1{"A1"};
|
||||
Account const A2{"A2"};
|
||||
Account const A3{"A3"};
|
||||
@@ -1338,13 +1343,13 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
path_find_06(bool const domainEnabled)
|
||||
path_find_06(FeatureBitset features, bool const domainEnabled)
|
||||
{
|
||||
testcase(
|
||||
std::string("Path Find: non-XRP -> non-XRP, same currency)") +
|
||||
(domainEnabled ? " w/ " : " w/o ") + "domain");
|
||||
using namespace jtx;
|
||||
Env env = pathTestEnv();
|
||||
Env env = pathTestEnv(features);
|
||||
Account const A1{"A1"};
|
||||
Account const A2{"A2"};
|
||||
Account const A3{"A3"};
|
||||
@@ -1393,7 +1398,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
receive_max(bool const domainEnabled)
|
||||
receive_max(FeatureBitset features, bool const domainEnabled)
|
||||
{
|
||||
testcase(std::string("Receive max") + (domainEnabled ? " w/ " : " w/o ") + "domain");
|
||||
|
||||
@@ -1405,7 +1410,7 @@ public:
|
||||
auto const USD = gw["USD"];
|
||||
{
|
||||
// XRP -> IOU receive max
|
||||
Env env = pathTestEnv();
|
||||
Env env = pathTestEnv(features);
|
||||
env.fund(XRP(10000), alice, bob, charlie, gw);
|
||||
env.close();
|
||||
env.trust(USD(100), alice, bob, charlie);
|
||||
@@ -1440,7 +1445,7 @@ public:
|
||||
}
|
||||
{
|
||||
// IOU -> XRP receive max
|
||||
Env env = pathTestEnv();
|
||||
Env env = pathTestEnv(features);
|
||||
env.fund(XRP(10000), alice, bob, charlie, gw);
|
||||
env.close();
|
||||
env.trust(USD(100), alice, bob, charlie);
|
||||
@@ -1476,7 +1481,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
noripple_combinations()
|
||||
noripple_combinations(FeatureBitset features)
|
||||
{
|
||||
using namespace jtx;
|
||||
// This test will create trust lines with various values of the noRipple
|
||||
@@ -1490,7 +1495,7 @@ public:
|
||||
auto test = [&](std::string casename, bool aliceRipple, bool bobRipple, bool expectPath) {
|
||||
testcase(casename);
|
||||
|
||||
Env env = pathTestEnv();
|
||||
Env env = pathTestEnv(features);
|
||||
env.fund(XRP(10000), noripple(alice, bob, george));
|
||||
env.close();
|
||||
// Set the same flags at both ends of the trustline, even though
|
||||
@@ -1525,7 +1530,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
hybrid_offer_path()
|
||||
hybrid_offer_path(FeatureBitset features)
|
||||
{
|
||||
testcase("Hybrid offer path");
|
||||
using namespace jtx;
|
||||
@@ -1534,7 +1539,7 @@ public:
|
||||
// different combinations of open/domain/hybrid offers. `func` is a
|
||||
// lambda param that creates different types of offers
|
||||
auto testPathfind = [&](auto func, bool const domainEnabled = false) {
|
||||
Env env = pathTestEnv();
|
||||
Env env = pathTestEnv(features);
|
||||
Account const A1{"A1"};
|
||||
Account const A2{"A2"};
|
||||
Account const A3{"A3"};
|
||||
@@ -1806,11 +1811,11 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
amm_domain_path()
|
||||
amm_domain_path(FeatureBitset features)
|
||||
{
|
||||
testcase("AMM not used in domain path");
|
||||
using namespace jtx;
|
||||
Env env = pathTestEnv();
|
||||
Env env = pathTestEnv(features);
|
||||
PermissionedDEX const permDex(env);
|
||||
auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] = permDex;
|
||||
AMM const amm(env, alice, XRP(10), USD(50));
|
||||
@@ -1833,46 +1838,50 @@ public:
|
||||
void
|
||||
run() override
|
||||
{
|
||||
source_currencies_limit();
|
||||
no_direct_path_no_intermediary_no_alternatives();
|
||||
direct_path_no_intermediary();
|
||||
payment_auto_path_find();
|
||||
indirect_paths_path_find();
|
||||
alternative_paths_consume_best_transfer_first();
|
||||
issues_path_negative_ripple_client_issue_23_smaller();
|
||||
issues_path_negative_ripple_client_issue_23_larger();
|
||||
quality_paths_quality_set_and_test();
|
||||
trust_auto_clear_trust_normal_clear();
|
||||
trust_auto_clear_trust_auto_clear();
|
||||
noripple_combinations();
|
||||
|
||||
for (bool const domainEnabled : {false, true})
|
||||
auto const all = jtx::testable_amendments();
|
||||
for (auto const& features : {all, all - featureMPTokensV2})
|
||||
{
|
||||
path_find(domainEnabled);
|
||||
path_find_consume_all(domainEnabled);
|
||||
alternative_path_consume_both(domainEnabled);
|
||||
alternative_paths_consume_best_transfer(domainEnabled);
|
||||
alternative_paths_limit_returned_paths_to_best_quality(domainEnabled);
|
||||
issues_path_negative_issue(domainEnabled);
|
||||
via_offers_via_gateway(domainEnabled);
|
||||
xrp_to_xrp(domainEnabled);
|
||||
receive_max(domainEnabled);
|
||||
source_currencies_limit(features);
|
||||
no_direct_path_no_intermediary_no_alternatives(features);
|
||||
direct_path_no_intermediary(features);
|
||||
payment_auto_path_find(features);
|
||||
indirect_paths_path_find(features);
|
||||
alternative_paths_consume_best_transfer_first(features);
|
||||
issues_path_negative_ripple_client_issue_23_smaller(features);
|
||||
issues_path_negative_ripple_client_issue_23_larger(features);
|
||||
quality_paths_quality_set_and_test(features);
|
||||
trust_auto_clear_trust_normal_clear(features);
|
||||
trust_auto_clear_trust_auto_clear(features);
|
||||
noripple_combinations(features);
|
||||
|
||||
// The following path_find_NN tests are data driven tests
|
||||
// that were originally implemented in js/coffee and migrated
|
||||
// here. The quantities and currencies used are taken directly from
|
||||
// those legacy tests, which in some cases probably represented
|
||||
// customer use cases.
|
||||
for (bool const domainEnabled : {false, true})
|
||||
{
|
||||
path_find(features, domainEnabled);
|
||||
path_find_consume_all(features, domainEnabled);
|
||||
alternative_path_consume_both(features, domainEnabled);
|
||||
alternative_paths_consume_best_transfer(features, domainEnabled);
|
||||
alternative_paths_limit_returned_paths_to_best_quality(features, domainEnabled);
|
||||
issues_path_negative_issue(features, domainEnabled);
|
||||
via_offers_via_gateway(features, domainEnabled);
|
||||
xrp_to_xrp(features, domainEnabled);
|
||||
receive_max(features, domainEnabled);
|
||||
|
||||
path_find_01(domainEnabled);
|
||||
path_find_02(domainEnabled);
|
||||
path_find_04(domainEnabled);
|
||||
path_find_05(domainEnabled);
|
||||
path_find_06(domainEnabled);
|
||||
// The following path_find_NN tests are data driven tests
|
||||
// that were originally implemented in js/coffee and migrated
|
||||
// here. The quantities and currencies used are taken directly from
|
||||
// those legacy tests, which in some cases probably represented
|
||||
// customer use cases.
|
||||
|
||||
path_find_01(features, domainEnabled);
|
||||
path_find_02(features, domainEnabled);
|
||||
path_find_04(features, domainEnabled);
|
||||
path_find_05(features, domainEnabled);
|
||||
path_find_06(features, domainEnabled);
|
||||
}
|
||||
|
||||
hybrid_offer_path(features);
|
||||
amm_domain_path(features);
|
||||
}
|
||||
|
||||
hybrid_offer_path();
|
||||
amm_domain_path();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ protected:
|
||||
};
|
||||
|
||||
jtx::Env
|
||||
pathTestEnv();
|
||||
pathTestEnv(FeatureBitset features = testable_amendments());
|
||||
};
|
||||
|
||||
} // namespace jtx
|
||||
|
||||
@@ -192,17 +192,20 @@ AMMTest::ammCrtFee(jtx::Env& env)
|
||||
}
|
||||
|
||||
jtx::Env
|
||||
AMMTest::pathTestEnv()
|
||||
AMMTest::pathTestEnv(FeatureBitset features)
|
||||
{
|
||||
// These tests were originally written with search parameters that are
|
||||
// different from the current defaults. This function creates an env
|
||||
// with the search parameters that the tests were written for.
|
||||
return Env(*this, envconfig([](std::unique_ptr<Config> cfg) {
|
||||
cfg->PATH_SEARCH_OLD = 7;
|
||||
cfg->PATH_SEARCH = 7;
|
||||
cfg->PATH_SEARCH_MAX = 10;
|
||||
return cfg;
|
||||
}));
|
||||
return Env(
|
||||
*this,
|
||||
envconfig([](std::unique_ptr<Config> cfg) {
|
||||
cfg->PATH_SEARCH_OLD = 7;
|
||||
cfg->PATH_SEARCH = 7;
|
||||
cfg->PATH_SEARCH_MAX = 10;
|
||||
return cfg;
|
||||
}),
|
||||
features);
|
||||
}
|
||||
} // namespace jtx
|
||||
} // namespace test
|
||||
|
||||
Reference in new issue
Block a user