diff --git a/src/ripple/rpc/handlers/LedgerData.cpp b/src/ripple/rpc/handlers/LedgerData.cpp index 7392b5051..f54339457 100644 --- a/src/ripple/rpc/handlers/LedgerData.cpp +++ b/src/ripple/rpc/handlers/LedgerData.cpp @@ -94,6 +94,10 @@ doLedgerData(RPC::JsonContext& context) return jvResult; } Json::Value& nodes = jvResult[jss::state]; + if (nodes.type() == Json::nullValue) + { + nodes = Json::Value(Json::arrayValue); + } auto e = lpLedger->sles.end(); for (auto i = lpLedger->sles.upper_bound(key); i != e; ++i) diff --git a/src/test/rpc/LedgerData_test.cpp b/src/test/rpc/LedgerData_test.cpp index ab520181c..ae57d6dcf 100644 --- a/src/test/rpc/LedgerData_test.cpp +++ b/src/test/rpc/LedgerData_test.cpp @@ -314,6 +314,34 @@ public: auto const USD = gw["USD"]; env.fund(XRP(100000), gw); + auto makeRequest = [&env](Json::StaticString const& type) { + Json::Value jvParams; + jvParams[jss::ledger_index] = "current"; + jvParams[jss::type] = type; + return env.rpc( + "json", + "ledger_data", + boost::lexical_cast(jvParams))[jss::result]; + }; + + // Assert that state is an empty array. + for (auto const& type : + {jss::amendments, + jss::check, + jss::directory, + jss::fee, + jss::offer, + jss::signer_list, + jss::state, + jss::ticket, + jss::escrow, + jss::payment_channel, + jss::deposit_preauth}) + { + auto const jrr = makeRequest(type); + BEAST_EXPECT(checkArraySize(jrr[jss::state], 0)); + } + int const num_accounts = 10; for (auto i = 0; i < num_accounts; i++) @@ -372,15 +400,6 @@ public: env.close(); // Now fetch each type - auto makeRequest = [&env](Json::StaticString t) { - Json::Value jvParams; - jvParams[jss::ledger_index] = "current"; - jvParams[jss::type] = t; - return env.rpc( - "json", - "ledger_data", - boost::lexical_cast(jvParams))[jss::result]; - }; { // jvParams[jss::type] = "account"; auto const jrr = makeRequest(jss::account);