1#include <test/unit_test/SuiteJournal.h> 
    3#include <xrpl/basics/chrono.h> 
    4#include <xrpl/basics/random.h> 
    5#include <xrpl/beast/unit_test.h> 
    6#include <xrpl/resource/Consumer.h> 
    7#include <xrpl/resource/detail/Entry.h> 
    8#include <xrpl/resource/detail/Logic.h> 
   10#include <boost/utility/base_from_member.hpp> 
   20    class TestLogic : 
private boost::base_from_member<TestStopwatch>,
 
   25        using clock_type = boost::base_from_member<TestStopwatch>;
 
   29            : 
Logic(
beast::insight::NullCollector::New(), member, journal)
 
 
 
   53        gossip.
items.reserve(n);
 
   58            beast::IP::AddressV4::bytes_type d = {
 
   61            gossip.
items.push_back(item);
 
 
   87                  std::placeholders::_1);
 
  100                        fail(
"Loop count exceeded without warning");
 
  111                        fail(
"Should loop forever with no warning");
 
  123                        fail(
"Loop count exceeded without dropping");
 
  146                    fail(
"Dropped consumer not put on blacklist");
 
  154        bool readmitted = 
false;
 
  156            using namespace std::chrono_literals;
 
  172        if (readmitted == 
false)
 
  174            fail(
"Dropped Consumer left on blacklist too long");
 
 
  189        for (
int i = 0; i < 5; ++i)
 
  192        for (
int i = 0; i < 5; ++i)
 
 
  208        beast::IP::AddressV4::bytes_type d = {{192, 0, 2, 1}};
 
  210        g.
items.push_back(item);
 
 
  232            for (
int i = 0; i < 128; ++i)
 
  234                JLOG(j.
info()) << 
"Time= " 
  235                               << logic.
clock().
now().time_since_epoch().count()
 
  236                               << 
", Balance = " << c.
balance();
 
  248            for (
int i = 0; i < 128; ++i)
 
  251                JLOG(j.
info()) << 
"Time= " 
  252                               << logic.
clock().
now().time_since_epoch().count()
 
  253                               << 
", Balance = " << c.
balance();
 
 
 
  275BEAST_DEFINE_TESTSUITE(ResourceManager, resource, 
ripple);
 
A version-independent IP address and port combination.
 
static Endpoint from_string(std::string const &s)
 
A generic endpoint for log messages.
 
time_point now() const override
Returns the current time.
 
void pass()
Record a successful test condition.
 
testcase_t testcase
Memberspace for declaring test cases.
 
void fail(String const &reason, char const *file, int line)
Record a failure.
 
An endpoint that consumes resources.
 
int balance()
Returns the credit balance representing consumption.
 
std::string to_string() const
Return a human readable string uniquely identifying this consumer.
 
bool disconnect(beast::Journal const &j)
Returns true if the consumer should be disconnected.
 
Disposition charge(Charge const &fee, std::string const &context={})
Apply a load charge to the consumer.
 
Disposition disposition() const
Returns the current disposition of this consumer.
 
Consumer newInboundEndpoint(beast::IP::Endpoint const &address)
 
void importConsumers(std::string const &origin, Gossip const &gossip)
 
Consumer newUnlimitedEndpoint(beast::IP::Endpoint const &address)
Create endpoint that should not have resource limits applied.
 
TestLogic(beast::Journal journal)
 
boost::base_from_member< TestStopwatch > clock_type
 
void testDrop(beast::Journal j, bool limited)
 
void testImport(beast::Journal j)
 
void run() override
Runs the suite.
 
void createGossip(Gossip &gossip)
 
void testCharges(beast::Journal j)
 
void testImports(beast::Journal j)
 
boost::asio::ip::address_v4 AddressV4
 
A namespace for easy access to logging severity values.
 
@ warn
Consumer should be disconnected for excess consumption.
 
std::chrono::seconds constexpr secondsUntilExpiration
 
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
 
std::enable_if_t< std::is_integral< Integral >::value, Integral > rand_int()
 
Describes a single consumer.
 
beast::IP::Endpoint address
 
Data format for exchanging consumption information across peers.
 
std::vector< Item > items