Add 'type' param to ledger_data and ledger rpc commands (RIPD-1446):

The 'type' field allows the rpc client to specify what type of ledger
entries to retrieve. The available types are:

    "account"
    "amendments"
    "directory"
    "fee"
    "hashes"
    "offer"
    "signer_list"
    "state"
    "ticket"
This commit is contained in:
Howard Hinnant
2017-03-17 16:20:45 -04:00
committed by Nik Bougalis
parent fab3ec0b56
commit 1a7a6f22e2
13 changed files with 293 additions and 62 deletions

View File

@@ -652,6 +652,44 @@ class LedgerRPC_test : public beast::unit_test::suite
}
void testLedgerAccountsType()
{
testcase("Ledger Request, Accounts Option");
using namespace test::jtx;
Env env {*this};
env.close();
std::string index;
{
Json::Value jvParams;
jvParams[jss::ledger_index] = 3u;
jvParams[jss::accounts] = true;
jvParams[jss::expand] = true;
jvParams[jss::type] = "hashes";
auto const jrr = env.rpc ( "json", "ledger", to_string(jvParams) ) [jss::result];
BEAST_EXPECT(jrr[jss::ledger].isMember(jss::accountState));
BEAST_EXPECT(jrr[jss::ledger][jss::accountState].isArray());
BEAST_EXPECT(jrr[jss::ledger][jss::accountState].size() == 1u);
BEAST_EXPECT(jrr[jss::ledger][jss::accountState][0u]["LedgerEntryType"]
== "LedgerHashes");
index = jrr[jss::ledger][jss::accountState][0u]["index"].asString();
}
{
Json::Value jvParams;
jvParams[jss::ledger_index] = 3u;
jvParams[jss::accounts] = true;
jvParams[jss::expand] = false;
jvParams[jss::type] = "hashes";
auto const jrr = env.rpc ( "json", "ledger", to_string(jvParams) ) [jss::result];
BEAST_EXPECT(jrr[jss::ledger].isMember(jss::accountState));
BEAST_EXPECT(jrr[jss::ledger][jss::accountState].isArray());
BEAST_EXPECT(jrr[jss::ledger][jss::accountState].size() == 1u);
BEAST_EXPECT(jrr[jss::ledger][jss::accountState][0u] == index);
}
}
public:
void run ()
{
@@ -668,6 +706,7 @@ public:
testLookupLedger();
testNoQueue();
testQueue();
testLedgerAccountsType();
}
};