Skip to content

Commit

Permalink
[FOLD] Initialize account_objects as json array
Browse files Browse the repository at this point in the history
  • Loading branch information
bachase authored and scottschurr committed Jan 29, 2018
1 parent aa2046f commit f1ed64c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/ripple/rpc/impl/RPCHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ getAccountObjects(ReadView const& ledger, AccountID const& account,
return false;

std::uint32_t i = 0;
auto& jvObjects = jvResult[jss::account_objects];
auto& jvObjects = (jvResult[jss::account_objects] = Json::arrayValue);
for (;;)
{
auto const& entries = dir->getFieldV256 (sfIndexes);
Expand Down
20 changes: 5 additions & 15 deletions src/test/rpc/AccountObjects_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,22 +512,12 @@ class AccountObjects_test : public beast::unit_test::suite
env.close();
}

// Make a lambda that easily identifies null account objects.
auto acct_objs_is_null =
[&env, &acct_objs] (Account const& acct, char const* type)
{
Json::Value const resp = acct_objs (acct, type);
return resp["result"]["account_objects"].isNull();
};

// Verify that the non-returning types still don't return anything.
// Note that, interestingly, they now return a null object rather
// than an empty array. Not sure what triggers that...
BEAST_EXPECT (acct_objs_is_null (gw, jss::account));
BEAST_EXPECT (acct_objs_is_null (gw, jss::amendments));
BEAST_EXPECT (acct_objs_is_null (gw, jss::directory));
BEAST_EXPECT (acct_objs_is_null (gw, jss::fee));
BEAST_EXPECT (acct_objs_is_null (gw, jss::hashes));
BEAST_EXPECT (acct_objs_is_empty (gw, jss::account));
BEAST_EXPECT (acct_objs_is_empty (gw, jss::amendments));
BEAST_EXPECT (acct_objs_is_empty (gw, jss::directory));
BEAST_EXPECT (acct_objs_is_empty (gw, jss::fee));
BEAST_EXPECT (acct_objs_is_empty (gw, jss::hashes));
}

void run() override
Expand Down

0 comments on commit f1ed64c

Please sign in to comment.