Skip to content

Commit

Permalink
Add confirmed_height in account_info RPC to be consistent (#3039)
Browse files Browse the repository at this point in the history
  • Loading branch information
wezrule authored Dec 14, 2020
1 parent 3963230 commit d35800a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion nano/node/json_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -638,15 +638,16 @@ void nano::json_handler::account_info ()
response_l.put ("modified_timestamp", std::to_string (info.modified));
response_l.put ("block_count", std::to_string (info.block_count));
response_l.put ("account_version", epoch_as_string (info.epoch ()));
response_l.put ("confirmation_height", std::to_string (confirmation_height_info.height));
auto confirmed_frontier = confirmation_height_info.frontier.to_string ();
if (include_confirmed)
{
response_l.put ("confirmed_height", std::to_string (confirmation_height_info.height));
response_l.put ("confirmed_frontier", confirmed_frontier);
}
else
{
// For backwards compatibility purposes
response_l.put ("confirmation_height", std::to_string (confirmation_height_info.height));
response_l.put ("confirmation_height_frontier", confirmed_frontier);
}

Expand Down
16 changes: 14 additions & 2 deletions nano/rpc_test/rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4859,16 +4859,22 @@ TEST (rpc, account_info)
{
test_response response (request, rpc.config.port, system.io_ctx);
ASSERT_TIMELY (5s, response.status != 0);
std::string balance (response.json.get<std::string> ("balance"));
auto balance (response.json.get<std::string> ("balance"));
ASSERT_EQ ("25", balance);
std::string confirmed_balance (response.json.get<std::string> ("confirmed_balance"));
auto confirmed_balance (response.json.get<std::string> ("confirmed_balance"));
ASSERT_EQ ("340282366920938463463374607431768211455", confirmed_balance);

auto representative (response.json.get<std::string> ("representative"));
ASSERT_EQ (representative, key1.pub.to_account ());

auto confirmed_representative (response.json.get<std::string> ("confirmed_representative"));
ASSERT_EQ (confirmed_representative, nano::dev_genesis_key.pub.to_account ());

auto confirmed_frontier (response.json.get<std::string> ("confirmed_frontier"));
ASSERT_EQ (nano::genesis_hash.to_string (), confirmed_frontier);

auto confirmed_height (response.json.get<uint64_t> ("confirmed_height"));
ASSERT_EQ (1, confirmed_height);
}

request.put ("account", key1.pub.to_account ());
Expand Down Expand Up @@ -4897,6 +4903,12 @@ TEST (rpc, account_info)

auto confirmed_representative (response.json.get_optional<std::string> ("confirmed_representative"));
ASSERT_FALSE (confirmed_representative.is_initialized ());

auto confirmed_frontier (response.json.get_optional<std::string> ("confirmed_frontier"));
ASSERT_FALSE (confirmed_frontier.is_initialized ());

auto confirmed_height (response.json.get_optional<uint64_t> ("confirmed_height"));
ASSERT_FALSE (confirmed_height.is_initialized ());
}
}

Expand Down

0 comments on commit d35800a

Please sign in to comment.