mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Format first-party source according to .clang-format
This commit is contained in:
committed by
manojsdoshi
parent
65dfc5d19e
commit
50760c6935
@@ -17,67 +17,63 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <test/jtx.h>
|
||||
#include <test/jtx/Env.h>
|
||||
#include <ripple/protocol/jss.h>
|
||||
#include <ripple/overlay/Cluster.h>
|
||||
#include <ripple/overlay/Overlay.h>
|
||||
#include <ripple/protocol/jss.h>
|
||||
#include <test/jtx.h>
|
||||
#include <test/jtx/Env.h>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
class Peers_test : public beast::unit_test::suite
|
||||
{
|
||||
void testRequest()
|
||||
void
|
||||
testRequest()
|
||||
{
|
||||
testcase("Basic request");
|
||||
using namespace test::jtx;
|
||||
Env env {*this};
|
||||
Env env{*this};
|
||||
|
||||
// without modification of the cluster, expect an empty set
|
||||
// from this request
|
||||
auto peers = env.rpc("peers")[jss::result];
|
||||
BEAST_EXPECT(peers.isMember(jss::cluster) &&
|
||||
peers[jss::cluster].size() == 0 );
|
||||
BEAST_EXPECT(peers.isMember(jss::peers) &&
|
||||
peers[jss::peers].isNull());
|
||||
BEAST_EXPECT(
|
||||
peers.isMember(jss::cluster) && peers[jss::cluster].size() == 0);
|
||||
BEAST_EXPECT(peers.isMember(jss::peers) && peers[jss::peers].isNull());
|
||||
|
||||
// insert some nodes in to the cluster
|
||||
std::unordered_map<std::string, std::string> nodes;
|
||||
for(auto i =0; i < 3; ++i)
|
||||
for (auto i = 0; i < 3; ++i)
|
||||
{
|
||||
|
||||
auto kp = generateKeyPair (KeyType::secp256k1,
|
||||
generateSeed("seed" + std::to_string(i)));
|
||||
auto kp = generateKeyPair(
|
||||
KeyType::secp256k1, generateSeed("seed" + std::to_string(i)));
|
||||
|
||||
std::string name = "Node " + std::to_string(i);
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
env.app().cluster().update(
|
||||
kp.first,
|
||||
name,
|
||||
200,
|
||||
env.timeKeeper().now() - 10s);
|
||||
nodes.insert( std::make_pair(
|
||||
kp.first, name, 200, env.timeKeeper().now() - 10s);
|
||||
nodes.insert(std::make_pair(
|
||||
toBase58(TokenType::NodePublic, kp.first), name));
|
||||
}
|
||||
|
||||
// make request, verify nodes we created match
|
||||
// what is reported
|
||||
peers = env.rpc("peers")[jss::result];
|
||||
if(! BEAST_EXPECT(peers.isMember(jss::cluster)))
|
||||
if (!BEAST_EXPECT(peers.isMember(jss::cluster)))
|
||||
return;
|
||||
if(! BEAST_EXPECT(peers[jss::cluster].size() == nodes.size()))
|
||||
if (!BEAST_EXPECT(peers[jss::cluster].size() == nodes.size()))
|
||||
return;
|
||||
for(auto it = peers[jss::cluster].begin();
|
||||
it != peers[jss::cluster].end();
|
||||
++it)
|
||||
for (auto it = peers[jss::cluster].begin();
|
||||
it != peers[jss::cluster].end();
|
||||
++it)
|
||||
{
|
||||
auto key = it.key().asString();
|
||||
auto search = nodes.find(key);
|
||||
if(! BEAST_EXPECTS(search != nodes.end(), key))
|
||||
if (!BEAST_EXPECTS(search != nodes.end(), key))
|
||||
continue;
|
||||
if(! BEAST_EXPECT((*it).isMember(jss::tag)))
|
||||
if (!BEAST_EXPECT((*it).isMember(jss::tag)))
|
||||
continue;
|
||||
auto tag = (*it)[jss::tag].asString();
|
||||
BEAST_EXPECTS((*it)[jss::tag].asString() == nodes[key], key);
|
||||
@@ -86,12 +82,13 @@ class Peers_test : public beast::unit_test::suite
|
||||
}
|
||||
|
||||
public:
|
||||
void run () override
|
||||
void
|
||||
run() override
|
||||
{
|
||||
testRequest();
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE (Peers, rpc, ripple);
|
||||
BEAST_DEFINE_TESTSUITE(Peers, rpc, ripple);
|
||||
|
||||
} // ripple
|
||||
} // namespace ripple
|
||||
|
||||
Reference in New Issue
Block a user