mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
feat: add user version of feature RPC (#4781)
* uses same formatting as admin RPC * hides potentially sensitive data
This commit is contained in:
@@ -288,7 +288,7 @@ public:
|
||||
uint256 const unsupportedID = amendmentId(unsupported_[0]);
|
||||
{
|
||||
Json::Value const unsupp =
|
||||
table->getJson(unsupportedID)[to_string(unsupportedID)];
|
||||
table->getJson(unsupportedID, true)[to_string(unsupportedID)];
|
||||
BEAST_EXPECT(unsupp.size() == 0);
|
||||
}
|
||||
|
||||
@@ -296,7 +296,7 @@ public:
|
||||
table->veto(unsupportedID);
|
||||
{
|
||||
Json::Value const unsupp =
|
||||
table->getJson(unsupportedID)[to_string(unsupportedID)];
|
||||
table->getJson(unsupportedID, true)[to_string(unsupportedID)];
|
||||
BEAST_EXPECT(unsupp[jss::vetoed].asBool());
|
||||
}
|
||||
}
|
||||
@@ -638,6 +638,22 @@ public:
|
||||
BEAST_EXPECT(enabled.empty());
|
||||
BEAST_EXPECT(majority.empty());
|
||||
|
||||
uint256 const unsupportedID = amendmentId(unsupported_[0]);
|
||||
{
|
||||
Json::Value const unsupp =
|
||||
table->getJson(unsupportedID, false)[to_string(unsupportedID)];
|
||||
BEAST_EXPECT(unsupp.size() == 0);
|
||||
}
|
||||
|
||||
table->veto(unsupportedID);
|
||||
{
|
||||
Json::Value const unsupp =
|
||||
table->getJson(unsupportedID, false)[to_string(unsupportedID)];
|
||||
BEAST_EXPECT(!unsupp[jss::vetoed].asBool());
|
||||
}
|
||||
|
||||
votes.emplace_back(testAmendment, validators.size());
|
||||
|
||||
votes.emplace_back(testAmendment, validators.size());
|
||||
|
||||
doRound(
|
||||
|
||||
@@ -205,11 +205,94 @@ class Feature_test : public beast::unit_test::suite
|
||||
return cfg;
|
||||
})};
|
||||
|
||||
auto jrr = env.rpc("feature")[jss::result];
|
||||
// The current HTTP/S ServerHandler returns an HTTP 403 error code here
|
||||
// rather than a noPermission JSON error. The JSONRPCClient just eats
|
||||
// that error and returns an null result.
|
||||
BEAST_EXPECT(jrr.isNull());
|
||||
{
|
||||
auto result = env.rpc("feature")[jss::result];
|
||||
BEAST_EXPECT(result.isMember(jss::features));
|
||||
// There should be at least 50 amendments. Don't do exact
|
||||
// comparison to avoid maintenance as more amendments are added in
|
||||
// the future.
|
||||
BEAST_EXPECT(result[jss::features].size() >= 50);
|
||||
for (auto it = result[jss::features].begin();
|
||||
it != result[jss::features].end();
|
||||
++it)
|
||||
{
|
||||
uint256 id;
|
||||
(void)id.parseHex(it.key().asString().c_str());
|
||||
if (!BEAST_EXPECT((*it).isMember(jss::name)))
|
||||
return;
|
||||
bool expectEnabled =
|
||||
env.app().getAmendmentTable().isEnabled(id);
|
||||
bool expectSupported =
|
||||
env.app().getAmendmentTable().isSupported(id);
|
||||
BEAST_EXPECTS(
|
||||
(*it).isMember(jss::enabled) &&
|
||||
(*it)[jss::enabled].asBool() == expectEnabled,
|
||||
(*it)[jss::name].asString() + " enabled");
|
||||
BEAST_EXPECTS(
|
||||
(*it).isMember(jss::supported) &&
|
||||
(*it)[jss::supported].asBool() == expectSupported,
|
||||
(*it)[jss::name].asString() + " supported");
|
||||
BEAST_EXPECT(!(*it).isMember(jss::vetoed));
|
||||
BEAST_EXPECT(!(*it).isMember(jss::majority));
|
||||
BEAST_EXPECT(!(*it).isMember(jss::count));
|
||||
BEAST_EXPECT(!(*it).isMember(jss::validations));
|
||||
BEAST_EXPECT(!(*it).isMember(jss::threshold));
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
Json::Value params;
|
||||
// invalid feature
|
||||
params[jss::feature] =
|
||||
"1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCD"
|
||||
"EF";
|
||||
auto const result = env.rpc(
|
||||
"json",
|
||||
"feature",
|
||||
boost::lexical_cast<std::string>(params))[jss::result];
|
||||
BEAST_EXPECTS(
|
||||
result[jss::error] == "badFeature", result.toStyledString());
|
||||
BEAST_EXPECT(
|
||||
result[jss::error_message] == "Feature unknown or invalid.");
|
||||
}
|
||||
|
||||
{
|
||||
Json::Value params;
|
||||
params[jss::feature] =
|
||||
"93E516234E35E08CA689FA33A6D38E103881F8DCB53023F728C307AA89D515"
|
||||
"A7";
|
||||
// invalid param
|
||||
params[jss::vetoed] = true;
|
||||
auto const result = env.rpc(
|
||||
"json",
|
||||
"feature",
|
||||
boost::lexical_cast<std::string>(params))[jss::result];
|
||||
BEAST_EXPECTS(
|
||||
result[jss::error] == "noPermission",
|
||||
result[jss::error].asString());
|
||||
BEAST_EXPECT(
|
||||
result[jss::error_message] ==
|
||||
"You don't have permission for this command.");
|
||||
}
|
||||
|
||||
{
|
||||
std::string const feature =
|
||||
"C4483A1896170C66C098DEA5B0E024309C60DC960DE5F01CD7AF986AA3D9AD"
|
||||
"37";
|
||||
Json::Value params;
|
||||
params[jss::feature] = feature;
|
||||
auto const result = env.rpc(
|
||||
"json",
|
||||
"feature",
|
||||
boost::lexical_cast<std::string>(params))[jss::result];
|
||||
BEAST_EXPECT(result.isMember(feature));
|
||||
auto const amendmentResult = result[feature];
|
||||
BEAST_EXPECT(amendmentResult[jss::enabled].asBool() == false);
|
||||
BEAST_EXPECT(amendmentResult[jss::supported].asBool() == true);
|
||||
BEAST_EXPECT(
|
||||
amendmentResult[jss::name].asString() ==
|
||||
"fixMasterKeyAsRegularKey");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user