xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
test
overlay
overlay_limit_test.cpp
1
#include <test/jtx/Env.h>
2
#include <test/jtx/envconfig.h>
3
4
#include <xrpld/app/main/Application.h>
5
#include <xrpld/overlay/Overlay.h>
6
7
#include <xrpl/beast/unit_test/suite.h>
8
#include <xrpl/peerfinder/detail/Tuning.h>
9
10
#include <
utility
>
11
12
namespace
xrpl::test
{
13
14
using namespace
jtx
;
15
32
class
OverlayLimit_test
:
public
beast::unit_test::Suite
33
{
34
void
35
testLegacyPeersMax
()
36
{
37
testcase
(
"Legacy peers_max is reported"
);
38
39
auto
config =
jtx::envconfig
();
40
config->peersMax = 40;
41
42
Env
env(*
this
, std::move(config));
43
BEAST_EXPECT(env.
app
().
getOverlay
().
limit
() == 40);
44
}
45
46
void
47
testPerDirectionPeerLimits
()
48
{
49
testcase
(
"Per-direction peer limits are reported"
);
50
51
// With incoming connections disabled the 50 inbound slots are dropped
52
// and only the outbound allowance remains, so neither zero (the value
53
// `maxPeers` used to hold in this branch of makeConfig) nor 70 (the
54
// unconditional sum of both directions) is correct.
55
auto
config =
jtx::envconfig
();
56
config->peersInMax = 50;
57
config->peersOutMax = 20;
58
59
Env
env(*
this
, std::move(config));
60
BEAST_EXPECT(env.
app
().
getOverlay
().
limit
() == 20);
61
}
62
63
void
64
testDefaultConfig
()
65
{
66
testcase
(
"A default configuration reports the default limit"
);
67
68
Env
env(*
this
);
69
BEAST_EXPECT(env.
app
().
getOverlay
().
limit
() ==
peer_finder::tuning::kDefaultMaxPeers
);
70
}
71
72
void
73
run
()
override
74
{
75
testLegacyPeersMax
();
76
testPerDirectionPeerLimits
();
77
testDefaultConfig
();
78
}
79
};
80
81
BEAST_DEFINE_TESTSUITE
(OverlayLimit, overlay,
xrpl
);
82
83
}
// namespace xrpl::test
beast::unit_test::Suite
A testsuite class.
Definition
suite.h:52
beast::unit_test::Suite::testcase
TestcaseT testcase
Memberspace for declaring test cases.
Definition
suite.h:155
xrpl::Overlay::limit
virtual int limit()=0
Returns the maximum number of peers we are configured to allow.
xrpl::ServiceRegistry::getOverlay
virtual Overlay & getOverlay()=0
xrpl::test::OverlayLimit_test
Tests for Overlay::limit(), the configured peer allowance reported once OverlayImpl::start() applies ...
Definition
overlay_limit_test.cpp:33
xrpl::test::OverlayLimit_test::testDefaultConfig
void testDefaultConfig()
Definition
overlay_limit_test.cpp:64
xrpl::test::OverlayLimit_test::testPerDirectionPeerLimits
void testPerDirectionPeerLimits()
Definition
overlay_limit_test.cpp:47
xrpl::test::OverlayLimit_test::testLegacyPeersMax
void testLegacyPeersMax()
Definition
overlay_limit_test.cpp:35
xrpl::test::OverlayLimit_test::run
void run() override
Runs the suite.
Definition
overlay_limit_test.cpp:73
xrpl::test::jtx::Env
A transaction testing environment.
Definition
Env.h:161
xrpl::test::jtx::Env::app
Application & app()
Definition
Env.h:300
xrpl::peer_finder::tuning::kDefaultMaxPeers
static constexpr auto kDefaultMaxPeers
The default value of Config::maxPeers.
Definition
include/xrpl/peerfinder/detail/Tuning.h:48
xrpl::test::jtx
Definition
Oracle_test.cpp:34
xrpl::test::jtx::envconfig
std::unique_ptr< Config > envconfig()
creates and initializes a default configuration for jtx::Env
Definition
envconfig.h:38
xrpl::test
Definition
STLedgerEntry.h:21
xrpl::test::BEAST_DEFINE_TESTSUITE
BEAST_DEFINE_TESTSUITE(AMMClawback, app, xrpl)
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
utility
Generated by
1.17.0