1#include <test/jtx/Account.h>
2#include <test/jtx/Env.h>
3#include <test/jtx/PeerStub.h>
4#include <test/jtx/amount.h>
5#include <test/jtx/batch.h>
6#include <test/jtx/envconfig.h>
7#include <test/jtx/fee.h>
8#include <test/jtx/pay.h>
9#include <test/jtx/seq.h>
10#include <test/jtx/sig.h>
11#include <test/jtx/tags.h>
12#include <test/jtx/ter.h>
14#include <xrpld/app/ledger/BuildLedger.h>
15#include <xrpld/app/ledger/InboundLedger.h>
16#include <xrpld/app/ledger/InboundLedgers.h>
17#include <xrpld/app/ledger/LedgerMaster.h>
18#include <xrpld/app/ledger/LedgerReplay.h>
19#include <xrpld/app/ledger/LedgerReplayTask.h>
20#include <xrpld/app/ledger/LedgerReplayer.h>
21#include <xrpld/app/ledger/detail/LedgerDeltaAcquire.h>
22#include <xrpld/app/ledger/detail/LedgerReplayMsgHandler.h>
23#include <xrpld/app/ledger/detail/SkipListAcquire.h>
24#include <xrpld/core/Config.h>
25#include <xrpld/overlay/Peer.h>
26#include <xrpld/overlay/PeerSet.h>
27#include <xrpld/overlay/detail/Handshake.h>
29#include <xrpl/basics/Slice.h>
30#include <xrpl/basics/base_uint.h>
31#include <xrpl/beast/net/IPAddress.h>
32#include <xrpl/beast/unit_test/suite.h>
33#include <xrpl/beast/utility/Journal.h>
34#include <xrpl/json/json_value.h>
35#include <xrpl/ledger/ApplyView.h>
36#include <xrpl/protocol/Indexes.h>
37#include <xrpl/protocol/RippleLedgerHash.h>
38#include <xrpl/protocol/TER.h>
39#include <xrpl/protocol/TxFlags.h>
40#include <xrpl/server/Handoff.h>
41#include <xrpl/shamap/SHAMapItem.h>
43#include <boost/asio/ip/address.hpp>
45#include <google/protobuf/message.h>
81 auto const alice =
Account(
"alice");
82 auto const bob =
Account(
"bob");
85 env.
fund(
XRP(100000), alice, bob);
90 auto const lastClosedParent = ledgerMaster.
getLedgerByHash(lastClosed->header().parentHash);
95 BEAST_EXPECT(replayed->header().hash == lastClosed->header().hash);
101 testcase(
"Replay ledger with batch transactions");
107 auto const alice =
Account(
"alice");
108 auto const bob =
Account(
"bob");
109 env.
fund(
XRP(100000), alice, bob);
112 auto const seq = env.
seq(alice);
122 auto const lastClosedParent = ledgerMaster.
getLedgerByHash(lastClosed->header().parentHash);
127 BEAST_EXPECT(replayed->header().hash == lastClosed->header().hash);
316 bool enableLedgerReplay)
336 ::google::protobuf::Message
const& msg,
337 protocol::MessageType type,
351 case protocol::mtPROOF_PATH_REQ: {
355 dynamic_cast<protocol::TMProofPathRequest const&
>(msg));
357 remote.processProofPathRequest(request));
358 local.processProofPathResponse(reply);
360 local.processProofPathResponse(reply);
363 case protocol::mtREPLAY_DELTA_REQ: {
367 dynamic_cast<protocol::TMReplayDeltaRequest const&
>(msg));
369 remote.processReplayDeltaRequest(request));
370 local.processReplayDeltaResponse(reply);
372 local.processReplayDeltaResponse(reply);
447 assert(
param.initLedgers > 0);
459 auto fundedAccounts =
accounts.size();
460 for (
int i = 0; i < newAccounts; ++i)
474 int fundedAccounts =
accounts.size();
475 assert(fundedAccounts >= newTxes);
482 auto updateIdx = [&]() {
483 assert(fundedAccounts > senders.
size());
484 fromIdx = (fromIdx + r) % fundedAccounts;
486 fromIdx = (fromIdx + 1) % fundedAccounts;
488 toIdx = (toIdx + (r * 2)) % fundedAccounts;
489 if (toIdx == fromIdx)
490 toIdx = (toIdx + 1) % fundedAccounts;
493 for (
int i = 0; i < newTxes; ++i)
513 for (
int i = 0; i <
param.initLedgers - 1; ++i)
576 UInt256 hash = finishLedgerHash;
578 for (; i < totalReplay; ++i)
583 hash = l->header().parentHash;
591 int const totalRound = 100;
592 for (
int i = 0; i < totalRound; ++i)
596 if (i < totalRound - 1)
605 int const totalRound = 100;
606 for (
int i = 0; i < totalRound; ++i)
611 for (
auto const& t :
replayer.tasks_)
622 if (i < totalRound - 1)
640 return t->parameter_.finishHash == hash && t->parameter_.totalLedgers == totalReplay;
665 return replayer.tasks_.size() == tasks &&
replayer.skipLists_.size() == skipLists &&
673 auto i =
replayer.skipLists_.find(hash);
676 return i->second.lock();
683 auto i =
replayer.deltas_.find(hash);
686 return i->second.lock();
689 template <
typename T>
709 if (
taskStatus(task->skipListAcquirer_) == skiplistExpect)
711 if (task->deltas_.size() == deltaExpects.
size())
713 for (
int i = 0; i < deltaExpects.
size(); ++i)
715 if (
taskStatus(task->deltas_[i]) != deltaExpects[i])
733 auto t =
findTask(hash, totalReplay);
739 return asExpected(t, taskExpect, skiplistExpect, deltaExpects);
750 auto t =
findTask(hash, totalReplay);
756 return asExpected(t, taskExpect, skiplistExpect, deltaExpects);
770 return checkStatus(hash, totalReplay, taskExpect, skiplistExpect, deltaExpects);
847 request->set_ledgerhash(l->header().hash.data(), l->header().hash.size());
848 request->set_type(protocol::TMLedgerMapType::lmACCOUNT_STATE);
850 server.msgHandler.processProofPathRequest(request));
851 BEAST_EXPECT(reply->has_error());
858 request->set_type(protocol::TMLedgerMapType::lmACCOUNT_STATE);
861 request->set_ledgerhash(hash.
data(), hash.
size());
863 server.msgHandler.processProofPathRequest(request));
864 BEAST_EXPECT(reply->has_error());
870 request->set_ledgerhash(l->header().hash.data(), l->header().hash.size());
871 request->set_type(protocol::TMLedgerMapType::lmACCOUNT_STATE);
875 server.msgHandler.processProofPathRequest(request));
876 BEAST_EXPECT(!reply->has_error());
886 server.msgHandler.processProofPathResponse(bad) ==
894 server.msgHandler.processProofPathResponse(bad) ==
902 server.msgHandler.processProofPathResponse(bad) ==
910 server.msgHandler.processProofPathResponse(bad) ==
918 server.msgHandler.processProofPathResponse(bad) ==
926 server.msgHandler.processProofPathResponse(bad) ==
936 reply->set_ledgerheader(r);
938 server.msgHandler.processProofPathResponse(reply) ==
941 reply->set_ledgerheader(r);
945 reply->mutable_path()->RemoveLast();
947 server.msgHandler.processProofPathResponse(reply) ==
964 server.msgHandler.processReplayDeltaRequest(request));
965 BEAST_EXPECT(reply->has_error());
970 request->set_ledgerhash(hash.
data(), hash.
size());
972 server.msgHandler.processReplayDeltaRequest(request));
973 BEAST_EXPECT(reply->has_error());
981 request->set_ledgerhash(l->header().hash.data(), l->header().hash.size());
983 server.msgHandler.processReplayDeltaRequest(request));
984 BEAST_EXPECT(!reply->has_error());
995 server.msgHandler.processReplayDeltaResponse(bad) ==
1003 server.msgHandler.processReplayDeltaResponse(bad) ==
1011 server.msgHandler.processReplayDeltaResponse(bad) ==
1021 reply->set_ledgerheader(r);
1023 server.msgHandler.processReplayDeltaResponse(reply) ==
1026 reply->set_ledgerheader(r);
1030 reply->mutable_transaction()->RemoveLast();
1032 server.msgHandler.processReplayDeltaResponse(reply) ==
1045 auto runNoThrow = [
this](
auto fn,
char const* what) {
1053 std::format(
"processor threw on truncated header ({}): {}", what, e.
what()),
1060 std::format(
"processor threw unknown exception ({}) on truncated header", what),
1068 request->set_ledgerhash(l->header().hash.data(), l->header().hash.size());
1070 server.msgHandler.processReplayDeltaRequest(request));
1071 BEAST_EXPECT(!reply->has_error());
1075 [&] {
return server.msgHandler.processReplayDeltaResponse(reply); },
"ReplayDelta");
1080 request->set_ledgerhash(l->header().hash.data(), l->header().hash.size());
1081 request->set_type(protocol::TMLedgerMapType::lmACCOUNT_STATE);
1084 server.msgHandler.processProofPathRequest(request));
1085 BEAST_EXPECT(!reply->has_error());
1089 [&] {
return server.msgHandler.processProofPathResponse(reply); },
"ProofPath");
1101 for (
int i = 0; i < count; ++i)
1107 BEAST_EXPECT(!tp10.
update(
UInt256(777), 5, makeSkipList(10)));
1108 BEAST_EXPECT(!tp10.
update(
UInt256(10), 5, makeSkipList(8)));
1109 BEAST_EXPECT(tp10.
update(
UInt256(10), 10, makeSkipList(10)));
1137 BEAST_EXPECT(tp20.
update(
UInt256(20), 20, makeSkipList(20)));
1178 auto handshake = [&](
bool client,
bool server,
bool expecting) ->
bool {
1181 httpRequest.version(request.version());
1182 httpRequest.base() = request.base();
1184 if (serverResult != expecting)
1188 jtx::Env serverEnv(*
this);
1189 serverEnv.app().config().ledgerReplay = server;
1191 true, httpRequest, addr, addr,
UInt256{1}, 1, {1, 0}, serverEnv.app());
1193 return clientResult == expecting;
1196 BEAST_EXPECT(handshake(
false,
false,
false));
1197 BEAST_EXPECT(handshake(
false,
true,
false));
1198 BEAST_EXPECT(handshake(
true,
false,
false));
1199 BEAST_EXPECT(handshake(
true,
true,
true));
1205 testcase(
"local node has all the ledgers");
1210 NetworkOfTwo net(*
this, {.initLedgers = totalReplay + 1}, psBhvr, ilBhvr, peerFeature);
1213 UInt256 const finalHash = l->header().hash;
1214 for (
int i = 0; i < totalReplay; ++i)
1219 net.client.ledgerMaster.storeLedger(l);
1220 l = net.server.ledgerMaster.getLedgerByHash(l->header().parentHash);
1231 BEAST_EXPECT(net.client.waitAndCheckStatus(
1235 net.client.replayer.sweep();
1236 BEAST_EXPECT(net.client.countsAsExpected(0, 0, 0));
1242 testcase(
"all the ledgers from InboundLedgers");
1245 {.initLedgers = totalReplay + 1},
1251 UInt256 const finalHash = l->header().hash;
1255 BEAST_EXPECT(net.client.waitAndCheckStatus(
1266 auto waitForSweep = [&net]() {
1267 for (
auto numAttempts = 0; numAttempts < 20; ++numAttempts)
1269 net.client.replayer.sweep();
1270 if (net.client.countsAsExpected(0, 0, 0))
1278 BEAST_EXPECT(waitForSweep());
1284 switch (peerSetBehavior)
1290 testcase(
"network drops 50% messages");
1293 testcase(
"network repeats all messages");
1301 {.initLedgers = totalReplay + 1},
1307 auto l = net.server.ledgerMaster.getClosedLedger();
1308 UInt256 const finalHash = l->header().hash;
1309 for (
int i = 0; i < totalReplay - 1; ++i)
1311 l = net.server.ledgerMaster.getLedgerByHash(l->header().parentHash);
1313 net.client.ledgerMaster.storeLedger(l);
1318 BEAST_EXPECT(net.client.waitAndCheckStatus(
1320 BEAST_EXPECT(net.client.waitForLedgers(finalHash, totalReplay));
1323 net.client.replayer.sweep();
1324 BEAST_EXPECT(net.client.countsAsExpected(0, 0, 0));
1331 int const totalReplay = 3;
1334 {.initLedgers = totalReplay + 1},
1340 UInt256 const finalHash = l->header().hash;
1344 BEAST_EXPECT(net.client.checkStatus(
1347 BEAST_EXPECT(net.client.countsAsExpected(1, 1, 0));
1348 net.client.replayer.stop();
1349 BEAST_EXPECT(net.client.countsAsExpected(0, 0, 0));
1355 testcase(
"SkipListAcquire bad reply");
1356 int const totalReplay = 3;
1359 {.initLedgers = totalReplay + 1 + 1},
1365 UInt256 const finalHash = l->header().hash;
1368 auto skipList = net.client.findSkipListAcquire(finalHash);
1370 std::uint8_t payload[55] = {0x6A, 0x09, 0xE6, 0x67, 0xF3, 0xBC, 0xC9, 0x08, 0xB2};
1372 skipList->processData(l->seq(), item);
1375 BEAST_EXPECT(net.client.waitAndCheckStatus(
1380 BEAST_EXPECT(net.client.waitAndCheckStatus(
1382 BEAST_EXPECT(net.client.countsAsExpected(2, 1, 0));
1388 testcase(
"LedgerDeltaAcquire bad reply");
1389 int const totalReplay = 3;
1392 {.initLedgers = totalReplay + 1},
1398 UInt256 const finalHash = l->header().hash;
1399 net.client.ledgerMaster.storeLedger(l);
1402 auto delta = net.client.findLedgerDeltaAcquire(l->header().parentHash);
1408 net.client.taskStatus(net.client.findTask(finalHash, totalReplay)) ==
1414 net.client.taskStatus(net.client.findTask(finalHash, totalReplay + 1)) ==
1422 int const totalReplay = 5;
1425 {.initLedgers = (totalReplay * 3) + 1},
1430 UInt256 const finalHash = l->header().hash;
1433 BEAST_EXPECT(net.client.waitAndCheckStatus(
1435 BEAST_EXPECT(net.client.waitForLedgers(finalHash, totalReplay));
1439 BEAST_EXPECT(net.client.countsAsExpected(1, 1, totalReplay - 1));
1442 BEAST_EXPECT(net.client.countsAsExpected(2, 1, totalReplay - 1));
1445 for (
int i = 0; i < totalReplay + 2; ++i)
1447 l = net.server.ledgerMaster.getLedgerByHash(l->header().parentHash);
1449 auto finalHashEarly = l->header().hash;
1451 BEAST_EXPECT(net.client.waitAndCheckStatus(
1457 BEAST_EXPECT(net.client.waitForLedgers(finalHashEarly, totalReplay));
1458 BEAST_EXPECT(net.client.countsAsExpected(3, 2, 2 * (totalReplay - 1)));
1461 l = net.server.ledgerMaster.getLedgerByHash(l->header().parentHash);
1462 auto finalHashMoreEarly = l->header().parentHash;
1464 BEAST_EXPECT(net.client.waitAndCheckStatus(
1470 BEAST_EXPECT(net.client.waitForLedgers(finalHashMoreEarly, totalReplay));
1471 BEAST_EXPECT(net.client.countsAsExpected(4, 3, (2 * (totalReplay - 1)) + 2));
1476 BEAST_EXPECT(net.client.waitAndCheckStatus(
1482 BEAST_EXPECT(net.client.waitForLedgers(finalHash, totalReplay * 3));
1483 BEAST_EXPECT(net.client.countsAsExpected(5, 3, (totalReplay * 3) - 1));
1486 net.client.replayer.sweep();
1487 BEAST_EXPECT(net.client.countsAsExpected(0, 0, 0));
1519 testcase(
"SkipListAcquire timeout");
1520 int const totalReplay = 3;
1523 {.initLedgers = totalReplay + 1},
1529 UInt256 const finalHash = l->header().hash;
1533 BEAST_EXPECT(net.client.waitAndCheckStatus(
1537 BEAST_EXPECT(net.client.countsAsExpected(1, 1, 0));
1538 net.client.replayer.sweep();
1539 BEAST_EXPECT(net.client.countsAsExpected(0, 0, 0));
1545 testcase(
"LedgerDeltaAcquire timeout");
1546 int const totalReplay = 3;
1549 {.initLedgers = totalReplay + 1},
1555 UInt256 const finalHash = l->header().hash;
1556 net.client.ledgerMaster.storeLedger(l);
1561 BEAST_EXPECT(net.client.waitAndCheckStatus(
1565 BEAST_EXPECT(net.client.countsAsExpected(1, 1, totalReplay - 1));
1566 net.client.replayer.sweep();
1567 BEAST_EXPECT(net.client.countsAsExpected(0, 0, 0));
1584 int const totalReplay = 250;
1585 int const rounds = 4;
1588 {.initLedgers = (totalReplay * rounds) + 1},
1594 auto l = net.server.ledgerMaster.getClosedLedger();
1595 for (
int i = 0; i < rounds; ++i)
1597 finishHashes.push_back(l->header().hash);
1598 for (
int j = 0; j < totalReplay; ++j)
1600 l = net.server.ledgerMaster.getLedgerByHash(l->header().parentHash);
1603 BEAST_EXPECT(finishHashes.size() == rounds);
1605 for (
int i = 0; i < rounds; ++i)
1607 net.client.replayer.replay(
1612 for (
int i = 0; i < rounds; ++i)
1614 BEAST_EXPECT(net.client.waitAndCheckStatus(
1622 BEAST_EXPECT(net.client.waitForLedgers(finishHashes[0], totalReplay * rounds));
1623 BEAST_EXPECT(net.client.countsAsExpected(rounds, rounds, rounds * (totalReplay - 1)));
1626 net.client.replayer.sweep();
1627 BEAST_EXPECT(net.client.countsAsExpected(0, 0, 0));
void fail(String const &reason, char const *file, int line)
Record a failure.
TestcaseT testcase
Memberspace for declaring test cases.
static constexpr std::size_t size()
void loadFromString(std::string const &fileContents)
Load the config from the contents of the string.
Manages the lifetime of inbound ledgers.
Tracks the current ledger and any ledgers in the process of closing.
std::shared_ptr< Ledger const > getClosedLedger()
The finalized ledger is the last closed/accepted ledger.
std::shared_ptr< Ledger const > getLedgerByHash(UInt256 const &hash)
InboundLedger::Reason reason
std::uint32_t totalLedgers
bool update(UInt256 const &hash, std::uint32_t seq, std::vector< UInt256 > const &sList)
fill all the fields that was not filled during construction
bool canMergeInto(TaskParameter const &existingTask) const
check if this task can be merged into an existing task
Manages the lifetime of ledger replay tasks.
beast::Severity threshold() const
Supports data retrieval by managing a set of peers.
virtual LedgerMaster & getLedgerMaster()=0
virtual Logs & getLogs()=0
Ledger replay client side.
LedgerReplayClient(beast::unit_test::Suite &suite, LedgerServer &server, PeerSetBehavior behavior=PeerSetBehavior::Good, InboundLedgersBehavior inboundBhvr=InboundLedgersBehavior::Good, PeerFeature peerFeature=PeerFeature::LedgerReplayEnabled)
TaskStatus taskStatus(std::shared_ptr< T > const &t)
std::size_t countDeltas()
std::vector< std::shared_ptr< LedgerReplayTask > > getTasks()
LedgerMaster & ledgerMaster
MagicInboundLedgers inboundLedgers
bool haveLedgers(UInt256 const &finishLedgerHash, int totalReplay)
std::size_t countSkipLists()
bool asExpected(UInt256 const &hash, int totalReplay, TaskStatus taskExpect, TaskStatus skiplistExpect, std::vector< TaskStatus > const &deltaExpects)
LedgerReplayMsgHandler clientMsgHandler
std::shared_ptr< LedgerReplayTask > findTask(UInt256 const &hash, int totalReplay)
bool waitAndCheckStatus(UInt256 const &hash, int totalReplay, TaskStatus taskExpect, TaskStatus skiplistExpect, std::vector< TaskStatus > const &deltaExpects)
bool waitForLedgers(UInt256 const &finishLedgerHash, int totalReplay)
void addLedger(std::shared_ptr< Ledger const > const &l)
bool countsAsExpected(std::size_t tasks, std::size_t skipLists, std::size_t deltas)
bool checkStatus(UInt256 const &hash, int totalReplay, TaskStatus taskExpect, TaskStatus skiplistExpect, std::vector< TaskStatus > const &deltaExpects)
std::shared_ptr< SkipListAcquire > findSkipListAcquire(UInt256 const &hash)
LedgerReplayMsgHandler serverMsgHandler
bool asExpected(std::shared_ptr< LedgerReplayTask > const &task, TaskStatus taskExpect, TaskStatus skiplistExpect, std::vector< TaskStatus > const &deltaExpects)
std::shared_ptr< LedgerDeltaAcquire > findLedgerDeltaAcquire(UInt256 const &hash)
Simulate a network InboundLedgers.
void clearFailures() override
bool gotLedgerData(LedgerHash const &ledgerHash, std::shared_ptr< Peer >, std::shared_ptr< protocol::TMLedgerData >) override
MagicInboundLedgers(LedgerMaster &ledgerSource, LedgerMaster &ledgerSink, InboundLedgersBehavior bhvr)
InboundLedgersBehavior bhvr
LedgerMaster & ledgerSink
bool isFailure(UInt256 const &h) override
void onLedgerFetched() override
Called when a complete ledger is obtained.
void gotFetchPack() override
std::shared_ptr< InboundLedger > find(LedgerHash const &hash) override
~MagicInboundLedgers() override=default
void logFailure(UInt256 const &h, std::uint32_t seq) override
size_t cacheSize() override
LedgerMaster & ledgerSource
void acquireAsync(UInt256 const &hash, std::uint32_t seq, InboundLedger::Reason reason) override
std::size_t fetchRate() override
Returns the rate of historical ledger fetches per minute.
json::Value getInfo() override
std::shared_ptr< Ledger const > acquire(UInt256 const &hash, std::uint32_t seq, InboundLedger::Reason) override
void gotStaleData(std::shared_ptr< protocol::TMLedgerData > packet) override
LedgerReplayMsgHandler & local_
LedgerReplayMsgHandler & remote_
TestPeerSetBuilder(LedgerReplayMsgHandler &me, LedgerReplayMsgHandler &other, PeerSetBehavior bhvr, PeerFeature peerFeature)
std::unique_ptr< PeerSet > build() override
PeerSetBehavior behavior_
bool supportsFeature(ProtocolFeature f) const override
bool ledgerReplayEnabled_
TestPeer(bool enableLedgerReplay)
bool hasLedger(UInt256 const &, std::uint32_t) const override
A transaction testing environment.
bool close(NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)
Close and advance the ledger.
void fund(bool setDefaultRipple, STAmount const &amount, Account const &account)
std::uint32_t seq(Account const &account) const
Returns the next sequence number on account.
beast::Journal const journal
Set the regular signature on a JTx.
Set the expected result code for a JTx The test will fail if the code doesn't match.
Adds an inner Batch transaction to a JTx and autofills it.
T emplace_back(T... args)
boost::asio::ip::address Address
Severity
Severity level / threshold of a Journal message.
Keylet const & skip() noexcept
The index of the "short" skip list.
json::Value outer(jtx::Account const &account, uint32_t seq, STAmount const &fee, std::uint32_t flags)
Build an outer Batch transaction JSON object.
XRPAmount calcBatchFee(jtx::Env const &env, uint32_t const &numSigners, uint32_t const &txns=0)
Calculate the expected outer Batch transaction fee.
json::Value pay(AccountID const &account, AccountID const &to, AnyAmount amount)
Create a payment.
XrpT const XRP
Converts to XRP Issue or STAmount.
FeatureBitset testableAmendments()
std::unique_ptr< Config > envconfig()
creates and initializes a default configuration for jtx::Env
static AutofillT const kAutofill
PrettyAmount drops(Integer i)
Returns an XRP PrettyAmount, which is trivially convertible to STAmount.
BEAST_DEFINE_TESTSUITE(AMMClawback, app, xrpl)
void logAll(LedgerServer &server, LedgerReplayClient &client, beast::Severity level=Severity::Trace)
BEAST_DEFINE_TESTSUITE_MANUAL(AMMCalc, app, xrpl)
static UInt256 ledgerHash(LedgerHeader const &info)
BEAST_DEFINE_TESTSUITE_PRIO(AccountDelete, app, xrpl, 2)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
HttpResponseType makeResponse(bool crawlPublic, HttpRequestType const &req, beast::ip::Address publicIp, beast::ip::Address remoteIp, UInt256 const &sharedValue, std::optional< std::uint32_t > networkID, ProtocolVersion protocol, Application &app)
Make http response.
auto makeRequest(bool crawlPublic, bool comprEnabled, bool ledgerReplayEnabled, bool txReduceRelayEnabled, bool vpReduceRelayEnabled) -> RequestType
Make outbound http request.
static constexpr char kFeatureLedgerReplay[]
boost::intrusive_ptr< SHAMapItem > makeShamapitem(UInt256 const &tag, Slice data)
boost::beast::http::request< boost::beast::http::dynamic_body > HttpRequestType
std::shared_ptr< Ledger > buildLedger(std::shared_ptr< Ledger const > const &parent, NetClock::time_point closeTime, bool const closeTimeCorrect, NetClock::duration closeResolution, Application &app, CanonicalTXSet &txns, std::set< TxID > &failedTxs, beast::Journal j)
Build a new ledger by applying consensus transactions.
bool peerFeatureEnabled(Headers const &request, std::string const &feature, std::string value, bool config)
Check if a feature should be enabled for a peer.
@ Malformed
Protocol-level violation; no honest peer would produce this.
@ BadData
Peer reported has_error() (legitimate "cannot fulfill" signal).
void run() override
Runs the suite.
void testReplayBatchLedger()
void run() override
Runs the suite.
void testSkipListTimeout()
void testLedgerDeltaTimeout()
void run() override
Runs the suite.
Test cases: LedgerReplayer_test: – process TMProofPathRequest and TMProofPathResponse – process TMRep...
void run() override
Runs the suite.
void testAllLocal(int totalReplay)
void testSkipListBadReply()
void testPeerSetBehavior(PeerSetBehavior peerSetBehavior, int totalReplay=4)
void testAllInboundLedgers(int totalReplay)
void testTruncatedHeader()
void testLedgerReplayOverlap()
void testLedgerDeltaBadReply()
Utility class for (1) creating ledgers with txns and (2) providing the ledgers via the ledgerMaster.
LedgerMaster & ledgerMaster
std::vector< jtx::Account > accounts
LedgerServer(beast::unit_test::Suite &suite, Parameter const &p)
void createLedgerHistory()
create ledger history
void sendPayments(int newTxes)
LedgerReplayMsgHandler msgHandler
void createAccounts(int newAccounts)
NetworkOfTwo(beast::unit_test::Suite &suite, LedgerServer::Parameter const ¶m, PeerSetBehavior behavior=PeerSetBehavior::Good, InboundLedgersBehavior inboundBhvr=InboundLedgersBehavior::Good, PeerFeature peerFeature=PeerFeature::LedgerReplayEnabled)
LedgerReplayClient client
LedgerReplayMsgHandler & local
std::shared_ptr< TestPeer > dummyPeer
TestPeerSet(LedgerReplayMsgHandler &me, LedgerReplayMsgHandler &other, PeerSetBehavior bhvr, bool enableLedgerReplay)
void sendRequest(::google::protobuf::Message const &msg, protocol::MessageType type, std::shared_ptr< Peer > const &peer) override
std::set< Peer::ID > const & getPeerIds() const override
get the set of ids of previously added peers
LedgerReplayMsgHandler & remote
std::atomic< int > sendCount
void addPeers(std::size_t limit, std::function< bool(std::shared_ptr< Peer > const &)> hasItem, std::function< void(std::shared_ptr< Peer > const &)> onPeerAdded) override
Set the sequence number on a JTx.