mirror of
https://github.com/XRPLF/rippled.git
synced 2026-07-24 15:40:26 +00:00
Merge remote-tracking branch 'ripple/develop' into dev_rename_merge
This commit is contained in:
@@ -41,7 +41,7 @@
|
||||
|
||||
namespace xrpl::test {
|
||||
|
||||
static char const* bob_account_objects[] = {
|
||||
static char const* gBobAccountObjects[] = {
|
||||
R"json({
|
||||
"Account" : "rPMh7Pi9ct699iZUTWaytJUoHcJ7cgyziK",
|
||||
"BookDirectory" : "50AD0A9E54D2B381288D535EB724E4275FFBF41580D28A925D038D7EA4C68000",
|
||||
@@ -119,7 +119,7 @@ static char const* bob_account_objects[] = {
|
||||
"index" : "F03ABE26CB8C5F4AFB31A86590BD25C64C5756FCE5CE9704C27AFE291A4A29A1"
|
||||
})json"};
|
||||
|
||||
class AccountObjects_test : public beast::unit_test::suite
|
||||
class AccountObjects_test : public beast::unit_test::Suite
|
||||
{
|
||||
public:
|
||||
void
|
||||
@@ -132,14 +132,14 @@ public:
|
||||
|
||||
// test error on no account
|
||||
{
|
||||
Json::Value const params;
|
||||
json::Value const params;
|
||||
auto resp = env.rpc("json", "account_objects", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_message] == "Missing field 'account'.");
|
||||
}
|
||||
// test account non-string
|
||||
{
|
||||
auto testInvalidAccountParam = [&](auto const& param) {
|
||||
Json::Value params;
|
||||
json::Value params;
|
||||
params[jss::account] = param;
|
||||
auto jrr = env.rpc("json", "account_objects", to_string(params))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
@@ -149,20 +149,20 @@ public:
|
||||
testInvalidAccountParam(1);
|
||||
testInvalidAccountParam(1.1);
|
||||
testInvalidAccountParam(true);
|
||||
testInvalidAccountParam(Json::Value(Json::nullValue));
|
||||
testInvalidAccountParam(Json::Value(Json::objectValue));
|
||||
testInvalidAccountParam(Json::Value(Json::arrayValue));
|
||||
testInvalidAccountParam(json::Value(json::NullValue));
|
||||
testInvalidAccountParam(json::Value(json::ObjectValue));
|
||||
testInvalidAccountParam(json::Value(json::ArrayValue));
|
||||
}
|
||||
// test error on malformed account string.
|
||||
{
|
||||
Json::Value params;
|
||||
json::Value params;
|
||||
params[jss::account] = "n94JNrQYkDrpt62bbSR7nVEhdyAvcJXRAsjEkFYyqRkh9SUTYEqV";
|
||||
auto resp = env.rpc("json", "account_objects", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_message] == "Account malformed.");
|
||||
}
|
||||
// test error on account that's not in the ledger.
|
||||
{
|
||||
Json::Value params;
|
||||
json::Value params;
|
||||
params[jss::account] = Account{"bogie"}.human();
|
||||
auto resp = env.rpc("json", "account_objects", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_message] == "Account not found.");
|
||||
@@ -170,7 +170,7 @@ public:
|
||||
Account const bob{"bob"};
|
||||
// test error on large ledger_index.
|
||||
{
|
||||
Json::Value params;
|
||||
json::Value params;
|
||||
params[jss::account] = bob.human();
|
||||
params[jss::ledger_index] = 10;
|
||||
auto resp = env.rpc("json", "account_objects", to_string(params));
|
||||
@@ -180,7 +180,7 @@ public:
|
||||
env.fund(XRP(1000), bob);
|
||||
// test error on type param not a string
|
||||
{
|
||||
Json::Value params;
|
||||
json::Value params;
|
||||
params[jss::account] = bob.human();
|
||||
params[jss::type] = 10;
|
||||
auto resp = env.rpc("json", "account_objects", to_string(params));
|
||||
@@ -189,7 +189,7 @@ public:
|
||||
}
|
||||
// test error on type param not a valid type
|
||||
{
|
||||
Json::Value params;
|
||||
json::Value params;
|
||||
params[jss::account] = bob.human();
|
||||
params[jss::type] = "expedited";
|
||||
auto resp = env.rpc("json", "account_objects", to_string(params));
|
||||
@@ -197,7 +197,7 @@ public:
|
||||
}
|
||||
// test error on limit -ve
|
||||
{
|
||||
Json::Value params;
|
||||
json::Value params;
|
||||
params[jss::account] = bob.human();
|
||||
params[jss::limit] = -1;
|
||||
auto resp = env.rpc("json", "account_objects", to_string(params));
|
||||
@@ -209,18 +209,18 @@ public:
|
||||
{
|
||||
Account const gw{"G"};
|
||||
env.fund(XRP(1000), gw);
|
||||
auto const USD = gw["USD"];
|
||||
env.trust(USD(1000), bob);
|
||||
auto const usd = gw["USD"];
|
||||
env.trust(usd(1000), bob);
|
||||
env(pay(gw, bob, XRP(1)));
|
||||
env(offer(bob, XRP(100), bob["USD"](1)), txflags(tfPassive));
|
||||
env(offer(bob, XRP(100), bob["USD"](1)), Txflags(tfPassive));
|
||||
|
||||
Json::Value params;
|
||||
json::Value params;
|
||||
params[jss::account] = bob.human();
|
||||
params[jss::limit] = 1;
|
||||
auto resp = env.rpc("json", "account_objects", to_string(params));
|
||||
|
||||
auto resume_marker = resp[jss::result][jss::marker];
|
||||
std::string mark = to_string(resume_marker);
|
||||
auto resumeMarker = resp[jss::result][jss::marker];
|
||||
std::string mark = to_string(resumeMarker);
|
||||
params[jss::marker] = 10;
|
||||
resp = env.rpc("json", "account_objects", to_string(params));
|
||||
BEAST_EXPECT(
|
||||
@@ -267,27 +267,27 @@ public:
|
||||
Account const gw2{"G2"};
|
||||
Account const bob{"bob"};
|
||||
|
||||
auto const USD1 = gw1["USD"];
|
||||
auto const USD2 = gw2["USD"];
|
||||
auto const usD1 = gw1["USD"];
|
||||
auto const usD2 = gw2["USD"];
|
||||
|
||||
env.fund(XRP(1000), gw1, gw2, bob);
|
||||
env.trust(USD1(1000), bob);
|
||||
env.trust(USD2(1000), bob);
|
||||
env.trust(usD1(1000), bob);
|
||||
env.trust(usD2(1000), bob);
|
||||
|
||||
env(pay(gw1, bob, USD1(1000)));
|
||||
env(pay(gw2, bob, USD2(1000)));
|
||||
env(pay(gw1, bob, usD1(1000)));
|
||||
env(pay(gw2, bob, usD2(1000)));
|
||||
|
||||
env(offer(bob, XRP(100), bob["USD"](1)), txflags(tfPassive));
|
||||
env(offer(bob, XRP(100), USD1(1)), txflags(tfPassive));
|
||||
env(offer(bob, XRP(100), bob["USD"](1)), Txflags(tfPassive));
|
||||
env(offer(bob, XRP(100), usD1(1)), Txflags(tfPassive));
|
||||
|
||||
Json::Value bobj[4];
|
||||
json::Value bobj[4];
|
||||
for (int i = 0; i < 4; ++i)
|
||||
Json::Reader{}.parse(bob_account_objects[i], bobj[i]);
|
||||
json::Reader{}.parse(gBobAccountObjects[i], bobj[i]);
|
||||
|
||||
// test 'unstepped'
|
||||
// i.e. request account objects without explicit limit/marker paging
|
||||
{
|
||||
Json::Value params;
|
||||
json::Value params;
|
||||
params[jss::account] = bob.human();
|
||||
auto resp = env.rpc("json", "account_objects", to_string(params));
|
||||
BEAST_EXPECT(!resp.isMember(jss::marker));
|
||||
@@ -303,7 +303,7 @@ public:
|
||||
}
|
||||
// test request with type parameter as filter, unstepped
|
||||
{
|
||||
Json::Value params;
|
||||
json::Value params;
|
||||
params[jss::account] = bob.human();
|
||||
params[jss::type] = jss::state;
|
||||
auto resp = env.rpc("json", "account_objects", to_string(params));
|
||||
@@ -320,7 +320,7 @@ public:
|
||||
}
|
||||
// test stepped one-at-a-time with limit=1, resume from prev marker
|
||||
{
|
||||
Json::Value params;
|
||||
json::Value params;
|
||||
params[jss::account] = bob.human();
|
||||
params[jss::limit] = 1;
|
||||
for (int i = 0; i < 4; ++i)
|
||||
@@ -363,8 +363,8 @@ public:
|
||||
Account const gw2{"G2"};
|
||||
Account const bob{"bob"};
|
||||
|
||||
auto const USD1 = gw1["USD"];
|
||||
auto const USD2 = gw2["USD"];
|
||||
auto const usD1 = gw1["USD"];
|
||||
auto const usD2 = gw2["USD"];
|
||||
|
||||
env.fund(XRP(1000), gw1, gw2, bob);
|
||||
env.close();
|
||||
@@ -372,7 +372,7 @@ public:
|
||||
// Check behavior if there are no account objects.
|
||||
{
|
||||
// Unpaged
|
||||
Json::Value params;
|
||||
json::Value params;
|
||||
params[jss::account] = bob.human();
|
||||
auto resp = env.rpc("json", "account_objects", to_string(params));
|
||||
BEAST_EXPECT(!resp.isMember(jss::marker));
|
||||
@@ -386,14 +386,14 @@ public:
|
||||
}
|
||||
|
||||
// Check behavior if there are only NFTokens.
|
||||
env(token::mint(bob, 0u), txflags(tfTransferable));
|
||||
env(token::mint(bob, 0u), Txflags(tfTransferable));
|
||||
env.close();
|
||||
|
||||
// test 'unstepped'
|
||||
// i.e. request account objects without explicit limit/marker paging
|
||||
Json::Value unpaged;
|
||||
json::Value unpaged;
|
||||
{
|
||||
Json::Value params;
|
||||
json::Value params;
|
||||
params[jss::account] = bob.human();
|
||||
auto resp = env.rpc("json", "account_objects", to_string(params));
|
||||
BEAST_EXPECT(!resp.isMember(jss::marker));
|
||||
@@ -403,24 +403,24 @@ public:
|
||||
}
|
||||
// test request with type parameter as filter, unstepped
|
||||
{
|
||||
Json::Value params;
|
||||
json::Value params;
|
||||
params[jss::account] = bob.human();
|
||||
params[jss::type] = jss::nft_page;
|
||||
auto resp = env.rpc("json", "account_objects", to_string(params));
|
||||
BEAST_EXPECT(!resp.isMember(jss::marker));
|
||||
Json::Value& aobjs = resp[jss::result][jss::account_objects];
|
||||
json::Value& aobjs = resp[jss::result][jss::account_objects];
|
||||
BEAST_EXPECT(aobjs.size() == 1);
|
||||
BEAST_EXPECT(aobjs[0u][sfLedgerEntryType.jsonName] == jss::NFTokenPage);
|
||||
BEAST_EXPECT(aobjs[0u][sfNFTokens.jsonName].size() == 1);
|
||||
}
|
||||
// test stepped one-at-a-time with limit=1, resume from prev marker
|
||||
{
|
||||
Json::Value params;
|
||||
json::Value params;
|
||||
params[jss::account] = bob.human();
|
||||
params[jss::limit] = 1;
|
||||
|
||||
Json::Value resp = env.rpc("json", "account_objects", to_string(params));
|
||||
Json::Value& aobjs = resp[jss::result][jss::account_objects];
|
||||
json::Value resp = env.rpc("json", "account_objects", to_string(params));
|
||||
json::Value& aobjs = resp[jss::result][jss::account_objects];
|
||||
BEAST_EXPECT(aobjs.size() == 1);
|
||||
auto& aobj = aobjs[0U];
|
||||
BEAST_EXPECT(!resp[jss::result].isMember(jss::limit));
|
||||
@@ -430,19 +430,19 @@ public:
|
||||
}
|
||||
|
||||
// Add more objects in addition to the NFToken Page.
|
||||
env.trust(USD1(1000), bob);
|
||||
env.trust(USD2(1000), bob);
|
||||
env.trust(usD1(1000), bob);
|
||||
env.trust(usD2(1000), bob);
|
||||
|
||||
env(pay(gw1, bob, USD1(1000)));
|
||||
env(pay(gw2, bob, USD2(1000)));
|
||||
env(pay(gw1, bob, usD1(1000)));
|
||||
env(pay(gw2, bob, usD2(1000)));
|
||||
|
||||
env(offer(bob, XRP(100), bob["USD"](1)), txflags(tfPassive));
|
||||
env(offer(bob, XRP(100), USD1(1)), txflags(tfPassive));
|
||||
env(offer(bob, XRP(100), bob["USD"](1)), Txflags(tfPassive));
|
||||
env(offer(bob, XRP(100), usD1(1)), Txflags(tfPassive));
|
||||
env.close();
|
||||
|
||||
// test 'unstepped'
|
||||
{
|
||||
Json::Value params;
|
||||
json::Value params;
|
||||
params[jss::account] = bob.human();
|
||||
auto resp = env.rpc("json", "account_objects", to_string(params));
|
||||
BEAST_EXPECT(!resp.isMember(jss::marker));
|
||||
@@ -452,25 +452,25 @@ public:
|
||||
}
|
||||
// test request with type parameter as filter, unstepped
|
||||
{
|
||||
Json::Value params;
|
||||
json::Value params;
|
||||
params[jss::account] = bob.human();
|
||||
params[jss::type] = jss::nft_page;
|
||||
auto resp = env.rpc("json", "account_objects", to_string(params));
|
||||
BEAST_EXPECT(!resp.isMember(jss::marker));
|
||||
Json::Value& aobjs = resp[jss::result][jss::account_objects];
|
||||
json::Value& aobjs = resp[jss::result][jss::account_objects];
|
||||
BEAST_EXPECT(aobjs.size() == 1);
|
||||
BEAST_EXPECT(aobjs[0u][sfLedgerEntryType.jsonName] == jss::NFTokenPage);
|
||||
BEAST_EXPECT(aobjs[0u][sfNFTokens.jsonName].size() == 1);
|
||||
}
|
||||
// test stepped one-at-a-time with limit=1, resume from prev marker
|
||||
{
|
||||
Json::Value params;
|
||||
json::Value params;
|
||||
params[jss::account] = bob.human();
|
||||
params[jss::limit] = 1;
|
||||
for (int i = 0; i < 5; ++i)
|
||||
{
|
||||
Json::Value resp = env.rpc("json", "account_objects", to_string(params));
|
||||
Json::Value& aobjs = resp[jss::result][jss::account_objects];
|
||||
json::Value resp = env.rpc("json", "account_objects", to_string(params));
|
||||
json::Value& aobjs = resp[jss::result][jss::account_objects];
|
||||
BEAST_EXPECT(aobjs.size() == 1);
|
||||
auto& aobj = aobjs[0U];
|
||||
if (i < 4)
|
||||
@@ -493,12 +493,12 @@ public:
|
||||
// Make sure things still work if there is more than 1 NFT Page.
|
||||
for (int i = 0; i < 32; ++i)
|
||||
{
|
||||
env(token::mint(bob, 0u), txflags(tfTransferable));
|
||||
env(token::mint(bob, 0u), Txflags(tfTransferable));
|
||||
env.close();
|
||||
}
|
||||
// test 'unstepped'
|
||||
{
|
||||
Json::Value params;
|
||||
json::Value params;
|
||||
params[jss::account] = bob.human();
|
||||
auto resp = env.rpc("json", "account_objects", to_string(params));
|
||||
BEAST_EXPECT(!resp.isMember(jss::marker));
|
||||
@@ -508,23 +508,23 @@ public:
|
||||
}
|
||||
// test request with type parameter as filter, unstepped
|
||||
{
|
||||
Json::Value params;
|
||||
json::Value params;
|
||||
params[jss::account] = bob.human();
|
||||
params[jss::type] = jss::nft_page;
|
||||
auto resp = env.rpc("json", "account_objects", to_string(params));
|
||||
BEAST_EXPECT(!resp.isMember(jss::marker));
|
||||
Json::Value const& aobjs = resp[jss::result][jss::account_objects];
|
||||
json::Value const& aobjs = resp[jss::result][jss::account_objects];
|
||||
BEAST_EXPECT(aobjs.size() == 2);
|
||||
}
|
||||
// test stepped one-at-a-time with limit=1, resume from prev marker
|
||||
{
|
||||
Json::Value params;
|
||||
json::Value params;
|
||||
params[jss::account] = bob.human();
|
||||
params[jss::limit] = 1;
|
||||
for (int i = 0; i < 6; ++i)
|
||||
{
|
||||
Json::Value resp = env.rpc("json", "account_objects", to_string(params));
|
||||
Json::Value& aobjs = resp[jss::result][jss::account_objects];
|
||||
json::Value resp = env.rpc("json", "account_objects", to_string(params));
|
||||
json::Value& aobjs = resp[jss::result][jss::account_objects];
|
||||
BEAST_EXPECT(aobjs.size() == 1);
|
||||
auto& aobj = aobjs[0U];
|
||||
if (i < 5)
|
||||
@@ -556,19 +556,19 @@ public:
|
||||
|
||||
Account const alice{"alice"};
|
||||
Account const gw{"gateway"};
|
||||
auto const USD = gw["USD"];
|
||||
auto const usd = gw["USD"];
|
||||
|
||||
auto const features =
|
||||
testable_amendments() | featureXChainBridge | featurePermissionedDomains;
|
||||
testableAmendments() | featureXChainBridge | featurePermissionedDomains;
|
||||
Env env(*this, features);
|
||||
|
||||
// Make a lambda we can use to get "account_objects" easily.
|
||||
auto acctObjs = [&env](
|
||||
AccountID const& acct,
|
||||
std::optional<Json::StaticString> const& type,
|
||||
std::optional<json::StaticString> const& type,
|
||||
std::optional<std::uint16_t> limit = std::nullopt,
|
||||
std::optional<std::string> marker = std::nullopt) {
|
||||
Json::Value params;
|
||||
json::Value params;
|
||||
params[jss::account] = to_string(acct);
|
||||
if (type)
|
||||
params[jss::type] = *type;
|
||||
@@ -581,13 +581,13 @@ public:
|
||||
};
|
||||
|
||||
// Make a lambda that easily identifies the size of account objects.
|
||||
auto acctObjsIsSize = [](Json::Value const& resp, unsigned size) {
|
||||
auto acctObjsIsSize = [](json::Value const& resp, unsigned size) {
|
||||
return resp[jss::result][jss::account_objects].isArray() &&
|
||||
(resp[jss::result][jss::account_objects].size() == size);
|
||||
};
|
||||
|
||||
// Make a lambda that checks if the response has error for invalid type
|
||||
auto acctObjsTypeIsInvalid = [](Json::Value const& resp) {
|
||||
auto acctObjsTypeIsInvalid = [](json::Value const& resp) {
|
||||
return resp[jss::result].isMember(jss::error) &&
|
||||
resp[jss::result][jss::error_message] == "Invalid field \'type\'.";
|
||||
};
|
||||
@@ -621,11 +621,11 @@ public:
|
||||
|
||||
// gw mints an NFT so we can find it.
|
||||
uint256 const nftID{token::getNextID(env, gw, 0u, tfTransferable)};
|
||||
env(token::mint(gw, 0u), txflags(tfTransferable));
|
||||
env(token::mint(gw, 0u), Txflags(tfTransferable));
|
||||
env.close();
|
||||
{
|
||||
// Find the NFToken page and make sure it's the right one.
|
||||
Json::Value const resp = acctObjs(gw, jss::nft_page);
|
||||
json::Value const resp = acctObjs(gw, jss::nft_page);
|
||||
BEAST_EXPECT(acctObjsIsSize(resp, 1));
|
||||
|
||||
auto const& nftPage = resp[jss::result][jss::account_objects][0u];
|
||||
@@ -636,13 +636,13 @@ public:
|
||||
}
|
||||
|
||||
// Set up a trust line so we can find it.
|
||||
env.trust(USD(1000), alice);
|
||||
env.trust(usd(1000), alice);
|
||||
env.close();
|
||||
env(pay(gw, alice, USD(5)));
|
||||
env(pay(gw, alice, usd(5)));
|
||||
env.close();
|
||||
{
|
||||
// Find the trustline and make sure it's the right one.
|
||||
Json::Value const resp = acctObjs(gw, jss::state);
|
||||
json::Value const resp = acctObjs(gw, jss::state);
|
||||
BEAST_EXPECT(acctObjsIsSize(resp, 1));
|
||||
|
||||
auto const& state = resp[jss::result][jss::account_objects][0u];
|
||||
@@ -650,11 +650,11 @@ public:
|
||||
BEAST_EXPECT(state[sfHighLimit.jsonName][jss::value].asUInt() == 1000);
|
||||
}
|
||||
// gw writes a check for USD(10) to alice.
|
||||
env(check::create(gw, alice, USD(10)));
|
||||
env(check::create(gw, alice, usd(10)));
|
||||
env.close();
|
||||
{
|
||||
// Find the check.
|
||||
Json::Value const resp = acctObjs(gw, jss::check);
|
||||
json::Value const resp = acctObjs(gw, jss::check);
|
||||
BEAST_EXPECT(acctObjsIsSize(resp, 1));
|
||||
|
||||
auto const& check = resp[jss::result][jss::account_objects][0u];
|
||||
@@ -667,7 +667,7 @@ public:
|
||||
env.close();
|
||||
{
|
||||
// Find the pre-authorization.
|
||||
Json::Value const resp = acctObjs(gw, jss::deposit_preauth);
|
||||
json::Value const resp = acctObjs(gw, jss::deposit_preauth);
|
||||
BEAST_EXPECT(acctObjsIsSize(resp, 1));
|
||||
|
||||
auto const& preauth = resp[jss::result][jss::account_objects][0u];
|
||||
@@ -676,18 +676,18 @@ public:
|
||||
}
|
||||
{
|
||||
// gw creates an escrow that we can look for in the ledger.
|
||||
Json::Value jvEscrow;
|
||||
json::Value jvEscrow;
|
||||
jvEscrow[jss::TransactionType] = jss::EscrowCreate;
|
||||
jvEscrow[jss::Account] = gw.human();
|
||||
jvEscrow[jss::Destination] = gw.human();
|
||||
jvEscrow[jss::Amount] = XRP(100).value().getJson(JsonOptions::none);
|
||||
jvEscrow[jss::Amount] = XRP(100).value().getJson(JsonOptions::KNone);
|
||||
jvEscrow[sfFinishAfter.jsonName] = env.now().time_since_epoch().count() + 1;
|
||||
env(jvEscrow);
|
||||
env.close();
|
||||
}
|
||||
{
|
||||
// Find the escrow.
|
||||
Json::Value const resp = acctObjs(gw, jss::escrow);
|
||||
json::Value const resp = acctObjs(gw, jss::escrow);
|
||||
BEAST_EXPECT(acctObjsIsSize(resp, 1));
|
||||
|
||||
auto const& escrow = resp[jss::result][jss::account_objects][0u];
|
||||
@@ -706,7 +706,7 @@ public:
|
||||
env.close();
|
||||
|
||||
// Find the PermissionedDomain.
|
||||
Json::Value const resp = acctObjs(gw, jss::permissioned_domain);
|
||||
json::Value const resp = acctObjs(gw, jss::permissioned_domain);
|
||||
BEAST_EXPECT(acctObjsIsSize(resp, 1));
|
||||
|
||||
auto const& permissionedDomain = resp[jss::result][jss::account_objects][0u];
|
||||
@@ -739,25 +739,25 @@ public:
|
||||
x.createScBridgeObjects(scEnv);
|
||||
|
||||
auto scEnvAcctObjs = [&](Account const& acct, char const* type) {
|
||||
Json::Value params;
|
||||
json::Value params;
|
||||
params[jss::account] = acct.human();
|
||||
params[jss::type] = type;
|
||||
params[jss::ledger_index] = "validated";
|
||||
return scEnv.rpc("json", "account_objects", to_string(params));
|
||||
};
|
||||
|
||||
Json::Value const resp = scEnvAcctObjs(Account::master, jss::bridge);
|
||||
json::Value const resp = scEnvAcctObjs(Account::kMASTER, jss::bridge);
|
||||
|
||||
BEAST_EXPECT(acctObjsIsSize(resp, 1));
|
||||
auto const& acct_bridge = resp[jss::result][jss::account_objects][0u];
|
||||
BEAST_EXPECT(acct_bridge[sfAccount.jsonName] == Account::master.human());
|
||||
BEAST_EXPECT(acct_bridge[sfLedgerEntryType.getJsonName()] == "Bridge");
|
||||
BEAST_EXPECT(acct_bridge[sfXChainClaimID.getJsonName()].asUInt() == 0);
|
||||
BEAST_EXPECT(acct_bridge[sfXChainAccountClaimCount.getJsonName()].asUInt() == 0);
|
||||
BEAST_EXPECT(acct_bridge[sfXChainAccountCreateCount.getJsonName()].asUInt() == 0);
|
||||
BEAST_EXPECT(acct_bridge[sfMinAccountCreateAmount.getJsonName()].asUInt() == 20000000);
|
||||
BEAST_EXPECT(acct_bridge[sfSignatureReward.getJsonName()].asUInt() == 1000000);
|
||||
BEAST_EXPECT(acct_bridge[sfXChainBridge.getJsonName()] == x.jvb);
|
||||
auto const& acctBridge = resp[jss::result][jss::account_objects][0u];
|
||||
BEAST_EXPECT(acctBridge[sfAccount.jsonName] == Account::kMASTER.human());
|
||||
BEAST_EXPECT(acctBridge[sfLedgerEntryType.getJsonName()] == "Bridge");
|
||||
BEAST_EXPECT(acctBridge[sfXChainClaimID.getJsonName()].asUInt() == 0);
|
||||
BEAST_EXPECT(acctBridge[sfXChainAccountClaimCount.getJsonName()].asUInt() == 0);
|
||||
BEAST_EXPECT(acctBridge[sfXChainAccountCreateCount.getJsonName()].asUInt() == 0);
|
||||
BEAST_EXPECT(acctBridge[sfMinAccountCreateAmount.getJsonName()].asUInt() == 20000000);
|
||||
BEAST_EXPECT(acctBridge[sfSignatureReward.getJsonName()].asUInt() == 1000000);
|
||||
BEAST_EXPECT(acctBridge[sfXChainBridge.getJsonName()] == x.jvb);
|
||||
}
|
||||
{
|
||||
// Alice and Bob create a xchain sequence number that we can look
|
||||
@@ -766,13 +766,13 @@ public:
|
||||
Env scEnv(*this, envconfig(), features);
|
||||
x.createScBridgeObjects(scEnv);
|
||||
|
||||
scEnv(xchain_create_claim_id(x.scAlice, x.jvb, x.reward, x.mcAlice));
|
||||
scEnv(xchainCreateClaimId(x.scAlice, x.jvb, x.reward, x.mcAlice));
|
||||
scEnv.close();
|
||||
scEnv(xchain_create_claim_id(x.scBob, x.jvb, x.reward, x.mcBob));
|
||||
scEnv(xchainCreateClaimId(x.scBob, x.jvb, x.reward, x.mcBob));
|
||||
scEnv.close();
|
||||
|
||||
auto scEnvAcctObjs = [&](Account const& acct, char const* type) {
|
||||
Json::Value params;
|
||||
json::Value params;
|
||||
params[jss::account] = acct.human();
|
||||
params[jss::type] = type;
|
||||
params[jss::ledger_index] = "validated";
|
||||
@@ -781,21 +781,21 @@ public:
|
||||
|
||||
{
|
||||
// Find the xchain sequence number for Andrea.
|
||||
Json::Value const resp = scEnvAcctObjs(x.scAlice, jss::xchain_owned_claim_id);
|
||||
json::Value const resp = scEnvAcctObjs(x.scAlice, jss::xchain_owned_claim_id);
|
||||
BEAST_EXPECT(acctObjsIsSize(resp, 1));
|
||||
|
||||
auto const& xchain_seq = resp[jss::result][jss::account_objects][0u];
|
||||
BEAST_EXPECT(xchain_seq[sfAccount.jsonName] == x.scAlice.human());
|
||||
BEAST_EXPECT(xchain_seq[sfXChainClaimID.getJsonName()].asUInt() == 1);
|
||||
auto const& xchainSeq = resp[jss::result][jss::account_objects][0u];
|
||||
BEAST_EXPECT(xchainSeq[sfAccount.jsonName] == x.scAlice.human());
|
||||
BEAST_EXPECT(xchainSeq[sfXChainClaimID.getJsonName()].asUInt() == 1);
|
||||
}
|
||||
{
|
||||
// and the one for Bob
|
||||
Json::Value const resp = scEnvAcctObjs(x.scBob, jss::xchain_owned_claim_id);
|
||||
json::Value const resp = scEnvAcctObjs(x.scBob, jss::xchain_owned_claim_id);
|
||||
BEAST_EXPECT(acctObjsIsSize(resp, 1));
|
||||
|
||||
auto const& xchain_seq = resp[jss::result][jss::account_objects][0u];
|
||||
BEAST_EXPECT(xchain_seq[sfAccount.jsonName] == x.scBob.human());
|
||||
BEAST_EXPECT(xchain_seq[sfXChainClaimID.getJsonName()].asUInt() == 2);
|
||||
auto const& xchainSeq = resp[jss::result][jss::account_objects][0u];
|
||||
BEAST_EXPECT(xchainSeq[sfAccount.jsonName] == x.scBob.human());
|
||||
BEAST_EXPECT(xchainSeq[sfXChainClaimID.getJsonName()].asUInt() == 2);
|
||||
}
|
||||
}
|
||||
{
|
||||
@@ -805,11 +805,11 @@ public:
|
||||
auto const amt = XRP(1000);
|
||||
|
||||
// send first batch of account create attestations, so the
|
||||
// xchain_create_account_claim_id should be present on the door
|
||||
// account (Account::master) to collect the signatures until a
|
||||
// xchain_create_account_claim_id_ should be present on the door
|
||||
// account (Account::kMASTER) to collect the signatures until a
|
||||
// quorum is reached
|
||||
scEnv(
|
||||
test::jtx::create_account_attestation(
|
||||
test::jtx::createAccountAttestation(
|
||||
x.scAttester,
|
||||
x.jvb,
|
||||
x.mcCarol,
|
||||
@@ -823,7 +823,7 @@ public:
|
||||
scEnv.close();
|
||||
|
||||
auto scEnvAcctObjs = [&](Account const& acct, char const* type) {
|
||||
Json::Value params;
|
||||
json::Value params;
|
||||
params[jss::account] = acct.human();
|
||||
params[jss::type] = type;
|
||||
params[jss::ledger_index] = "validated";
|
||||
@@ -831,27 +831,27 @@ public:
|
||||
};
|
||||
|
||||
{
|
||||
// Find the xchain_create_account_claim_id
|
||||
Json::Value const resp =
|
||||
scEnvAcctObjs(Account::master, jss::xchain_owned_create_account_claim_id);
|
||||
// Find the xchain_create_account_claim_id_
|
||||
json::Value const resp =
|
||||
scEnvAcctObjs(Account::kMASTER, jss::xchain_owned_create_account_claim_id);
|
||||
BEAST_EXPECT(acctObjsIsSize(resp, 1));
|
||||
|
||||
auto const& xchain_create_account_claim_id =
|
||||
auto const& xchainCreateAccountClaimId =
|
||||
resp[jss::result][jss::account_objects][0u];
|
||||
BEAST_EXPECT(
|
||||
xchain_create_account_claim_id[sfAccount.jsonName] == Account::master.human());
|
||||
xchainCreateAccountClaimId[sfAccount.jsonName] == Account::kMASTER.human());
|
||||
BEAST_EXPECT(
|
||||
xchain_create_account_claim_id[sfXChainAccountCreateCount.getJsonName()]
|
||||
.asUInt() == 1);
|
||||
xchainCreateAccountClaimId[sfXChainAccountCreateCount.getJsonName()].asUInt() ==
|
||||
1);
|
||||
}
|
||||
}
|
||||
|
||||
// gw creates an offer that we can look for in the ledger.
|
||||
env(offer(gw, USD(7), XRP(14)));
|
||||
env(offer(gw, usd(7), XRP(14)));
|
||||
env.close();
|
||||
{
|
||||
// Find the offer.
|
||||
Json::Value const resp = acctObjs(gw, jss::offer);
|
||||
json::Value const resp = acctObjs(gw, jss::offer);
|
||||
BEAST_EXPECT(acctObjsIsSize(resp, 1));
|
||||
|
||||
auto const& offer = resp[jss::result][jss::account_objects][0u];
|
||||
@@ -862,11 +862,11 @@ public:
|
||||
{
|
||||
// Create a payment channel from qw to alice that we can look
|
||||
// for.
|
||||
Json::Value jvPayChan;
|
||||
json::Value jvPayChan;
|
||||
jvPayChan[jss::TransactionType] = jss::PaymentChannelCreate;
|
||||
jvPayChan[jss::Account] = gw.human();
|
||||
jvPayChan[jss::Destination] = alice.human();
|
||||
jvPayChan[jss::Amount] = XRP(300).value().getJson(JsonOptions::none);
|
||||
jvPayChan[jss::Amount] = XRP(300).value().getJson(JsonOptions::KNone);
|
||||
jvPayChan[sfSettleDelay.jsonName] = 24 * 60 * 60;
|
||||
jvPayChan[sfPublicKey.jsonName] = strHex(gw.pk().slice());
|
||||
env(jvPayChan);
|
||||
@@ -874,7 +874,7 @@ public:
|
||||
}
|
||||
{
|
||||
// Find the payment channel.
|
||||
Json::Value const resp = acctObjs(gw, jss::payment_channel);
|
||||
json::Value const resp = acctObjs(gw, jss::payment_channel);
|
||||
BEAST_EXPECT(acctObjsIsSize(resp, 1));
|
||||
|
||||
auto const& payChan = resp[jss::result][jss::account_objects][0u];
|
||||
@@ -885,7 +885,7 @@ public:
|
||||
|
||||
{
|
||||
// gw creates a DID that we can look for in the ledger.
|
||||
Json::Value jvDID;
|
||||
json::Value jvDID;
|
||||
jvDID[jss::TransactionType] = jss::DIDSet;
|
||||
jvDID[jss::Account] = gw.human();
|
||||
jvDID[sfURI.jsonName] = strHex(std::string{"uri"});
|
||||
@@ -894,7 +894,7 @@ public:
|
||||
}
|
||||
{
|
||||
// Find the DID.
|
||||
Json::Value const resp = acctObjs(gw, jss::did);
|
||||
json::Value const resp = acctObjs(gw, jss::did);
|
||||
BEAST_EXPECT(acctObjsIsSize(resp, 1));
|
||||
|
||||
auto const& did = resp[jss::result][jss::account_objects][0u];
|
||||
@@ -906,7 +906,7 @@ public:
|
||||
env.close();
|
||||
{
|
||||
// Find the signer list.
|
||||
Json::Value const resp = acctObjs(gw, jss::signer_list);
|
||||
json::Value const resp = acctObjs(gw, jss::signer_list);
|
||||
BEAST_EXPECT(acctObjsIsSize(resp, 1));
|
||||
|
||||
auto const& signerList = resp[jss::result][jss::account_objects][0u];
|
||||
@@ -923,7 +923,7 @@ public:
|
||||
env.close();
|
||||
|
||||
// Find the ticket.
|
||||
Json::Value const resp = acctObjs(gw, jss::ticket);
|
||||
json::Value const resp = acctObjs(gw, jss::ticket);
|
||||
BEAST_EXPECT(acctObjsIsSize(resp, 1));
|
||||
|
||||
auto const& ticket = resp[jss::result][jss::account_objects][0u];
|
||||
@@ -958,20 +958,20 @@ public:
|
||||
|
||||
{
|
||||
// See how "deletion_blockers_only" handles gw's directory.
|
||||
Json::Value params;
|
||||
json::Value params;
|
||||
params[jss::account] = gw.human();
|
||||
params[jss::deletion_blockers_only] = true;
|
||||
auto resp = env.rpc("json", "account_objects", to_string(params));
|
||||
|
||||
std::vector<std::string> const expectedLedgerTypes = [] {
|
||||
std::vector<std::string> v{
|
||||
jss::Escrow.c_str(),
|
||||
jss::Check.c_str(),
|
||||
jss::NFTokenPage.c_str(),
|
||||
jss::RippleState.c_str(),
|
||||
jss::PayChannel.c_str(),
|
||||
jss::PermissionedDomain.c_str(),
|
||||
jss::Sponsorship.c_str()};
|
||||
jss::Escrow.cStr(),
|
||||
jss::Check.cStr(),
|
||||
jss::NFTokenPage.cStr(),
|
||||
jss::RippleState.cStr(),
|
||||
jss::PayChannel.cStr(),
|
||||
jss::PermissionedDomain.cStr(),
|
||||
jss::Sponsorship.cStr()};
|
||||
std::ranges::sort(v);
|
||||
return v;
|
||||
}();
|
||||
@@ -995,7 +995,7 @@ public:
|
||||
{
|
||||
// See how "deletion_blockers_only" with `type` handles gw's
|
||||
// directory.
|
||||
Json::Value params;
|
||||
json::Value params;
|
||||
params[jss::account] = gw.human();
|
||||
params[jss::deletion_blockers_only] = true;
|
||||
params[jss::type] = jss::escrow;
|
||||
@@ -1009,7 +1009,7 @@ public:
|
||||
}
|
||||
{
|
||||
// Make a lambda to get the types
|
||||
auto getTypes = [&](Json::Value const& resp, std::vector<std::string>& typesOut) {
|
||||
auto getTypes = [&](json::Value const& resp, std::vector<std::string>& typesOut) {
|
||||
auto const objs = resp[jss::result][jss::account_objects];
|
||||
for (auto const& obj : resp[jss::result][jss::account_objects])
|
||||
typesOut.push_back(obj[sfLedgerEntryType.fieldName].asString());
|
||||
@@ -1017,7 +1017,7 @@ public:
|
||||
};
|
||||
// Make a lambda we can use to check the number of fetched
|
||||
// account objects and their ledger type
|
||||
auto expectObjects = [&](Json::Value const& resp,
|
||||
auto expectObjects = [&](json::Value const& resp,
|
||||
std::vector<std::string> const& types) -> bool {
|
||||
if (!acctObjsIsSize(resp, types.size()))
|
||||
return false;
|
||||
@@ -1026,8 +1026,8 @@ public:
|
||||
return types == typesOut;
|
||||
};
|
||||
// Find AMM objects
|
||||
AMM amm(env, gw, XRP(1'000), USD(1'000));
|
||||
amm.deposit(alice, USD(1));
|
||||
AMM amm(env, gw, XRP(1'000), usd(1'000));
|
||||
amm.deposit(alice, usd(1));
|
||||
// AMM account has 4 objects: AMM object and 3 trustlines
|
||||
auto const lines = getAccountLines(env, amm.ammAccount());
|
||||
BEAST_EXPECT(lines[jss::lines].size() == 3);
|
||||
@@ -1044,15 +1044,14 @@ public:
|
||||
BEAST_EXPECT(
|
||||
(typesOut ==
|
||||
std::vector<std::string>{
|
||||
jss::AMM.c_str(),
|
||||
jss::RippleState.c_str(),
|
||||
jss::RippleState.c_str(),
|
||||
jss::RippleState.c_str()}));
|
||||
jss::AMM.cStr(),
|
||||
jss::RippleState.cStr(),
|
||||
jss::RippleState.cStr(),
|
||||
jss::RippleState.cStr()}));
|
||||
// filter by state: there are three trustlines
|
||||
resp = acctObjs(amm.ammAccount(), jss::state, 10);
|
||||
BEAST_EXPECT(expectObjects(
|
||||
resp,
|
||||
{jss::RippleState.c_str(), jss::RippleState.c_str(), jss::RippleState.c_str()}));
|
||||
resp, {jss::RippleState.cStr(), jss::RippleState.cStr(), jss::RippleState.cStr()}));
|
||||
// AMM account doesn't own offers
|
||||
BEAST_EXPECT(acctObjsIsSize(acctObjs(amm.ammAccount(), jss::offer), 0));
|
||||
// gw account doesn't own AMM object
|
||||
@@ -1070,7 +1069,7 @@ public:
|
||||
// directory nodes.
|
||||
for (int d = 1'000'032; d >= 1'000'000; --d)
|
||||
{
|
||||
env(offer(gw, USD(1), drops(d)));
|
||||
env(offer(gw, usd(1), drops(d)));
|
||||
env.close();
|
||||
}
|
||||
|
||||
@@ -1093,8 +1092,8 @@ public:
|
||||
Account const bob{"bob"};
|
||||
env.fund(XRP(10000), bob);
|
||||
|
||||
static constexpr unsigned nftsSize = 10;
|
||||
for (unsigned i = 0; i < nftsSize; i++)
|
||||
static constexpr unsigned kNFTS_SIZE = 10;
|
||||
for (unsigned i = 0; i < kNFTS_SIZE; i++)
|
||||
{
|
||||
env(token::mint(bob, 0));
|
||||
}
|
||||
@@ -1102,14 +1101,14 @@ public:
|
||||
env.close();
|
||||
|
||||
// save the NFTokenIDs to use later
|
||||
std::vector<Json::Value> tokenIDs;
|
||||
std::vector<json::Value> tokenIDs;
|
||||
{
|
||||
Json::Value params;
|
||||
json::Value params;
|
||||
params[jss::account] = bob.human();
|
||||
params[jss::ledger_index] = "validated";
|
||||
Json::Value const resp = env.rpc("json", "account_nfts", to_string(params));
|
||||
Json::Value const& nfts = resp[jss::result][jss::account_nfts];
|
||||
for (Json::Value const& nft : nfts)
|
||||
json::Value const resp = env.rpc("json", "account_nfts", to_string(params));
|
||||
json::Value const& nfts = resp[jss::result][jss::account_nfts];
|
||||
for (json::Value const& nft : nfts)
|
||||
tokenIDs.push_back(nft["NFTokenID"]);
|
||||
}
|
||||
|
||||
@@ -1117,17 +1116,17 @@ public:
|
||||
// returns the correct token information. lastIndex is used to query the
|
||||
// last marker.
|
||||
auto compareNFTs = [&tokenIDs, &env, &bob](unsigned const limit, unsigned const lastIndex) {
|
||||
Json::Value params;
|
||||
json::Value params;
|
||||
params[jss::account] = bob.human();
|
||||
params[jss::limit] = limit;
|
||||
params[jss::marker] = tokenIDs[lastIndex];
|
||||
params[jss::ledger_index] = "validated";
|
||||
Json::Value const resp = env.rpc("json", "account_nfts", to_string(params));
|
||||
json::Value const resp = env.rpc("json", "account_nfts", to_string(params));
|
||||
|
||||
if (resp[jss::result].isMember(jss::error))
|
||||
return false;
|
||||
|
||||
Json::Value const& nfts = resp[jss::result][jss::account_nfts];
|
||||
json::Value const& nfts = resp[jss::result][jss::account_nfts];
|
||||
unsigned const nftsCount =
|
||||
tokenIDs.size() - lastIndex - 1 < limit ? tokenIDs.size() - lastIndex - 1 : limit;
|
||||
|
||||
@@ -1151,12 +1150,12 @@ public:
|
||||
|
||||
// lambda that holds common code for invalid cases.
|
||||
auto testInvalidMarker = [&env, &bob](auto marker, char const* errorMessage) {
|
||||
Json::Value params;
|
||||
json::Value params;
|
||||
params[jss::account] = bob.human();
|
||||
params[jss::limit] = 4;
|
||||
params[jss::ledger_index] = jss::validated;
|
||||
params[jss::marker] = marker;
|
||||
Json::Value const resp = env.rpc("json", "account_nfts", to_string(params));
|
||||
json::Value const resp = env.rpc("json", "account_nfts", to_string(params));
|
||||
return resp[jss::result][jss::error_message] == errorMessage;
|
||||
};
|
||||
|
||||
@@ -1202,7 +1201,7 @@ public:
|
||||
// test validation
|
||||
{
|
||||
auto testInvalidAccountParam = [&](auto const& param) {
|
||||
Json::Value params;
|
||||
json::Value params;
|
||||
params[jss::account] = param;
|
||||
auto jrr = env.rpc("json", "account_nfts", to_string(params))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
@@ -1212,9 +1211,9 @@ public:
|
||||
testInvalidAccountParam(1);
|
||||
testInvalidAccountParam(1.1);
|
||||
testInvalidAccountParam(true);
|
||||
testInvalidAccountParam(Json::Value(Json::nullValue));
|
||||
testInvalidAccountParam(Json::Value(Json::objectValue));
|
||||
testInvalidAccountParam(Json::Value(Json::arrayValue));
|
||||
testInvalidAccountParam(json::Value(json::NullValue));
|
||||
testInvalidAccountParam(json::Value(json::ObjectValue));
|
||||
testInvalidAccountParam(json::Value(json::ArrayValue));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1241,11 +1240,11 @@ public:
|
||||
env.close();
|
||||
|
||||
unsigned const limit = 11;
|
||||
Json::Value marker;
|
||||
json::Value marker;
|
||||
|
||||
// test account_objects with a limit and update marker
|
||||
{
|
||||
Json::Value params;
|
||||
json::Value params;
|
||||
params[jss::account] = bob.human();
|
||||
params[jss::limit] = limit;
|
||||
params[jss::ledger_index] = "validated";
|
||||
@@ -1258,7 +1257,7 @@ public:
|
||||
|
||||
// test account_objects with valid marker and update marker
|
||||
{
|
||||
Json::Value params;
|
||||
json::Value params;
|
||||
params[jss::account] = bob.human();
|
||||
params[jss::limit] = limit;
|
||||
params[jss::marker] = marker;
|
||||
@@ -1272,12 +1271,12 @@ public:
|
||||
|
||||
// this lambda function is used to check invalid marker response.
|
||||
auto testInvalidMarker = [&](std::string& marker) {
|
||||
Json::Value params;
|
||||
json::Value params;
|
||||
params[jss::account] = bob.human();
|
||||
params[jss::limit] = limit;
|
||||
params[jss::ledger_index] = jss::validated;
|
||||
params[jss::marker] = marker;
|
||||
Json::Value const resp = env.rpc("json", "account_objects", to_string(params));
|
||||
json::Value const resp = env.rpc("json", "account_objects", to_string(params));
|
||||
return resp[jss::result][jss::error_message] == "Invalid field \'marker\'.";
|
||||
};
|
||||
|
||||
@@ -1328,7 +1327,7 @@ public:
|
||||
// dir.
|
||||
{
|
||||
std::string const s = "0," + entryIndex;
|
||||
Json::Value params;
|
||||
json::Value params;
|
||||
params[jss::account] = bob.human();
|
||||
params[jss::limit] = limit;
|
||||
params[jss::marker] = s;
|
||||
@@ -1356,7 +1355,7 @@ public:
|
||||
// continue getting account_objects with valid marker. This will be the
|
||||
// last page, so response will not contain any marker.
|
||||
{
|
||||
Json::Value params;
|
||||
json::Value params;
|
||||
params[jss::account] = bob.human();
|
||||
params[jss::limit] = limit;
|
||||
params[jss::marker] = marker;
|
||||
@@ -1371,7 +1370,7 @@ public:
|
||||
// test account_objects when the account only have nft pages, but
|
||||
// provided invalid entry index.
|
||||
{
|
||||
Json::Value params;
|
||||
json::Value params;
|
||||
params[jss::account] = carol.human();
|
||||
params[jss::limit] = 10;
|
||||
params[jss::marker] = "0," + entryIndex;
|
||||
|
||||
Reference in New Issue
Block a user