1#include <test/jtx/Account.h>
2#include <test/jtx/Env.h>
3#include <test/jtx/amount.h>
4#include <test/jtx/envconfig.h>
5#include <test/jtx/fee.h>
6#include <test/jtx/pay.h>
7#include <test/jtx/seq.h>
8#include <test/jtx/sig.h>
9#include <test/jtx/tags.h>
11#include <xrpld/app/ledger/BuildLedger.h>
12#include <xrpld/app/ledger/InboundLedger.h>
13#include <xrpld/app/ledger/LedgerMaster.h>
14#include <xrpld/app/ledger/LedgerReplay.h>
15#include <xrpld/app/ledger/LedgerReplayTask.h>
16#include <xrpld/app/ledger/LedgerReplayer.h>
17#include <xrpld/app/ledger/detail/LedgerDeltaAcquire.h>
18#include <xrpld/app/ledger/detail/LedgerReplayMsgHandler.h>
19#include <xrpld/app/ledger/detail/SkipListAcquire.h>
20#include <xrpld/core/Config.h>
21#include <xrpld/overlay/Message.h>
22#include <xrpld/overlay/Peer.h>
23#include <xrpld/overlay/PeerSet.h>
24#include <xrpld/overlay/detail/Handshake.h>
26#include <xrpl/basics/Slice.h>
27#include <xrpl/basics/base_uint.h>
28#include <xrpl/beast/net/IPAddress.h>
29#include <xrpl/beast/net/IPEndpoint.h>
30#include <xrpl/beast/unit_test/suite.h>
31#include <xrpl/beast/utility/Journal.h>
32#include <xrpl/json/json_value.h>
33#include <xrpl/ledger/ApplyView.h>
34#include <xrpl/protocol/Indexes.h>
35#include <xrpl/protocol/KeyType.h>
36#include <xrpl/protocol/PublicKey.h>
37#include <xrpl/protocol/RippleLedgerHash.h>
38#include <xrpl/protocol/SecretKey.h>
39#include <xrpl/resource/Charge.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>
78 auto const alice =
Account(
"alice");
79 auto const bob =
Account(
"bob");
82 env.
fund(
XRP(100000), alice, bob);
87 auto const lastClosedParent = ledgerMaster.
getLedgerByHash(lastClosed->header().parentHash);
92 BEAST_EXPECT(replayed->header().hash == lastClosed->header().hash);
377 bool enableLedgerReplay)
397 ::google::protobuf::Message
const& msg,
398 protocol::MessageType type,
411 if (((rand() % 100) + 1) <= dropRate)
416 case protocol::mtPROOF_PATH_REQ: {
420 dynamic_cast<protocol::TMProofPathRequest const&
>(msg));
422 remote.processProofPathRequest(request));
423 local.processProofPathResponse(reply);
425 local.processProofPathResponse(reply);
428 case protocol::mtREPLAY_DELTA_REQ: {
432 dynamic_cast<protocol::TMReplayDeltaRequest const&
>(msg));
434 remote.processReplayDeltaRequest(request));
435 local.processReplayDeltaResponse(reply);
437 local.processReplayDeltaResponse(reply);
511 assert(
param.initLedgers > 0);
523 auto fundedAccounts =
accounts.size();
524 for (
int i = 0; i < newAccounts; ++i)
538 int fundedAccounts =
accounts.size();
539 assert(fundedAccounts >= newTxes);
546 auto updateIdx = [&]() {
547 assert(fundedAccounts > senders.
size());
548 fromIdx = (fromIdx + r) % fundedAccounts;
550 fromIdx = (fromIdx + 1) % fundedAccounts;
552 toIdx = (toIdx + (r * 2)) % fundedAccounts;
553 if (toIdx == fromIdx)
554 toIdx = (toIdx + 1) % fundedAccounts;
557 for (
int i = 0; i < newTxes; ++i)
577 for (
int i = 0; i <
param.initLedgers - 1; ++i)
640 uint256 hash = finishLedgerHash;
642 for (; i < totalReplay; ++i)
647 hash = l->header().parentHash;
655 int const totalRound = 100;
656 for (
int i = 0; i < totalRound; ++i)
660 if (i < totalRound - 1)
669 int const totalRound = 100;
670 for (
int i = 0; i < totalRound; ++i)
675 for (
auto const& t :
replayer.tasks_)
686 if (i < totalRound - 1)
704 return t->parameter_.finishHash == hash && t->parameter_.totalLedgers == totalReplay;
729 return replayer.tasks_.size() == tasks &&
replayer.skipLists_.size() == skipLists &&
737 auto i =
replayer.skipLists_.find(hash);
740 return i->second.lock();
747 auto i =
replayer.deltas_.find(hash);
750 return i->second.lock();
753 template <
typename T>
773 if (
taskStatus(task->skipListAcquirer_) == skiplistExpect)
775 if (task->deltas_.size() == deltaExpects.
size())
777 for (
int i = 0; i < deltaExpects.
size(); ++i)
779 if (
taskStatus(task->deltas_[i]) != deltaExpects[i])
797 auto t =
findTask(hash, totalReplay);
803 return asExpected(t, taskExpect, skiplistExpect, deltaExpects);
814 auto t =
findTask(hash, totalReplay);
820 return asExpected(t, taskExpect, skiplistExpect, deltaExpects);
834 return checkStatus(hash, totalReplay, taskExpect, skiplistExpect, deltaExpects);
911 request->set_ledgerhash(l->header().hash.data(), l->header().hash.size());
912 request->set_type(protocol::TMLedgerMapType::lmACCOUNT_STATE);
914 server.msgHandler.processProofPathRequest(request));
915 BEAST_EXPECT(reply->has_error());
916 BEAST_EXPECT(!server.msgHandler.processProofPathResponse(reply));
921 request->set_type(protocol::TMLedgerMapType::lmACCOUNT_STATE);
924 request->set_ledgerhash(hash.
data(), hash.
size());
926 server.msgHandler.processProofPathRequest(request));
927 BEAST_EXPECT(reply->has_error());
933 request->set_ledgerhash(l->header().hash.data(), l->header().hash.size());
934 request->set_type(protocol::TMLedgerMapType::lmACCOUNT_STATE);
938 server.msgHandler.processProofPathRequest(request));
939 BEAST_EXPECT(!reply->has_error());
940 BEAST_EXPECT(server.msgHandler.processProofPathResponse(reply));
947 reply->set_ledgerheader(r);
948 BEAST_EXPECT(!server.msgHandler.processProofPathResponse(reply));
950 reply->set_ledgerheader(r);
951 BEAST_EXPECT(server.msgHandler.processProofPathResponse(reply));
953 reply->mutable_path()->RemoveLast();
954 BEAST_EXPECT(!server.msgHandler.processProofPathResponse(reply));
970 server.msgHandler.processReplayDeltaRequest(request));
971 BEAST_EXPECT(reply->has_error());
972 BEAST_EXPECT(!server.msgHandler.processReplayDeltaResponse(reply));
975 request->set_ledgerhash(hash.
data(), hash.
size());
977 server.msgHandler.processReplayDeltaRequest(request));
978 BEAST_EXPECT(reply->has_error());
979 BEAST_EXPECT(!server.msgHandler.processReplayDeltaResponse(reply));
985 request->set_ledgerhash(l->header().hash.data(), l->header().hash.size());
987 server.msgHandler.processReplayDeltaRequest(request));
988 BEAST_EXPECT(!reply->has_error());
989 BEAST_EXPECT(server.msgHandler.processReplayDeltaResponse(reply));
996 reply->set_ledgerheader(r);
997 BEAST_EXPECT(!server.msgHandler.processReplayDeltaResponse(reply));
999 reply->set_ledgerheader(r);
1000 BEAST_EXPECT(server.msgHandler.processReplayDeltaResponse(reply));
1002 reply->mutable_transaction()->RemoveLast();
1003 BEAST_EXPECT(!server.msgHandler.processReplayDeltaResponse(reply));
1016 for (
int i = 0; i < count; ++i)
1022 BEAST_EXPECT(!tp10.
update(
uint256(777), 5, makeSkipList(10)));
1023 BEAST_EXPECT(!tp10.
update(
uint256(10), 5, makeSkipList(8)));
1024 BEAST_EXPECT(tp10.
update(
uint256(10), 10, makeSkipList(10)));
1052 BEAST_EXPECT(tp20.
update(
uint256(20), 20, makeSkipList(20)));
1093 auto handshake = [&](
bool client,
bool server,
bool expecting) ->
bool {
1096 httpRequest.version(request.version());
1097 httpRequest.base() = request.base();
1099 if (serverResult != expecting)
1103 jtx::Env serverEnv(*
this);
1104 serverEnv.app().config().ledgerReplay = server;
1106 true, httpRequest, addr, addr,
uint256{1}, 1, {1, 0}, serverEnv.app());
1108 return clientResult == expecting;
1111 BEAST_EXPECT(handshake(
false,
false,
false));
1112 BEAST_EXPECT(handshake(
false,
true,
false));
1113 BEAST_EXPECT(handshake(
true,
false,
false));
1114 BEAST_EXPECT(handshake(
true,
true,
true));
1120 testcase(
"local node has all the ledgers");
1125 NetworkOfTwo net(*
this, {.initLedgers = totalReplay + 1}, psBhvr, ilBhvr, peerFeature);
1128 uint256 const finalHash = l->header().hash;
1129 for (
int i = 0; i < totalReplay; ++i)
1134 net.client.ledgerMaster.storeLedger(l);
1135 l = net.server.ledgerMaster.getLedgerByHash(l->header().parentHash);
1146 BEAST_EXPECT(net.client.waitAndCheckStatus(
1150 net.client.replayer.sweep();
1151 BEAST_EXPECT(net.client.countsAsExpected(0, 0, 0));
1157 testcase(
"all the ledgers from InboundLedgers");
1160 {.initLedgers = totalReplay + 1},
1166 uint256 const finalHash = l->header().hash;
1170 BEAST_EXPECT(net.client.waitAndCheckStatus(
1181 auto waitForSweep = [&net]() {
1182 for (
auto numAttempts = 0; numAttempts < 20; ++numAttempts)
1184 net.client.replayer.sweep();
1185 if (net.client.countsAsExpected(0, 0, 0))
1193 BEAST_EXPECT(waitForSweep());
1199 switch (peerSetBehavior)
1205 testcase(
"network drops 50% messages");
1208 testcase(
"network repeats all messages");
1216 {.initLedgers = totalReplay + 1},
1222 auto l = net.server.ledgerMaster.getClosedLedger();
1223 uint256 const finalHash = l->header().hash;
1224 for (
int i = 0; i < totalReplay - 1; ++i)
1226 l = net.server.ledgerMaster.getLedgerByHash(l->header().parentHash);
1228 net.client.ledgerMaster.storeLedger(l);
1233 BEAST_EXPECT(net.client.waitAndCheckStatus(
1235 BEAST_EXPECT(net.client.waitForLedgers(finalHash, totalReplay));
1238 net.client.replayer.sweep();
1239 BEAST_EXPECT(net.client.countsAsExpected(0, 0, 0));
1246 int const totalReplay = 3;
1249 {.initLedgers = totalReplay + 1},
1255 uint256 const finalHash = l->header().hash;
1259 BEAST_EXPECT(net.client.checkStatus(
1262 BEAST_EXPECT(net.client.countsAsExpected(1, 1, 0));
1263 net.client.replayer.stop();
1264 BEAST_EXPECT(net.client.countsAsExpected(0, 0, 0));
1270 testcase(
"SkipListAcquire bad reply");
1271 int const totalReplay = 3;
1274 {.initLedgers = totalReplay + 1 + 1},
1280 uint256 const finalHash = l->header().hash;
1283 auto skipList = net.client.findSkipListAcquire(finalHash);
1285 std::uint8_t payload[55] = {0x6A, 0x09, 0xE6, 0x67, 0xF3, 0xBC, 0xC9, 0x08, 0xB2};
1287 skipList->processData(l->seq(), item);
1290 BEAST_EXPECT(net.client.waitAndCheckStatus(
1295 BEAST_EXPECT(net.client.waitAndCheckStatus(
1297 BEAST_EXPECT(net.client.countsAsExpected(2, 1, 0));
1303 testcase(
"LedgerDeltaAcquire bad reply");
1304 int const totalReplay = 3;
1307 {.initLedgers = totalReplay + 1},
1313 uint256 const finalHash = l->header().hash;
1314 net.client.ledgerMaster.storeLedger(l);
1317 auto delta = net.client.findLedgerDeltaAcquire(l->header().parentHash);
1323 net.client.taskStatus(net.client.findTask(finalHash, totalReplay)) ==
1329 net.client.taskStatus(net.client.findTask(finalHash, totalReplay + 1)) ==
1337 int const totalReplay = 5;
1340 {.initLedgers = (totalReplay * 3) + 1},
1345 uint256 const finalHash = l->header().hash;
1348 BEAST_EXPECT(net.client.waitAndCheckStatus(
1350 BEAST_EXPECT(net.client.waitForLedgers(finalHash, totalReplay));
1354 BEAST_EXPECT(net.client.countsAsExpected(1, 1, totalReplay - 1));
1357 BEAST_EXPECT(net.client.countsAsExpected(2, 1, totalReplay - 1));
1360 for (
int i = 0; i < totalReplay + 2; ++i)
1362 l = net.server.ledgerMaster.getLedgerByHash(l->header().parentHash);
1364 auto finalHashEarly = l->header().hash;
1366 BEAST_EXPECT(net.client.waitAndCheckStatus(
1372 BEAST_EXPECT(net.client.waitForLedgers(finalHashEarly, totalReplay));
1373 BEAST_EXPECT(net.client.countsAsExpected(3, 2, 2 * (totalReplay - 1)));
1376 l = net.server.ledgerMaster.getLedgerByHash(l->header().parentHash);
1377 auto finalHashMoreEarly = l->header().parentHash;
1379 BEAST_EXPECT(net.client.waitAndCheckStatus(
1385 BEAST_EXPECT(net.client.waitForLedgers(finalHashMoreEarly, totalReplay));
1386 BEAST_EXPECT(net.client.countsAsExpected(4, 3, (2 * (totalReplay - 1)) + 2));
1391 BEAST_EXPECT(net.client.waitAndCheckStatus(
1397 BEAST_EXPECT(net.client.waitForLedgers(finalHash, totalReplay * 3));
1398 BEAST_EXPECT(net.client.countsAsExpected(5, 3, (totalReplay * 3) - 1));
1401 net.client.replayer.sweep();
1402 BEAST_EXPECT(net.client.countsAsExpected(0, 0, 0));
1433 testcase(
"SkipListAcquire timeout");
1434 int const totalReplay = 3;
1437 {.initLedgers = totalReplay + 1},
1443 uint256 const finalHash = l->header().hash;
1447 BEAST_EXPECT(net.client.waitAndCheckStatus(
1451 BEAST_EXPECT(net.client.countsAsExpected(1, 1, 0));
1452 net.client.replayer.sweep();
1453 BEAST_EXPECT(net.client.countsAsExpected(0, 0, 0));
1459 testcase(
"LedgerDeltaAcquire timeout");
1460 int const totalReplay = 3;
1463 {.initLedgers = totalReplay + 1},
1469 uint256 const finalHash = l->header().hash;
1470 net.client.ledgerMaster.storeLedger(l);
1475 BEAST_EXPECT(net.client.waitAndCheckStatus(
1479 BEAST_EXPECT(net.client.countsAsExpected(1, 1, totalReplay - 1));
1480 net.client.replayer.sweep();
1481 BEAST_EXPECT(net.client.countsAsExpected(0, 0, 0));
1498 int const totalReplay = 250;
1499 int const rounds = 4;
1502 {.initLedgers = (totalReplay * rounds) + 1},
1508 auto l = net.server.ledgerMaster.getClosedLedger();
1509 for (
int i = 0; i < rounds; ++i)
1511 finishHashes.push_back(l->header().hash);
1512 for (
int j = 0; j < totalReplay; ++j)
1514 l = net.server.ledgerMaster.getLedgerByHash(l->header().parentHash);
1517 BEAST_EXPECT(finishHashes.size() == rounds);
1519 for (
int i = 0; i < rounds; ++i)
1521 net.client.replayer.replay(
1526 for (
int i = 0; i < rounds; ++i)
1528 BEAST_EXPECT(net.client.waitAndCheckStatus(
1536 BEAST_EXPECT(net.client.waitForLedgers(finishHashes[0], totalReplay * rounds));
1537 BEAST_EXPECT(net.client.countsAsExpected(rounds, rounds, rounds * (totalReplay - 1)));
1540 net.client.replayer.sweep();
1541 BEAST_EXPECT(net.client.countsAsExpected(0, 0, 0));
A version-independent IP address and port combination.
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.
std::shared_ptr< Ledger const > getClosedLedger()
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.
Represents a peer connection in the overlay.
std::uint32_t id_t
Uniquely identifies a peer.
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()
bool asExpected(uint256 const &hash, int totalReplay, TaskStatus taskExpect, TaskStatus skiplistExpect, std::vector< TaskStatus > const &deltaExpects)
LedgerMaster & ledgerMaster
MagicInboundLedgers inboundLedgers
std::size_t countSkipLists()
LedgerReplayMsgHandler clientMsgHandler
bool haveLedgers(uint256 const &finishLedgerHash, int totalReplay)
void addLedger(std::shared_ptr< Ledger const > const &l)
std::shared_ptr< SkipListAcquire > findSkipListAcquire(uint256 const &hash)
bool countsAsExpected(std::size_t tasks, std::size_t skipLists, std::size_t deltas)
bool waitForLedgers(uint256 const &finishLedgerHash, int totalReplay)
LedgerReplayMsgHandler serverMsgHandler
bool waitAndCheckStatus(uint256 const &hash, int totalReplay, TaskStatus taskExpect, TaskStatus skiplistExpect, std::vector< TaskStatus > const &deltaExpects)
bool asExpected(std::shared_ptr< LedgerReplayTask > const &task, TaskStatus taskExpect, TaskStatus skiplistExpect, std::vector< TaskStatus > const &deltaExpects)
std::shared_ptr< LedgerReplayTask > findTask(uint256 const &hash, int totalReplay)
bool checkStatus(uint256 const &hash, int totalReplay, TaskStatus taskExpect, TaskStatus skiplistExpect, std::vector< TaskStatus > const &deltaExpects)
std::shared_ptr< LedgerDeltaAcquire > findLedgerDeltaAcquire(uint256 const &hash)
Simulate a network InboundLedgers.
std::shared_ptr< Ledger const > acquire(uint256 const &hash, std::uint32_t seq, InboundLedger::Reason) override
void clearFailures() override
void acquireAsync(uint256 const &hash, std::uint32_t seq, InboundLedger::Reason reason) 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
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
size_t cacheSize() override
LedgerMaster & ledgerSource
std::size_t fetchRate() override
Returns the rate of historical ledger fetches per minute.
void logFailure(uint256 const &h, std::uint32_t seq) override
json::Value getInfo() override
bool isFailure(uint256 const &h) 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_
void cycleStatus() override
uint256 const & getClosedLedgerHash() const override
std::optional< std::size_t > publisherListSequence(PublicKey const &) const override
bool supportsFeature(ProtocolFeature f) const override
PublicKey const & getNodePublic() const override
beast::IP::Endpoint getRemoteAddress() const override
std::string const & fingerprint() const override
void ledgerRange(std::uint32_t &minSeq, std::uint32_t &maxSeq) const override
bool compressionEnabled() const override
void charge(Resource::Charge const &fee, std::string const &context={}) override
Adjust this peer's load balance based on the type of load imposed.
json::Value json() override
bool ledgerReplayEnabled_
bool hasLedger(uint256 const &hash, std::uint32_t seq) const override
bool txReduceRelayEnabled() const override
TestPeer(bool enableLedgerReplay)
bool hasTxSet(uint256 const &hash) const override
int getScore(bool) const override
bool isHighLatency() const override
bool cluster() const override
Returns true if this connection is a member of the cluster.
void addTxQueue(uint256 const &) override
Aggregate transaction's hash.
void removeTxQueue(uint256 const &) override
Remove hash from the transactions' hashes queue.
void send(std::shared_ptr< Message > const &m) override
void sendTxQueue() override
Send aggregated transactions' hashes.
bool hasRange(std::uint32_t uMin, std::uint32_t uMax) override
void setPublisherListSequence(PublicKey const &, std::size_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)
beast::Journal const journal
Set the regular signature on a JTx.
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 pay(AccountID const &account, AccountID const &to, AnyAmount amount)
Create a payment.
XrpT const XRP
Converts to XRP Issue or STAmount.
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)
static uint256 ledgerHash(LedgerHeader const &info)
BEAST_DEFINE_TESTSUITE_MANUAL(AMMCalc, app, xrpl)
BEAST_DEFINE_TESTSUITE_PRIO(AccountDelete, app, xrpl, 2)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
PublicKey derivePublicKey(KeyType type, SecretKey const &sk)
Derive the public key from a secret key.
static constexpr char kFeatureLedgerReplay[]
auto makeRequest(bool crawlPublic, bool comprEnabled, bool ledgerReplayEnabled, bool txReduceRelayEnabled, bool vpReduceRelayEnabled) -> request_type
Make outbound http request.
boost::intrusive_ptr< SHAMapItem > makeShamapitem(uint256 const &tag, Slice data)
http_response_type makeResponse(bool crawlPublic, http_request_type 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.
SecretKey randomSecretKey()
Create a secret key using secure random numbers.
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.
boost::beast::http::request< boost::beast::http::dynamic_body > http_request_type
void run() override
Runs the suite.
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 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
std::set< Peer::id_t > const & getPeerIds() const override
get the set of ids of previously added peers
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
LedgerReplayMsgHandler & remote
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
Try add more peers.
Set the sequence number on a JTx.