xrpld
Loading...
Searching...
No Matches
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
12namespace xrpl::test {
13
14using namespace jtx;
15
33{
34 void
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
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
65 {
66 testcase("A default configuration reports the default limit");
67
68 Env env(*this);
70 }
71
72 void
79};
80
81BEAST_DEFINE_TESTSUITE(OverlayLimit, overlay, xrpl);
82
83} // namespace xrpl::test
A testsuite class.
Definition suite.h:52
TestcaseT testcase
Memberspace for declaring test cases.
Definition suite.h:155
virtual int limit()=0
Returns the maximum number of peers we are configured to allow.
virtual Overlay & getOverlay()=0
Tests for Overlay::limit(), the configured peer allowance reported once OverlayImpl::start() applies ...
void run() override
Runs the suite.
A transaction testing environment.
Definition Env.h:161
Application & app()
Definition Env.h:300
static constexpr auto kDefaultMaxPeers
The default value of Config::maxPeers.
std::unique_ptr< Config > envconfig()
creates and initializes a default configuration for jtx::Env
Definition envconfig.h:38
BEAST_DEFINE_TESTSUITE(AMMClawback, app, xrpl)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5