mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-25 05:25:55 +00:00
Include config manifest in server_info admin response (RIPD-1172)
This commit is contained in:
@@ -3378,6 +3378,10 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\rpc\tests\ServerInfo.test.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\rpc\tests\Status.test.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
|
||||
|
||||
@@ -3837,6 +3837,9 @@
|
||||
<ClCompile Include="..\..\src\ripple\rpc\tests\RobustTransaction.test.cpp">
|
||||
<Filter>ripple\rpc\tests</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\rpc\tests\ServerInfo.test.cpp">
|
||||
<Filter>ripple\rpc\tests</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\rpc\tests\Status.test.cpp">
|
||||
<Filter>ripple\rpc\tests</Filter>
|
||||
</ClCompile>
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
#include <ripple/basics/UptimeTimer.h>
|
||||
#include <ripple/protocol/JsonFields.h>
|
||||
#include <ripple/core/Config.h>
|
||||
#include <ripple/core/ConfigSections.h>
|
||||
#include <ripple/core/DeadlineTimer.h>
|
||||
#include <ripple/core/LoadFeeTrack.h>
|
||||
#include <ripple/core/TimeKeeper.h>
|
||||
@@ -67,10 +68,12 @@
|
||||
#include <ripple/resource/Fees.h>
|
||||
#include <ripple/resource/Gossip.h>
|
||||
#include <ripple/resource/ResourceManager.h>
|
||||
#include <ripple/beast/rfc2616.h>
|
||||
#include <ripple/beast/core/LexicalCast.h>
|
||||
#include <ripple/beast/core/SystemStats.h>
|
||||
#include <ripple/beast/utility/rngfill.h>
|
||||
#include <ripple/basics/make_lock.h>
|
||||
#include <beast/core/detail/base64.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#include <condition_variable>
|
||||
#include <memory>
|
||||
@@ -2021,6 +2024,30 @@ Json::Value NetworkOPsImp::getServerInfo (bool human, bool admin)
|
||||
{
|
||||
if (app_.config().VALIDATION_PUB.size ())
|
||||
{
|
||||
auto const& validation_manifest =
|
||||
app_.config().section (SECTION_VALIDATION_MANIFEST);
|
||||
|
||||
if (! validation_manifest.lines().empty())
|
||||
{
|
||||
std::string s;
|
||||
s.reserve (188);
|
||||
for (auto const& line : validation_manifest.lines())
|
||||
s += beast::rfc2616::trim(line);
|
||||
if (auto mo = make_Manifest (beast::detail::base64_decode(s)))
|
||||
{
|
||||
Json::Value valManifest = Json::objectValue;
|
||||
valManifest [jss::master_key] = toBase58 (
|
||||
TokenType::TOKEN_NODE_PUBLIC,
|
||||
mo->masterKey);
|
||||
valManifest [jss::signing_key] = toBase58 (
|
||||
TokenType::TOKEN_NODE_PUBLIC,
|
||||
mo->signingKey);
|
||||
valManifest [jss::seq] = Json::UInt (mo->sequence);
|
||||
|
||||
info[jss::validation_manifest] = valManifest;
|
||||
}
|
||||
}
|
||||
|
||||
info[jss::pubkey_validator] = toBase58 (
|
||||
TokenType::TOKEN_NODE_PUBLIC,
|
||||
app_.config().VALIDATION_PUB);
|
||||
|
||||
@@ -196,7 +196,7 @@ public:
|
||||
bool bSilent, bool bStandalone);
|
||||
|
||||
/**
|
||||
* Load the conig from the contents of the sting.
|
||||
* Load the config from the contents of the string.
|
||||
*
|
||||
* @param fileContents String representing the config contents.
|
||||
*/
|
||||
|
||||
@@ -491,16 +491,16 @@ OverlayImpl::setupValidatorKeyManifests (BasicConfig const& config,
|
||||
Throw<std::runtime_error> (
|
||||
"Unable to load keys from [" SECTION_VALIDATOR_KEYS "]");
|
||||
|
||||
auto const validation_manifest =
|
||||
auto const& validation_manifest =
|
||||
config.section (SECTION_VALIDATION_MANIFEST);
|
||||
|
||||
if (! validation_manifest.lines().empty())
|
||||
{
|
||||
std::string s;
|
||||
s.reserve (188);
|
||||
for (auto const& line : validation_manifest.lines())
|
||||
s += beast::rfc2616::trim(line);
|
||||
s = beast::detail::base64_decode(s);
|
||||
if (auto mo = make_Manifest (std::move (s)))
|
||||
if (auto mo = make_Manifest (beast::detail::base64_decode(s)))
|
||||
{
|
||||
manifestCache_.configManifest (
|
||||
std::move (*mo),
|
||||
|
||||
@@ -417,6 +417,7 @@ JSS ( validated ); // out: NetworkOPs, RPCHelpers, AccountTx*
|
||||
JSS ( validated_ledger ); // out: NetworkOPs
|
||||
JSS ( validated_ledgers ); // out: NetworkOPs
|
||||
JSS ( validation_key ); // out: ValidationCreate, ValidationSeed
|
||||
JSS ( validation_manifest ); // out: NetworkOPs
|
||||
JSS ( validation_public_key ); // out: ValidationCreate, ValidationSeed
|
||||
JSS ( validation_quorum ); // out: NetworkOPs
|
||||
JSS ( validation_seed ); // out: ValidationCreate, ValidationSeed
|
||||
|
||||
108
src/ripple/rpc/tests/ServerInfo.test.cpp
Normal file
108
src/ripple/rpc/tests/ServerInfo.test.cpp
Normal file
@@ -0,0 +1,108 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012-2016 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <BeastConfig.h>
|
||||
#include <ripple/protocol/JsonFields.h>
|
||||
#include <ripple/test/jtx.h>
|
||||
#include <ripple/beast/unit_test.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
namespace test {
|
||||
|
||||
namespace validator {
|
||||
static auto const seed = "ss7t3J9dYentEFgKdPA3q6eyxtrLB";
|
||||
static auto const master_key =
|
||||
"nHU4LxxrSQsRTKy5uZbX95eYowoamUEPCcWraxoiCNbtDaUr1V34";
|
||||
static auto const signing_key =
|
||||
"n9LHPLA36SBky1YjbaVEApQQ3s9XcpazCgfAG7jsqBb1ugDAosbm";
|
||||
// Format manifest string to test trim()
|
||||
static auto const manifest =
|
||||
" JAAAAAFxIe2FwblmJwz4pVYXHLJSzSBgIK7mpQuHNQ88CxW\n"
|
||||
" \tjIN7q4nMhAuUTyasIhvj2KPfNRbmmIBnqNUzidgkKb244eP \n"
|
||||
"\t794ZpMdkC+8l5n3R/CHP6SAwhYDOaqub0Cs2NjjewBnp1mf\n"
|
||||
"\t 23rhAzdcjRuWzm0IT12eduZ0DwcF5Ng8rAelaYP1iT93ScE\t \t";
|
||||
static auto sequence = 1;
|
||||
}
|
||||
|
||||
class ServerInfo_test : public beast::unit_test::suite
|
||||
{
|
||||
public:
|
||||
static
|
||||
std::unique_ptr<Config>
|
||||
makeValidatorConfig()
|
||||
{
|
||||
auto p = std::make_unique<Config>();
|
||||
boost::format toLoad(R"rippleConfig(
|
||||
[validation_manifest]
|
||||
%1%
|
||||
|
||||
[validation_seed]
|
||||
%2%
|
||||
)rippleConfig");
|
||||
|
||||
p->loadFromString (boost::str (
|
||||
toLoad % validator::manifest % validator::seed));
|
||||
|
||||
setupConfigForUnitTests(*p);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
void testServerInfo()
|
||||
{
|
||||
using namespace test::jtx;
|
||||
|
||||
{
|
||||
Env env(*this);
|
||||
auto const result = env.rpc("server_info", "1");
|
||||
expect (!result[jss::result].isMember (jss::error));
|
||||
expect (result[jss::status] == "success");
|
||||
expect (result[jss::result].isMember(jss::info));
|
||||
}
|
||||
{
|
||||
Env env(*this, makeValidatorConfig());
|
||||
auto const result = env.rpc("server_info", "1");
|
||||
expect (!result[jss::result].isMember (jss::error));
|
||||
expect (result[jss::status] == "success");
|
||||
expect (result[jss::result].isMember(jss::info));
|
||||
expect(result[jss::result][jss::info]
|
||||
[jss::pubkey_validator] == validator::signing_key);
|
||||
expect (result[jss::result][jss::info].isMember(
|
||||
jss::validation_manifest));
|
||||
expect (result[jss::result][jss::info][jss::validation_manifest]
|
||||
[jss::master_key] == validator::master_key);
|
||||
expect (result[jss::result][jss::info][jss::validation_manifest]
|
||||
[jss::signing_key] == validator::signing_key);
|
||||
expect (result[jss::result][jss::info][jss::validation_manifest]
|
||||
[jss::seq] == validator::sequence);
|
||||
}
|
||||
}
|
||||
|
||||
void run ()
|
||||
{
|
||||
testServerInfo ();
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(ServerInfo,app,ripple);
|
||||
|
||||
} // test
|
||||
} // ripple
|
||||
|
||||
@@ -102,5 +102,6 @@
|
||||
#include <ripple/rpc/tests/LedgerRequestRPC.test.cpp>
|
||||
#include <ripple/rpc/tests/KeyGeneration.test.cpp>
|
||||
#include <ripple/rpc/tests/RobustTransaction.test.cpp>
|
||||
#include <ripple/rpc/tests/ServerInfo.test.cpp>
|
||||
#include <ripple/rpc/tests/Status.test.cpp>
|
||||
#include <ripple/rpc/tests/Subscribe.test.cpp>
|
||||
|
||||
Reference in New Issue
Block a user