Fix RPC "active_difficulty" returning empty string as "difficulty_trend" (#3323) (#3343)

* Fix RPC "active_difficulty" returning empty string as "difficulty_trend" (#3323)

* Change active_difficulty test unit accordingly
This commit is contained in:
Shryder 2021-06-16 18:08:27 +01:00 committed by GitHub
commit baa7f4386a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View file

@ -1024,8 +1024,14 @@ void nano::json_handler::active_difficulty ()
response_l.put ("multiplier", 1.0);
if (include_trend)
{
boost::property_tree::ptree trend_entry_l;
response_l.add_child ("difficulty_trend", trend_entry_l);
boost::property_tree::ptree difficulty_trend_l;
// To keep this RPC backwards-compatible
boost::property_tree::ptree entry;
entry.put ("", "1.000000000000000");
difficulty_trend_l.push_back (std::make_pair ("", entry));
response_l.add_child ("difficulty_trend", difficulty_trend_l);
}
response_errors ();
}

View file

@ -7159,7 +7159,7 @@ TEST (rpc, active_difficulty)
auto trend_opt (response.json.get_child_optional ("difficulty_trend"));
ASSERT_TRUE (trend_opt.is_initialized ());
auto & trend (trend_opt.get ());
ASSERT_EQ (0, trend.size ());
ASSERT_EQ (1, trend.size ());
}
}