mirror of
https://github.com/XRPLF/rippled.git
synced 2026-07-30 02:20:39 +00:00
Merge remote-tracking branch 'ripple/develop' into dev_rename_merge
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
|
||||
namespace xrpl::test {
|
||||
|
||||
class TrustSet_test : public beast::unit_test::suite
|
||||
class TrustSet_test : public beast::unit_test::Suite
|
||||
{
|
||||
public:
|
||||
void
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
env.require(lines(becky, 1));
|
||||
|
||||
// Fetch the trust-lines via RPC for verification
|
||||
Json::Value jv;
|
||||
json::Value jv;
|
||||
jv["account"] = becky.human();
|
||||
auto beckyLines = env.rpc("json", "account_lines", to_string(jv));
|
||||
|
||||
@@ -136,7 +136,7 @@ public:
|
||||
env.require(lines(becky, 1));
|
||||
|
||||
// Fetch the trust-lines via RPC for verification
|
||||
Json::Value jv;
|
||||
json::Value jv;
|
||||
jv["account"] = becky.human();
|
||||
auto beckyLines = env.rpc("json", "account_lines", to_string(jv));
|
||||
|
||||
@@ -202,24 +202,24 @@ public:
|
||||
+ drops(3 * txFee) /* and to pay for 3 transactions */,
|
||||
creator);
|
||||
|
||||
env(trust(creator, gwA["USD"](100)), require(lines(creator, 1)));
|
||||
env(trust(creator, gwB["USD"](100)), require(lines(creator, 2)));
|
||||
env(trust(creator, gwA["USD"](100)), Require(lines(creator, 1)));
|
||||
env(trust(creator, gwB["USD"](100)), Require(lines(creator, 2)));
|
||||
|
||||
if (thirdLineCreatesLE)
|
||||
{
|
||||
// creator does not have enough for the third trust line
|
||||
env(trust(creator, assistor["USD"](100)),
|
||||
ter(tecNO_LINE_INSUF_RESERVE),
|
||||
require(lines(creator, 2)));
|
||||
Ter(tecNO_LINE_INSUF_RESERVE),
|
||||
Require(lines(creator, 2)));
|
||||
}
|
||||
else
|
||||
{
|
||||
// First establish opposite trust direction from assistor
|
||||
env(trust(assistor, creator["USD"](100)), require(lines(creator, 3)));
|
||||
env(trust(assistor, creator["USD"](100)), Require(lines(creator, 3)));
|
||||
|
||||
// creator does not have enough to create the other direction on
|
||||
// the existing trust line ledger entry
|
||||
env(trust(creator, assistor["USD"](100)), ter(tecINSUF_RESERVE_LINE));
|
||||
env(trust(creator, assistor["USD"](100)), Ter(tecINSUF_RESERVE_LINE));
|
||||
}
|
||||
|
||||
// Fund creator additional amount to cover
|
||||
@@ -227,13 +227,13 @@ public:
|
||||
|
||||
if (thirdLineCreatesLE)
|
||||
{
|
||||
env(trust(creator, assistor["USD"](100)), require(lines(creator, 3)));
|
||||
env(trust(creator, assistor["USD"](100)), Require(lines(creator, 3)));
|
||||
}
|
||||
else
|
||||
{
|
||||
env(trust(creator, assistor["USD"](100)), require(lines(creator, 3)));
|
||||
env(trust(creator, assistor["USD"](100)), Require(lines(creator, 3)));
|
||||
|
||||
Json::Value jv;
|
||||
json::Value jv;
|
||||
jv["account"] = creator.human();
|
||||
auto const lines = env.rpc("json", "account_lines", to_string(jv));
|
||||
// Verify that all lines have 100 limit from creator
|
||||
@@ -257,13 +257,13 @@ public:
|
||||
Env env{*this, features};
|
||||
auto const gw = Account{"gateway"};
|
||||
auto const alice = Account{"alice"};
|
||||
auto const USD = gw["USD"];
|
||||
auto const usd = gw["USD"];
|
||||
|
||||
env.fund(XRP(10000), gw, alice);
|
||||
env.close();
|
||||
|
||||
// Cannot pay alice without a trustline.
|
||||
env(pay(gw, alice, USD(200)), ter(tecPATH_DRY));
|
||||
env(pay(gw, alice, usd(200)), Ter(tecPATH_DRY));
|
||||
env.close();
|
||||
|
||||
// Create a ticket.
|
||||
@@ -272,20 +272,20 @@ public:
|
||||
env.close();
|
||||
|
||||
// Use that ticket to create a trust line.
|
||||
env(trust(alice, USD(1000)), ticket::use(ticketSeq));
|
||||
env(trust(alice, usd(1000)), ticket::Use(ticketSeq));
|
||||
env.close();
|
||||
|
||||
// Now the payment succeeds.
|
||||
env(pay(gw, alice, USD(200)));
|
||||
env(pay(gw, alice, usd(200)));
|
||||
env.close();
|
||||
}
|
||||
|
||||
static Json::Value
|
||||
trust_explicit_amt(jtx::Account const& a, STAmount const& amt)
|
||||
static json::Value
|
||||
trustExplicitAmt(jtx::Account const& a, STAmount const& amt)
|
||||
{
|
||||
Json::Value jv;
|
||||
json::Value jv;
|
||||
jv[jss::Account] = a.human();
|
||||
jv[jss::LimitAmount] = amt.getJson(JsonOptions::none);
|
||||
jv[jss::LimitAmount] = amt.getJson(JsonOptions::KNone);
|
||||
jv[jss::TransactionType] = jss::TrustSet;
|
||||
jv[jss::Flags] = 0;
|
||||
return jv;
|
||||
@@ -310,28 +310,28 @@ public:
|
||||
if ((badFlag & tfTrustSetMask) != 0u)
|
||||
{
|
||||
env(trust(alice, gw["USD"](100), static_cast<std::uint32_t>(badFlag)),
|
||||
ter(temINVALID_FLAG));
|
||||
Ter(temINVALID_FLAG));
|
||||
}
|
||||
}
|
||||
|
||||
// trust amount can't be XRP
|
||||
env(trust_explicit_amt(alice, drops(10000)), ter(temBAD_LIMIT));
|
||||
env(trustExplicitAmt(alice, drops(10000)), Ter(temBAD_LIMIT));
|
||||
|
||||
// trust amount can't be badCurrency IOU
|
||||
env(trust_explicit_amt(alice, gw[to_string(badCurrency())](100)), ter(temBAD_CURRENCY));
|
||||
env(trustExplicitAmt(alice, gw[to_string(badCurrency())](100)), Ter(temBAD_CURRENCY));
|
||||
|
||||
// trust amount can't be negative
|
||||
env(trust(alice, gw["USD"](-1000)), ter(temBAD_LIMIT));
|
||||
env(trust(alice, gw["USD"](-1000)), Ter(temBAD_LIMIT));
|
||||
|
||||
// trust amount can't be from invalid issuer
|
||||
env(trust_explicit_amt(alice, STAmount{Issue{to_currency("USD"), noAccount()}, 100}),
|
||||
ter(temDST_NEEDED));
|
||||
env(trustExplicitAmt(alice, STAmount{Issue{toCurrency("USD"), noAccount()}, 100}),
|
||||
Ter(temDST_NEEDED));
|
||||
|
||||
// trust cannot be to self
|
||||
env(trust(alice, alice["USD"](100)), ter(temDST_IS_SRC));
|
||||
env(trust(alice, alice["USD"](100)), Ter(temDST_IS_SRC));
|
||||
|
||||
// tfSetAuth flag should not be set if not required by lsfRequireAuth
|
||||
env(trust(alice, gw["USD"](100), tfSetfAuth), ter(tefNO_AUTH_REQUIRED));
|
||||
env(trust(alice, gw["USD"](100), tfSetfAuth), Ter(tefNO_AUTH_REQUIRED));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -353,7 +353,7 @@ public:
|
||||
env.close();
|
||||
|
||||
// send a payment for a large quantity through the trust line
|
||||
env(pay(gw, alice, gw["USD"](200)), ter(tecPATH_PARTIAL));
|
||||
env(pay(gw, alice, gw["USD"](200)), Ter(tecPATH_PARTIAL));
|
||||
env.close();
|
||||
|
||||
// on the other hand, smaller payments should succeed
|
||||
@@ -386,7 +386,7 @@ public:
|
||||
env.close();
|
||||
|
||||
// send a payment from alice to bob, validate that the payment fails
|
||||
env(pay(alice, bob, alice["USD"](10)), ter(tecPATH_DRY));
|
||||
env(pay(alice, bob, alice["USD"](10)), Ter(tecPATH_DRY));
|
||||
env.close();
|
||||
}
|
||||
|
||||
@@ -410,21 +410,21 @@ public:
|
||||
env.close();
|
||||
|
||||
// archetypical payment transaction from alice to bob must succeed
|
||||
env(pay(alice, bob, alice["USD"](20)), ter(tesSUCCESS));
|
||||
env(pay(alice, bob, alice["USD"](20)), Ter(tesSUCCESS));
|
||||
env.close();
|
||||
|
||||
// Issued tokens are fungible. i.e. alice's USD is identical to bob's
|
||||
// USD
|
||||
env(pay(bob, alice, bob["USD"](10)), ter(tesSUCCESS));
|
||||
env(pay(bob, alice, bob["USD"](10)), Ter(tesSUCCESS));
|
||||
env.close();
|
||||
|
||||
// bob cannot place alice in his debt i.e. alice's balance of the USD
|
||||
// tokens cannot go below zero.
|
||||
env(pay(bob, alice, bob["USD"](11)), ter(tecPATH_PARTIAL));
|
||||
env(pay(bob, alice, bob["USD"](11)), Ter(tecPATH_PARTIAL));
|
||||
env.close();
|
||||
|
||||
// payments that respect the trust line limits of alice should succeed
|
||||
env(pay(bob, alice, bob["USD"](10)), ter(tesSUCCESS));
|
||||
env(pay(bob, alice, bob["USD"](10)), Ter(tesSUCCESS));
|
||||
env.close();
|
||||
}
|
||||
|
||||
@@ -457,8 +457,8 @@ public:
|
||||
auto& tx1 = createQuality ? txWithQuality : txWithoutQuality;
|
||||
auto& tx2 = createQuality ? txWithoutQuality : txWithQuality;
|
||||
|
||||
auto check_quality = [&](bool const exists) {
|
||||
Json::Value jv;
|
||||
auto checkQuality = [&](bool const exists) {
|
||||
json::Value jv;
|
||||
jv["account"] = toAcct.human();
|
||||
auto const lines = env.rpc("json", "account_lines", to_string(jv));
|
||||
auto quality = exists ? 1000 : 0;
|
||||
@@ -468,11 +468,11 @@ public:
|
||||
BEAST_EXPECT(lines[jss::result][jss::lines][0u][jss::quality_out] == quality);
|
||||
};
|
||||
|
||||
env(tx1, require(lines(toAcct, 1)), require(lines(fromAcct, 1)));
|
||||
check_quality(createQuality);
|
||||
env(tx1, Require(lines(toAcct, 1)), Require(lines(fromAcct, 1)));
|
||||
checkQuality(createQuality);
|
||||
|
||||
env(tx2, require(lines(toAcct, 1)), require(lines(fromAcct, 1)));
|
||||
check_quality(!createQuality);
|
||||
env(tx2, Require(lines(toAcct, 1)), Require(lines(fromAcct, 1)));
|
||||
checkQuality(!createQuality);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -491,7 +491,7 @@ public:
|
||||
Env env{*this, amend};
|
||||
auto const dist = Account("dist");
|
||||
auto const gw = Account("gw");
|
||||
auto const USD = gw["USD"];
|
||||
auto const usd = gw["USD"];
|
||||
auto const distUSD = dist["USD"];
|
||||
|
||||
env.fund(XRP(1000), gw, dist);
|
||||
@@ -503,17 +503,17 @@ public:
|
||||
env(fset(dist, asfDisallowIncomingTrustline));
|
||||
env.close();
|
||||
|
||||
env(trust(dist, USD(10000)));
|
||||
env(trust(dist, usd(10000)));
|
||||
env.close();
|
||||
|
||||
// withFix: can set trustline
|
||||
// withOutFix: cannot set trustline
|
||||
auto const trustResult = withFix ? ter(tesSUCCESS) : ter(tecNO_PERMISSION);
|
||||
env(trust(gw, distUSD(10000)), txflags(tfSetfAuth), trustResult);
|
||||
auto const trustResult = withFix ? Ter(tesSUCCESS) : Ter(tecNO_PERMISSION);
|
||||
env(trust(gw, distUSD(10000)), Txflags(tfSetfAuth), trustResult);
|
||||
env.close();
|
||||
|
||||
auto const txResult = withFix ? ter(tesSUCCESS) : ter(tecPATH_DRY);
|
||||
env(pay(gw, dist, USD(1000)), txResult);
|
||||
auto const txResult = withFix ? Ter(tesSUCCESS) : Ter(tecPATH_DRY);
|
||||
env(pay(gw, dist, usd(1000)), txResult);
|
||||
env.close();
|
||||
}
|
||||
}
|
||||
@@ -523,7 +523,7 @@ public:
|
||||
auto const gw = Account{"gateway"};
|
||||
auto const alice = Account{"alice"};
|
||||
auto const bob = Account{"bob"};
|
||||
auto const USD = gw["USD"];
|
||||
auto const usd = gw["USD"];
|
||||
|
||||
env.fund(XRP(10000), gw, alice, bob);
|
||||
env.close();
|
||||
@@ -533,7 +533,7 @@ public:
|
||||
env.close();
|
||||
|
||||
// Create a trustline which will fail
|
||||
env(trust(alice, USD(1000)), ter(tecNO_PERMISSION));
|
||||
env(trust(alice, usd(1000)), Ter(tecNO_PERMISSION));
|
||||
env.close();
|
||||
|
||||
// Unset the flag
|
||||
@@ -541,11 +541,11 @@ public:
|
||||
env.close();
|
||||
|
||||
// Create a trustline which will now succeed
|
||||
env(trust(alice, USD(1000)));
|
||||
env(trust(alice, usd(1000)));
|
||||
env.close();
|
||||
|
||||
// Now the payment succeeds.
|
||||
env(pay(gw, alice, USD(200)));
|
||||
env(pay(gw, alice, usd(200)));
|
||||
env.close();
|
||||
|
||||
// Set flag on gateway again
|
||||
@@ -553,12 +553,12 @@ public:
|
||||
env.close();
|
||||
|
||||
// Destroy the balance by sending it back
|
||||
env(pay(gw, alice, USD(200)));
|
||||
env(pay(gw, alice, usd(200)));
|
||||
env.close();
|
||||
|
||||
// The trustline still exists in default state
|
||||
// So a further payment should work
|
||||
env(pay(gw, alice, USD(200)));
|
||||
env(pay(gw, alice, usd(200)));
|
||||
env.close();
|
||||
|
||||
// Also set the flag on bob
|
||||
@@ -566,12 +566,12 @@ public:
|
||||
env.close();
|
||||
|
||||
// But now bob can't open a trustline because he didn't already have one
|
||||
env(trust(bob, USD(1000)), ter(tecNO_PERMISSION));
|
||||
env(trust(bob, usd(1000)), Ter(tecNO_PERMISSION));
|
||||
env.close();
|
||||
|
||||
// The gateway also can't open this trustline because bob has the flag
|
||||
// set
|
||||
env(trust(gw, bob["USD"](1000)), ter(tecNO_PERMISSION));
|
||||
env(trust(gw, bob["USD"](1000)), Ter(tecNO_PERMISSION));
|
||||
env.close();
|
||||
|
||||
// Unset the flag only on the gateway
|
||||
@@ -579,11 +579,11 @@ public:
|
||||
env.close();
|
||||
|
||||
// Now bob can open a trustline
|
||||
env(trust(bob, USD(1000)));
|
||||
env(trust(bob, usd(1000)));
|
||||
env.close();
|
||||
|
||||
// And the gateway can send bob a balance
|
||||
env(pay(gw, bob, USD(200)));
|
||||
env(pay(gw, bob, usd(200)));
|
||||
env.close();
|
||||
}
|
||||
|
||||
@@ -615,7 +615,7 @@ public:
|
||||
run() override
|
||||
{
|
||||
using namespace test::jtx;
|
||||
auto const sa = testable_amendments();
|
||||
auto const sa = testableAmendments();
|
||||
testWithFeats(sa);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user