Result difficulty in RPC block_create (#2752)

This commit is contained in:
Guilherme Lawless 2020-04-30 20:22:26 +01:00 committed by GitHub
commit 28b8ece8c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 0 deletions

View file

@ -1370,6 +1370,7 @@ void nano::json_handler::block_create ()
auto block_response_put_l = [rpc_l, this](nano::block const & block_a) {
boost::property_tree::ptree response_l;
response_l.put ("hash", block_a.hash ().to_string ());
response_l.put ("difficulty", nano::to_string_hex (block_a.difficulty ()));
bool json_block_l = request.get<bool> ("json_block", false);
if (json_block_l)
{

View file

@ -5826,6 +5826,8 @@ TEST (rpc, block_create)
ASSERT_EQ (200, response.status);
std::string send_hash (response.json.get<std::string> ("hash"));
ASSERT_EQ (send.hash ().to_string (), send_hash);
std::string send_difficulty (response.json.get<std::string> ("difficulty"));
ASSERT_EQ (nano::to_string_hex (send.difficulty ()), send_difficulty);
auto send_text (response.json.get<std::string> ("block"));
boost::property_tree::ptree block_l;
std::stringstream block_stream (send_text);