rippled
Loading...
Searching...
No Matches
LedgerReplay_test.cpp
1#include <test/jtx.h>
2#include <test/jtx/envconfig.h>
3
4#include <xrpld/app/ledger/BuildLedger.h>
5#include <xrpld/app/ledger/LedgerMaster.h>
6#include <xrpld/app/ledger/LedgerReplay.h>
7#include <xrpld/app/ledger/LedgerReplayTask.h>
8#include <xrpld/app/ledger/LedgerReplayer.h>
9#include <xrpld/app/ledger/detail/LedgerDeltaAcquire.h>
10#include <xrpld/app/ledger/detail/LedgerReplayMsgHandler.h>
11#include <xrpld/app/ledger/detail/SkipListAcquire.h>
12#include <xrpld/overlay/PeerSet.h>
13#include <xrpld/overlay/detail/PeerImp.h>
14
15#include <xrpl/basics/Slice.h>
16
17#include <chrono>
18#include <thread>
19
20namespace ripple {
21namespace test {
22
24{
25 void
26 run() override
27 {
28 testcase("Replay ledger");
29
30 using namespace jtx;
31
32 // Build a ledger normally
33 auto const alice = Account("alice");
34 auto const bob = Account("bob");
35
36 Env env(*this);
37 env.fund(XRP(100000), alice, bob);
38 env.close();
39
41 auto const lastClosed = ledgerMaster.getClosedLedger();
42 auto const lastClosedParent =
43 ledgerMaster.getLedgerByHash(lastClosed->info().parentHash);
44
45 auto const replayed = buildLedger(
46 LedgerReplay(lastClosedParent, lastClosed),
47 tapNONE,
48 env.app(),
49 env.journal);
50
51 BEAST_EXPECT(replayed->info().hash == lastClosed->info().hash);
52 }
53};
54
56 Good,
57 DropAll,
58};
59
66{
67public:
75 virtual ~MagicInboundLedgers() = default;
76
79 override
80 {
82 return {};
83 if (auto l = ledgerSource.getLedgerByHash(hash); l)
84 {
86 return l;
87 }
88
89 return {};
90 }
91
92 virtual void
94 uint256 const& hash,
96 InboundLedger::Reason reason) override
97 {
98 }
99
101 find(LedgerHash const& hash) override
102 {
103 return {};
104 }
105
106 virtual bool
108 LedgerHash const& ledgerHash,
111 {
112 return false;
113 }
114
115 virtual void
119
120 virtual void
122 {
123 }
124
125 virtual bool
126 isFailure(uint256 const& h) override
127 {
128 return false;
129 }
130
131 virtual void
132 clearFailures() override
133 {
134 }
135
136 virtual Json::Value
137 getInfo() override
138 {
139 return {};
140 }
141
142 virtual std::size_t
143 fetchRate() override
144 {
145 return 0;
146 }
147
148 virtual void
150 {
151 }
152
153 virtual void
154 gotFetchPack() override
155 {
156 }
157 virtual void
158 sweep() override
159 {
160 }
161
162 virtual void
163 stop() override
164 {
165 }
166
167 virtual size_t
168 cacheSize() override
169 {
170 return 0;
171 }
172
176};
177
178enum class PeerFeature {
180 None,
181};
182
188class TestPeer : public Peer
189{
190public:
191 TestPeer(bool enableLedgerReplay)
192 : ledgerReplayEnabled_(enableLedgerReplay)
194 {
195 }
196
197 void
199 {
200 }
202 getRemoteAddress() const override
203 {
204 return {};
205 }
206 void
207 charge(Resource::Charge const& fee, std::string const& context = {})
208 override
209 {
210 }
211 id_t
212 id() const override
213 {
214 return 1234;
215 }
216 bool
217 cluster() const override
218 {
219 return false;
220 }
221 bool
222 isHighLatency() const override
223 {
224 return false;
225 }
226 int
227 getScore(bool) const override
228 {
229 return 0;
230 }
231 PublicKey const&
232 getNodePublic() const override
233 {
234 return nodePublicKey_;
235 }
237 json() override
238 {
239 return {};
240 }
241 bool
243 {
245 return true;
246 return false;
247 }
249 publisherListSequence(PublicKey const&) const override
250 {
251 return {};
252 }
253 void
255 {
256 }
257 uint256 const&
258 getClosedLedgerHash() const override
259 {
260 static uint256 hash{};
261 return hash;
262 }
263 bool
264 hasLedger(uint256 const& hash, std::uint32_t seq) const override
265 {
266 return true;
267 }
268 void
269 ledgerRange(std::uint32_t& minSeq, std::uint32_t& maxSeq) const override
270 {
271 }
272 bool
273 hasTxSet(uint256 const& hash) const override
274 {
275 return false;
276 }
277 void
278 cycleStatus() override
279 {
280 }
281 bool
283 {
284 return false;
285 }
286 bool
287 compressionEnabled() const override
288 {
289 return false;
290 }
291 void
292 sendTxQueue() override
293 {
294 }
295 void
296 addTxQueue(uint256 const&) override
297 {
298 }
299 void
300 removeTxQueue(uint256 const&) override
301 {
302 }
303 bool
304 txReduceRelayEnabled() const override
305 {
306 return false;
307 }
308
309 std::string const&
310 fingerprint() const override
311 {
312 return fingerprint_;
313 }
314
318};
319
320enum class PeerSetBehavior {
321 Good,
322 Drop50,
323 DropAll,
326 Repeat,
327};
328
335struct TestPeerSet : public PeerSet
336{
340 PeerSetBehavior bhvr,
341 bool enableLedgerReplay)
342 : local(me)
343 , remote(other)
344 , dummyPeer(std::make_shared<TestPeer>(enableLedgerReplay))
345 , behavior(bhvr)
346 {
347 }
348
349 void
351 std::size_t limit,
352 std::function<bool(std::shared_ptr<Peer> const&)> hasItem,
353 std::function<void(std::shared_ptr<Peer> const&)> onPeerAdded) override
354 {
355 hasItem(dummyPeer);
356 onPeerAdded(dummyPeer);
357 }
358
359 void
361 ::google::protobuf::Message const& msg,
362 protocol::MessageType type,
363 std::shared_ptr<Peer> const& peer) override
364 {
365 int dropRate = 0;
367 dropRate = 50;
369 dropRate = 100;
370
371 if ((rand() % 100 + 1) <= dropRate)
372 return;
373
374 switch (type)
375 {
376 case protocol::mtPROOF_PATH_REQ: {
378 return;
380 dynamic_cast<protocol::TMProofPathRequest const&>(msg));
386 break;
387 }
388 case protocol::mtREPLAY_DELTA_REQ: {
390 return;
392 dynamic_cast<protocol::TMReplayDeltaRequest const&>(msg));
398 break;
399 }
400 default:
401 return;
402 }
403 }
404
406 getPeerIds() const override
407 {
408 static std::set<Peer::id_t> emptyPeers;
409 return emptyPeers;
410 }
411
416};
417
449
455{
457 {
459 int initAccounts = 10;
460 int initAmount = 1'000'000;
462 int txAmount = 10;
463 };
464
466 : env(suite)
467 , app(env.app())
468 , ledgerMaster(env.app().getLedgerMaster())
469 , msgHandler(env.app(), env.app().getLedgerReplayer())
470 , param(p)
471 {
472 assert(param.initLedgers > 0);
476 }
477
481 void
482 createAccounts(int newAccounts)
483 {
484 auto fundedAccounts = accounts.size();
485 for (int i = 0; i < newAccounts; ++i)
486 {
487 accounts.emplace_back(
488 "alice_" + std::to_string(fundedAccounts + i));
490 }
491 env.close();
492 }
493
497 void
498 sendPayments(int newTxes)
499 {
500 int fundedAccounts = accounts.size();
501 assert(fundedAccounts >= newTxes);
503
504 // somewhat random but reproducible
505 int r = ledgerMaster.getClosedLedger()->seq() * 7;
506 int fromIdx = 0;
507 int toIdx = 0;
508 auto updateIdx = [&]() {
509 assert(fundedAccounts > senders.size());
510 fromIdx = (fromIdx + r) % fundedAccounts;
511 while (senders.count(fromIdx) != 0)
512 fromIdx = (fromIdx + 1) % fundedAccounts;
513 senders.insert(fromIdx);
514 toIdx = (toIdx + r * 2) % fundedAccounts;
515 if (toIdx == fromIdx)
516 toIdx = (toIdx + 1) % fundedAccounts;
517 };
518
519 for (int i = 0; i < newTxes; ++i)
520 {
521 updateIdx();
522 env.apply(
523 pay(accounts[fromIdx],
524 accounts[toIdx],
525 jtx::drops(ledgerMaster.getClosedLedger()->fees().base) +
530 }
531 env.close();
532 }
533
537 void
539 {
540 for (int i = 0; i < param.initLedgers - 1; ++i)
541 {
543 }
544 }
545
552};
553
554enum class TaskStatus {
555 Failed,
556 Completed,
557 NotDone,
558 NotExist,
559};
560
569{
570public:
573 LedgerServer& server,
577 : env(suite, jtx::envconfig(), nullptr, beast::severities::kDisabled)
578 , app(env.app())
579 , ledgerMaster(env.app().getLedgerMaster())
581 server.app.getLedgerMaster(),
583 inboundBhvr)
584 , serverMsgHandler(server.app, server.app.getLedgerReplayer())
586 , replayer(
587 env.app(),
589 std::make_unique<TestPeerSetBuilder>(
592 behavior,
593 peerFeature))
594 {
595 }
596
597 void
602
603 bool
604 haveLedgers(uint256 const& finishLedgerHash, int totalReplay)
605 {
606 uint256 hash = finishLedgerHash;
607 int i = 0;
608 for (; i < totalReplay; ++i)
609 {
610 auto const l = ledgerMaster.getLedgerByHash(hash);
611 if (!l)
612 return false;
613 hash = l->info().parentHash;
614 }
615 return true;
616 }
617
618 bool
619 waitForLedgers(uint256 const& finishLedgerHash, int totalReplay)
620 {
621 int totalRound = 100;
622 for (int i = 0; i < totalRound; ++i)
623 {
624 if (haveLedgers(finishLedgerHash, totalReplay))
625 return true;
626 if (i < totalRound - 1)
628 }
629 return false;
630 }
631
632 bool
634 {
635 int totalRound = 100;
636 for (int i = 0; i < totalRound; ++i)
637 {
638 bool allDone = true;
639 {
641 for (auto const& t : replayer.tasks_)
642 {
643 if (!t->finished())
644 {
645 allDone = false;
646 break;
647 }
648 }
649 }
650 if (allDone)
651 return true;
652 if (i < totalRound - 1)
654 }
655 return false;
656 }
657
660 {
662 return replayer.tasks_;
663 }
664
666 findTask(uint256 const& hash, int totalReplay)
667 {
669 auto i = std::find_if(
670 replayer.tasks_.begin(), replayer.tasks_.end(), [&](auto const& t) {
671 return t->parameter_.finishHash_ == hash &&
672 t->parameter_.totalLedgers_ == totalReplay;
673 });
674 if (i == replayer.tasks_.end())
675 return {};
676 return *i;
677 }
678
681 {
683 return replayer.deltas_.size();
684 }
685
688 {
690 return replayer.skipLists_.size();
691 }
692
693 bool
695 std::size_t tasks,
696 std::size_t skipLists,
697 std::size_t deltas)
698 {
700 return replayer.tasks_.size() == tasks &&
701 replayer.skipLists_.size() == skipLists &&
702 replayer.deltas_.size() == deltas;
703 }
704
707 {
709 auto i = replayer.skipLists_.find(hash);
710 if (i == replayer.skipLists_.end())
711 return {};
712 return i->second.lock();
713 }
714
717 {
719 auto i = replayer.deltas_.find(hash);
720 if (i == replayer.deltas_.end())
721 return {};
722 return i->second.lock();
723 }
724
725 template <typename T>
728 {
729 if (t->failed_)
730 return TaskStatus::Failed;
731 if (t->complete_)
733 return TaskStatus::NotDone;
734 }
735
736 bool
739 TaskStatus taskExpect,
740 TaskStatus skiplistExpect,
741 std::vector<TaskStatus> const& deltaExpects)
742 {
743 if (taskStatus(task) == taskExpect)
744 {
745 if (taskStatus(task->skipListAcquirer_) == skiplistExpect)
746 {
747 if (task->deltas_.size() == deltaExpects.size())
748 {
749 for (int i = 0; i < deltaExpects.size(); ++i)
750 {
751 if (taskStatus(task->deltas_[i]) != deltaExpects[i])
752 return false;
753 }
754 return true;
755 }
756 }
757 }
758 return false;
759 }
760
761 bool
763 uint256 const& hash,
764 int totalReplay,
765 TaskStatus taskExpect,
766 TaskStatus skiplistExpect,
767 std::vector<TaskStatus> const& deltaExpects)
768 {
769 auto t = findTask(hash, totalReplay);
770 if (!t)
771 {
772 if (taskExpect == TaskStatus::NotExist)
773 return true;
774 return false;
775 }
776
777 return asExpected(t, taskExpect, skiplistExpect, deltaExpects);
778 }
779
780 bool
782 uint256 const& hash,
783 int totalReplay,
784 TaskStatus taskExpect,
785 TaskStatus skiplistExpect,
786 std::vector<TaskStatus> const& deltaExpects)
787 {
788 auto t = findTask(hash, totalReplay);
789 if (!t)
790 {
791 if (taskExpect == TaskStatus::NotExist)
792 return true;
793 return false;
794 }
795
796 return asExpected(t, taskExpect, skiplistExpect, deltaExpects);
797 }
798
799 bool
801 uint256 const& hash,
802 int totalReplay,
803 TaskStatus taskExpect,
804 TaskStatus skiplistExpect,
805 std::vector<TaskStatus> const& deltaExpects)
806 {
807 if (!waitForDone())
808 return false;
809
810 return checkStatus(
811 hash, totalReplay, taskExpect, skiplistExpect, deltaExpects);
812 }
813
821};
822
823using namespace beast::severities;
824void
826 LedgerServer& server,
827 LedgerReplayClient& client,
828 beast::severities::Severity level = Severity::kTrace)
829{
830 server.app.logs().threshold(level);
831 client.app.logs().threshold(level);
832}
833// logAll(net.server, net.client);
834
835/*
836 * Create a LedgerServer and a LedgerReplayClient
837 */
839{
842 LedgerServer::Parameter const& param,
846 : server(suite, param)
847 , client(suite, server, behavior, inboundBhvr, peerFeature)
848 {
849 // logAll(server, client);
850 }
853};
854
881{
882 void
884 {
885 testcase("ProofPath");
886 LedgerServer server(*this, {1});
887 auto const l = server.ledgerMaster.getClosedLedger();
888
889 {
890 // request, missing key
892 request->set_ledgerhash(
893 l->info().hash.data(), l->info().hash.size());
894 request->set_type(protocol::TMLedgerMapType::lmACCOUNT_STATE);
896 server.msgHandler.processProofPathRequest(request));
897 BEAST_EXPECT(reply->has_error());
898 BEAST_EXPECT(!server.msgHandler.processProofPathResponse(reply));
899 }
900 {
901 // request, wrong hash
903 request->set_type(protocol::TMLedgerMapType::lmACCOUNT_STATE);
904 request->set_key(
905 keylet::skip().key.data(), keylet::skip().key.size());
906 uint256 hash(1234567);
907 request->set_ledgerhash(hash.data(), hash.size());
909 server.msgHandler.processProofPathRequest(request));
910 BEAST_EXPECT(reply->has_error());
911 }
912
913 {
914 // good request
916 request->set_ledgerhash(
917 l->info().hash.data(), l->info().hash.size());
918 request->set_type(protocol::TMLedgerMapType::lmACCOUNT_STATE);
919 request->set_key(
920 keylet::skip().key.data(), keylet::skip().key.size());
921 // generate response
923 server.msgHandler.processProofPathRequest(request));
924 BEAST_EXPECT(!reply->has_error());
925 BEAST_EXPECT(server.msgHandler.processProofPathResponse(reply));
926
927 {
928 // bad reply
929 // bad header
930 std::string r(reply->ledgerheader());
931 r.back()--;
932 reply->set_ledgerheader(r);
933 BEAST_EXPECT(
934 !server.msgHandler.processProofPathResponse(reply));
935 r.back()++;
936 reply->set_ledgerheader(r);
937 BEAST_EXPECT(server.msgHandler.processProofPathResponse(reply));
938 // bad proof path
939 reply->mutable_path()->RemoveLast();
940 BEAST_EXPECT(
941 !server.msgHandler.processProofPathResponse(reply));
942 }
943 }
944 }
945
946 void
948 {
949 testcase("ReplayDelta");
950 LedgerServer server(*this, {1});
951 auto const l = server.ledgerMaster.getClosedLedger();
952
953 {
954 // request, missing hash
957 server.msgHandler.processReplayDeltaRequest(request));
958 BEAST_EXPECT(reply->has_error());
959 BEAST_EXPECT(!server.msgHandler.processReplayDeltaResponse(reply));
960 // request, wrong hash
961 uint256 hash(1234567);
962 request->set_ledgerhash(hash.data(), hash.size());
964 server.msgHandler.processReplayDeltaRequest(request));
965 BEAST_EXPECT(reply->has_error());
966 BEAST_EXPECT(!server.msgHandler.processReplayDeltaResponse(reply));
967 }
968
969 {
970 // good request
972 request->set_ledgerhash(
973 l->info().hash.data(), l->info().hash.size());
975 server.msgHandler.processReplayDeltaRequest(request));
976 BEAST_EXPECT(!reply->has_error());
977 BEAST_EXPECT(server.msgHandler.processReplayDeltaResponse(reply));
978
979 {
980 // bad reply
981 // bad header
982 std::string r(reply->ledgerheader());
983 r.back()--;
984 reply->set_ledgerheader(r);
985 BEAST_EXPECT(
986 !server.msgHandler.processReplayDeltaResponse(reply));
987 r.back()++;
988 reply->set_ledgerheader(r);
989 BEAST_EXPECT(
990 server.msgHandler.processReplayDeltaResponse(reply));
991 // bad txns
992 reply->mutable_transaction()->RemoveLast();
993 BEAST_EXPECT(
994 !server.msgHandler.processReplayDeltaResponse(reply));
995 }
996 }
997 }
998
999 void
1001 {
1002 testcase("TaskParameter");
1003
1004 auto makeSkipList = [](int count) -> std::vector<uint256> const {
1006 for (int i = 0; i < count; ++i)
1007 sList.emplace_back(i);
1008 return sList;
1009 };
1010
1013 BEAST_EXPECT(!tp10.update(uint256(777), 5, makeSkipList(10)));
1014 BEAST_EXPECT(!tp10.update(uint256(10), 5, makeSkipList(8)));
1015 BEAST_EXPECT(tp10.update(uint256(10), 10, makeSkipList(10)));
1016
1017 // can merge to self
1018 BEAST_EXPECT(tp10.canMergeInto(tp10));
1019
1020 // smaller task
1023
1024 BEAST_EXPECT(tp9.canMergeInto(tp10));
1025 BEAST_EXPECT(!tp10.canMergeInto(tp9));
1026
1027 tp9.totalLedgers_++;
1028 BEAST_EXPECT(!tp9.canMergeInto(tp10));
1029 tp9.totalLedgers_--;
1030 BEAST_EXPECT(tp9.canMergeInto(tp10));
1031
1033 BEAST_EXPECT(!tp9.canMergeInto(tp10));
1035 BEAST_EXPECT(tp9.canMergeInto(tp10));
1036
1037 tp9.finishHash_ = uint256(1234);
1038 BEAST_EXPECT(!tp9.canMergeInto(tp10));
1039 tp9.finishHash_ = uint256(9);
1040 BEAST_EXPECT(tp9.canMergeInto(tp10));
1041
1042 // larger task
1045 BEAST_EXPECT(tp20.update(uint256(20), 20, makeSkipList(20)));
1046 BEAST_EXPECT(tp10.canMergeInto(tp20));
1047 BEAST_EXPECT(tp9.canMergeInto(tp20));
1048 BEAST_EXPECT(!tp20.canMergeInto(tp10));
1049 BEAST_EXPECT(!tp20.canMergeInto(tp9));
1050 }
1051
1052 void
1054 {
1055 testcase("config test");
1056 {
1057 Config c;
1058 BEAST_EXPECT(c.LEDGER_REPLAY == false);
1059 }
1060
1061 {
1062 Config c;
1063 std::string toLoad(R"rippleConfig(
1064[ledger_replay]
10651
1066)rippleConfig");
1067 c.loadFromString(toLoad);
1068 BEAST_EXPECT(c.LEDGER_REPLAY == true);
1069 }
1070
1071 {
1072 Config c;
1073 std::string toLoad = (R"rippleConfig(
1074[ledger_replay]
10750
1076)rippleConfig");
1077 c.loadFromString(toLoad);
1078 BEAST_EXPECT(c.LEDGER_REPLAY == false);
1079 }
1080 }
1081
1082 void
1084 {
1085 testcase("handshake test");
1086 auto handshake = [&](bool client, bool server, bool expecting) -> bool {
1087 auto request =
1088 ripple::makeRequest(true, false, client, false, false);
1089 http_request_type http_request;
1090 http_request.version(request.version());
1091 http_request.base() = request.base();
1092 bool serverResult =
1093 peerFeatureEnabled(http_request, FEATURE_LEDGER_REPLAY, server);
1094 if (serverResult != expecting)
1095 return false;
1096
1097 beast::IP::Address addr =
1098 boost::asio::ip::make_address("172.1.1.100");
1099 jtx::Env serverEnv(*this);
1100 serverEnv.app().config().LEDGER_REPLAY = server;
1101 auto http_resp = ripple::makeResponse(
1102 true,
1103 http_request,
1104 addr,
1105 addr,
1106 uint256{1},
1107 1,
1108 {1, 0},
1109 serverEnv.app());
1110 auto const clientResult =
1111 peerFeatureEnabled(http_resp, FEATURE_LEDGER_REPLAY, client);
1112 if (clientResult != expecting)
1113 return false;
1114
1115 return true;
1116 };
1117
1118 BEAST_EXPECT(handshake(false, false, false));
1119 BEAST_EXPECT(handshake(false, true, false));
1120 BEAST_EXPECT(handshake(true, false, false));
1121 BEAST_EXPECT(handshake(true, true, true));
1122 }
1123
1124 void
1125 testAllLocal(int totalReplay)
1126 {
1127 testcase("local node has all the ledgers");
1128 auto psBhvr = PeerSetBehavior::DropAll;
1129 auto ilBhvr = InboundLedgersBehavior::DropAll;
1130 auto peerFeature = PeerFeature::None;
1131
1132 NetworkOfTwo net(*this, {totalReplay + 1}, psBhvr, ilBhvr, peerFeature);
1133
1134 auto l = net.server.ledgerMaster.getClosedLedger();
1135 uint256 finalHash = l->info().hash;
1136 for (int i = 0; i < totalReplay; ++i)
1137 {
1138 BEAST_EXPECT(l);
1139 if (l)
1140 {
1141 net.client.ledgerMaster.storeLedger(l);
1142 l = net.server.ledgerMaster.getLedgerByHash(
1143 l->info().parentHash);
1144 }
1145 else
1146 break;
1147 }
1148
1149 net.client.replayer.replay(
1150 InboundLedger::Reason::GENERIC, finalHash, totalReplay);
1151
1152 std::vector<TaskStatus> deltaStatuses(
1153 totalReplay - 1, TaskStatus::Completed);
1154 BEAST_EXPECT(net.client.waitAndCheckStatus(
1155 finalHash,
1156 totalReplay,
1159 deltaStatuses));
1160
1161 // sweep
1162 net.client.replayer.sweep();
1163 BEAST_EXPECT(net.client.countsAsExpected(0, 0, 0));
1164 }
1165
1166 void
1167 testAllInboundLedgers(int totalReplay)
1168 {
1169 testcase("all the ledgers from InboundLedgers");
1170 NetworkOfTwo net(
1171 *this,
1172 {totalReplay + 1},
1176
1177 auto l = net.server.ledgerMaster.getClosedLedger();
1178 uint256 finalHash = l->info().hash;
1179 net.client.replayer.replay(
1180 InboundLedger::Reason::GENERIC, finalHash, totalReplay);
1181
1182 std::vector<TaskStatus> deltaStatuses(
1183 totalReplay - 1, TaskStatus::Completed);
1184 BEAST_EXPECT(net.client.waitAndCheckStatus(
1185 finalHash,
1186 totalReplay,
1189 deltaStatuses));
1190
1191 // sweep
1192 net.client.replayer.sweep();
1193 BEAST_EXPECT(net.client.countsAsExpected(0, 0, 0));
1194 }
1195
1196 void
1197 testPeerSetBehavior(PeerSetBehavior peerSetBehavior, int totalReplay = 4)
1198 {
1199 switch (peerSetBehavior)
1200 {
1202 testcase("good network");
1203 break;
1205 testcase("network drops 50% messages");
1206 break;
1208 testcase("network repeats all messages");
1209 break;
1210 default:
1211 return;
1212 }
1213
1214 NetworkOfTwo net(
1215 *this,
1216 {totalReplay + 1},
1217 peerSetBehavior,
1220
1221 // feed client with start ledger since InboundLedgers drops all
1222 auto l = net.server.ledgerMaster.getClosedLedger();
1223 uint256 finalHash = l->info().hash;
1224 for (int i = 0; i < totalReplay - 1; ++i)
1225 {
1226 l = net.server.ledgerMaster.getLedgerByHash(l->info().parentHash);
1227 }
1228 net.client.ledgerMaster.storeLedger(l);
1229
1230 net.client.replayer.replay(
1231 InboundLedger::Reason::GENERIC, finalHash, totalReplay);
1232
1233 std::vector<TaskStatus> deltaStatuses(
1234 totalReplay - 1, TaskStatus::Completed);
1235 BEAST_EXPECT(net.client.waitAndCheckStatus(
1236 finalHash,
1237 totalReplay,
1240 deltaStatuses));
1241 BEAST_EXPECT(net.client.waitForLedgers(finalHash, totalReplay));
1242
1243 // sweep
1244 net.client.replayer.sweep();
1245 BEAST_EXPECT(net.client.countsAsExpected(0, 0, 0));
1246 }
1247
1248 void
1250 {
1251 testcase("stop before timeout");
1252 int totalReplay = 3;
1253 NetworkOfTwo net(
1254 *this,
1255 {totalReplay + 1},
1259
1260 auto l = net.server.ledgerMaster.getClosedLedger();
1261 uint256 finalHash = l->info().hash;
1262 net.client.replayer.replay(
1263 InboundLedger::Reason::GENERIC, finalHash, totalReplay);
1264
1265 std::vector<TaskStatus> deltaStatuses;
1266 BEAST_EXPECT(net.client.checkStatus(
1267 finalHash,
1268 totalReplay,
1271 deltaStatuses));
1272
1273 BEAST_EXPECT(net.client.countsAsExpected(1, 1, 0));
1274 net.client.replayer.stop();
1275 BEAST_EXPECT(net.client.countsAsExpected(0, 0, 0));
1276 }
1277
1278 void
1280 {
1281 testcase("SkipListAcquire bad reply");
1282 int totalReplay = 3;
1283 NetworkOfTwo net(
1284 *this,
1285 {totalReplay + 1 + 1},
1289
1290 auto l = net.server.ledgerMaster.getClosedLedger();
1291 uint256 finalHash = l->info().hash;
1292 net.client.replayer.replay(
1293 InboundLedger::Reason::GENERIC, finalHash, totalReplay);
1294
1295 auto skipList = net.client.findSkipListAcquire(finalHash);
1296
1297 std::uint8_t payload[55] = {
1298 0x6A, 0x09, 0xE6, 0x67, 0xF3, 0xBC, 0xC9, 0x08, 0xB2};
1299 auto item =
1300 make_shamapitem(uint256(12345), Slice(payload, sizeof(payload)));
1301 skipList->processData(l->seq(), item);
1302
1303 std::vector<TaskStatus> deltaStatuses;
1304 BEAST_EXPECT(net.client.waitAndCheckStatus(
1305 finalHash,
1306 totalReplay,
1309 deltaStatuses));
1310
1311 // add another task
1312 net.client.replayer.replay(
1313 InboundLedger::Reason::GENERIC, finalHash, totalReplay + 1);
1314 BEAST_EXPECT(net.client.waitAndCheckStatus(
1315 finalHash,
1316 totalReplay,
1319 deltaStatuses));
1320 BEAST_EXPECT(net.client.countsAsExpected(2, 1, 0));
1321 }
1322
1323 void
1325 {
1326 testcase("LedgerDeltaAcquire bad reply");
1327 int totalReplay = 3;
1328 NetworkOfTwo net(
1329 *this,
1330 {totalReplay + 1},
1334
1335 auto l = net.server.ledgerMaster.getClosedLedger();
1336 uint256 finalHash = l->info().hash;
1337 net.client.ledgerMaster.storeLedger(l);
1338 net.client.replayer.replay(
1339 InboundLedger::Reason::GENERIC, finalHash, totalReplay);
1340
1341 auto delta = net.client.findLedgerDeltaAcquire(l->info().parentHash);
1342 delta->processData(
1343 l->info(), // wrong ledger info
1345 BEAST_EXPECT(net.client.taskStatus(delta) == TaskStatus::Failed);
1346 BEAST_EXPECT(
1347 net.client.taskStatus(net.client.findTask(
1348 finalHash, totalReplay)) == TaskStatus::Failed);
1349
1350 // add another task
1351 net.client.replayer.replay(
1352 InboundLedger::Reason::GENERIC, finalHash, totalReplay + 1);
1353 BEAST_EXPECT(
1354 net.client.taskStatus(net.client.findTask(
1355 finalHash, totalReplay + 1)) == TaskStatus::Failed);
1356 }
1357
1358 void
1360 {
1361 testcase("Overlap tasks");
1362 int totalReplay = 5;
1363 NetworkOfTwo net(
1364 *this,
1365 {totalReplay * 3 + 1},
1369 auto l = net.server.ledgerMaster.getClosedLedger();
1370 uint256 finalHash = l->info().hash;
1371 net.client.replayer.replay(
1372 InboundLedger::Reason::GENERIC, finalHash, totalReplay);
1373 std::vector<TaskStatus> deltaStatuses(
1374 totalReplay - 1, TaskStatus::Completed);
1375 BEAST_EXPECT(net.client.waitAndCheckStatus(
1376 finalHash,
1377 totalReplay,
1380 deltaStatuses));
1381 BEAST_EXPECT(net.client.waitForLedgers(finalHash, totalReplay));
1382
1383 // same range, same reason
1384 net.client.replayer.replay(
1385 InboundLedger::Reason::GENERIC, finalHash, totalReplay);
1386 BEAST_EXPECT(net.client.countsAsExpected(1, 1, totalReplay - 1));
1387 // same range, different reason
1388 net.client.replayer.replay(
1389 InboundLedger::Reason::CONSENSUS, finalHash, totalReplay);
1390 BEAST_EXPECT(net.client.countsAsExpected(2, 1, totalReplay - 1));
1391
1392 // no overlap
1393 for (int i = 0; i < totalReplay + 2; ++i)
1394 {
1395 l = net.server.ledgerMaster.getLedgerByHash(l->info().parentHash);
1396 }
1397 auto finalHash_early = l->info().hash;
1398 net.client.replayer.replay(
1399 InboundLedger::Reason::GENERIC, finalHash_early, totalReplay);
1400 BEAST_EXPECT(net.client.waitAndCheckStatus(
1401 finalHash_early,
1402 totalReplay,
1405 deltaStatuses)); // deltaStatuses no change
1406 BEAST_EXPECT(net.client.waitForLedgers(finalHash_early, totalReplay));
1407 BEAST_EXPECT(net.client.countsAsExpected(3, 2, 2 * (totalReplay - 1)));
1408
1409 // partial overlap
1410 l = net.server.ledgerMaster.getLedgerByHash(l->info().parentHash);
1411 auto finalHash_moreEarly = l->info().parentHash;
1412 net.client.replayer.replay(
1413 InboundLedger::Reason::GENERIC, finalHash_moreEarly, totalReplay);
1414 BEAST_EXPECT(net.client.waitAndCheckStatus(
1415 finalHash_moreEarly,
1416 totalReplay,
1419 deltaStatuses)); // deltaStatuses no change
1420 BEAST_EXPECT(
1421 net.client.waitForLedgers(finalHash_moreEarly, totalReplay));
1422 BEAST_EXPECT(
1423 net.client.countsAsExpected(4, 3, 2 * (totalReplay - 1) + 2));
1424
1425 // cover
1426 net.client.replayer.replay(
1427 InboundLedger::Reason::GENERIC, finalHash, totalReplay * 3);
1428 deltaStatuses =
1429 std::vector<TaskStatus>(totalReplay * 3 - 1, TaskStatus::Completed);
1430 BEAST_EXPECT(net.client.waitAndCheckStatus(
1431 finalHash,
1432 totalReplay * 3,
1435 deltaStatuses)); // deltaStatuses changed
1436 BEAST_EXPECT(net.client.waitForLedgers(finalHash, totalReplay * 3));
1437 BEAST_EXPECT(net.client.countsAsExpected(5, 3, totalReplay * 3 - 1));
1438
1439 // sweep
1440 net.client.replayer.sweep();
1441 BEAST_EXPECT(net.client.countsAsExpected(0, 0, 0));
1442 }
1443
1444 void
1465};
1466
1468{
1469 void
1471 {
1472 testcase("SkipListAcquire timeout");
1473 int totalReplay = 3;
1474 NetworkOfTwo net(
1475 *this,
1476 {totalReplay + 1},
1480
1481 auto l = net.server.ledgerMaster.getClosedLedger();
1482 uint256 finalHash = l->info().hash;
1483 net.client.replayer.replay(
1484 InboundLedger::Reason::GENERIC, finalHash, totalReplay);
1485
1486 std::vector<TaskStatus> deltaStatuses;
1487 BEAST_EXPECT(net.client.waitAndCheckStatus(
1488 finalHash,
1489 totalReplay,
1492 deltaStatuses));
1493
1494 // sweep
1495 BEAST_EXPECT(net.client.countsAsExpected(1, 1, 0));
1496 net.client.replayer.sweep();
1497 BEAST_EXPECT(net.client.countsAsExpected(0, 0, 0));
1498 }
1499
1500 void
1502 {
1503 testcase("LedgerDeltaAcquire timeout");
1504 int totalReplay = 3;
1505 NetworkOfTwo net(
1506 *this,
1507 {totalReplay + 1},
1511
1512 auto l = net.server.ledgerMaster.getClosedLedger();
1513 uint256 finalHash = l->info().hash;
1514 net.client.ledgerMaster.storeLedger(l);
1515 net.client.replayer.replay(
1516 InboundLedger::Reason::GENERIC, finalHash, totalReplay);
1517
1518 std::vector<TaskStatus> deltaStatuses(
1519 totalReplay - 1, TaskStatus::Failed);
1520 deltaStatuses.back() = TaskStatus::Completed; // in client ledgerMaster
1521 BEAST_EXPECT(net.client.waitAndCheckStatus(
1522 finalHash,
1523 totalReplay,
1526 deltaStatuses));
1527
1528 // sweep
1529 BEAST_EXPECT(net.client.countsAsExpected(1, 1, totalReplay - 1));
1530 net.client.replayer.sweep();
1531 BEAST_EXPECT(net.client.countsAsExpected(0, 0, 0));
1532 }
1533
1534 void
1535 run() override
1536 {
1539 }
1540};
1541
1543{
1544 void
1545 run() override
1546 {
1547 testcase("Acquire 1000 ledgers");
1548 int totalReplay = 250;
1549 int rounds = 4;
1550 NetworkOfTwo net(
1551 *this,
1552 {totalReplay * rounds + 1},
1556
1557 std::vector<uint256> finishHashes;
1558 auto l = net.server.ledgerMaster.getClosedLedger();
1559 for (int i = 0; i < rounds; ++i)
1560 {
1561 finishHashes.push_back(l->info().hash);
1562 for (int j = 0; j < totalReplay; ++j)
1563 {
1564 l = net.server.ledgerMaster.getLedgerByHash(
1565 l->info().parentHash);
1566 }
1567 }
1568 BEAST_EXPECT(finishHashes.size() == rounds);
1569
1570 for (int i = 0; i < rounds; ++i)
1571 {
1572 net.client.replayer.replay(
1573 InboundLedger::Reason::GENERIC, finishHashes[i], totalReplay);
1574 }
1575
1576 std::vector<TaskStatus> deltaStatuses(
1577 totalReplay - 1, TaskStatus::Completed);
1578 for (int i = 0; i < rounds; ++i)
1579 {
1580 BEAST_EXPECT(net.client.waitAndCheckStatus(
1581 finishHashes[i],
1582 totalReplay,
1585 deltaStatuses));
1586 }
1587
1588 BEAST_EXPECT(
1589 net.client.waitForLedgers(finishHashes[0], totalReplay * rounds));
1590 BEAST_EXPECT(net.client.countsAsExpected(
1591 rounds, rounds, rounds * (totalReplay - 1)));
1592
1593 // sweep
1594 net.client.replayer.sweep();
1595 BEAST_EXPECT(net.client.countsAsExpected(0, 0, 0));
1596 }
1597};
1598
1599BEAST_DEFINE_TESTSUITE(LedgerReplay, app, ripple);
1600BEAST_DEFINE_TESTSUITE_PRIO(LedgerReplayer, app, ripple, 1);
1601BEAST_DEFINE_TESTSUITE(LedgerReplayerTimeout, app, ripple);
1602BEAST_DEFINE_TESTSUITE_MANUAL(LedgerReplayerLong, app, ripple);
1603
1604} // namespace test
1605} // namespace ripple
T back(T... args)
Represents a JSON value.
Definition json_value.h:130
A version-independent IP address and port combination.
Definition IPEndpoint.h:19
A testsuite class.
Definition suite.h:52
testcase_t testcase
Memberspace for declaring test cases.
Definition suite.h:152
virtual Config & config()=0
virtual LedgerMaster & getLedgerMaster()=0
virtual Logs & logs()=0
bool LEDGER_REPLAY
Definition Config.h:204
void loadFromString(std::string const &fileContents)
Load the config from the contents of the string.
Definition Config.cpp:460
Manages the lifetime of inbound ledgers.
std::shared_ptr< Ledger const > getClosedLedger()
bool storeLedger(std::shared_ptr< Ledger const > ledger)
std::shared_ptr< Ledger const > getLedgerByHash(uint256 const &hash)
protocol::TMReplayDeltaResponse processReplayDeltaRequest(std::shared_ptr< protocol::TMReplayDeltaRequest > const &msg)
Process TMReplayDeltaRequest and return TMReplayDeltaResponse.
bool processProofPathResponse(std::shared_ptr< protocol::TMProofPathResponse > const &msg)
Process TMProofPathResponse.
bool processReplayDeltaResponse(std::shared_ptr< protocol::TMReplayDeltaResponse > const &msg)
Process TMReplayDeltaResponse.
protocol::TMProofPathResponse processProofPathRequest(std::shared_ptr< protocol::TMProofPathRequest > const &msg)
Process TMProofPathRequest and return TMProofPathResponse.
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.
std::vector< std::shared_ptr< LedgerReplayTask > > tasks_
hash_map< uint256, std::weak_ptr< SkipListAcquire > > skipLists_
hash_map< uint256, std::weak_ptr< LedgerDeltaAcquire > > deltas_
beast::severities::Severity threshold() const
Definition Log.cpp:147
Supports data retrieval by managing a set of peers.
Definition PeerSet.h:21
Represents a peer connection in the overlay.
std::uint32_t id_t
Uniquely identifies a peer.
A public key.
Definition PublicKey.h:43
A consumption charge.
Definition Charge.h:11
An immutable linear range of bytes.
Definition Slice.h:27
static constexpr std::size_t size()
Definition base_uint.h:507
bool waitForLedgers(uint256 const &finishLedgerHash, int totalReplay)
bool asExpected(uint256 const &hash, int totalReplay, TaskStatus taskExpect, TaskStatus skiplistExpect, std::vector< TaskStatus > const &deltaExpects)
bool waitAndCheckStatus(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)
LedgerReplayMsgHandler serverMsgHandler
bool countsAsExpected(std::size_t tasks, std::size_t skipLists, std::size_t deltas)
bool asExpected(std::shared_ptr< LedgerReplayTask > const &task, TaskStatus taskExpect, TaskStatus skiplistExpect, std::vector< TaskStatus > const &deltaExpects)
std::vector< std::shared_ptr< LedgerReplayTask > > getTasks()
std::shared_ptr< LedgerDeltaAcquire > findLedgerDeltaAcquire(uint256 const &hash)
bool haveLedgers(uint256 const &finishLedgerHash, int totalReplay)
LedgerReplayClient(beast::unit_test::suite &suite, LedgerServer &server, PeerSetBehavior behavior=PeerSetBehavior::Good, InboundLedgersBehavior inboundBhvr=InboundLedgersBehavior::Good, PeerFeature peerFeature=PeerFeature::LedgerReplayEnabled)
bool checkStatus(uint256 const &hash, int totalReplay, TaskStatus taskExpect, TaskStatus skiplistExpect, std::vector< TaskStatus > const &deltaExpects)
TaskStatus taskStatus(std::shared_ptr< T > const &t)
void addLedger(std::shared_ptr< Ledger const > const &l)
std::shared_ptr< SkipListAcquire > findSkipListAcquire(uint256 const &hash)
Simulate a network InboundLedgers.
virtual void acquireAsync(uint256 const &hash, std::uint32_t seq, InboundLedger::Reason reason) override
virtual void onLedgerFetched() override
Called when a complete ledger is obtained.
virtual bool gotLedgerData(LedgerHash const &ledgerHash, std::shared_ptr< Peer >, std::shared_ptr< protocol::TMLedgerData >) override
virtual std::shared_ptr< InboundLedger > find(LedgerHash const &hash) override
virtual ~MagicInboundLedgers()=default
virtual Json::Value getInfo() override
virtual size_t cacheSize() override
virtual void logFailure(uint256 const &h, std::uint32_t seq) override
MagicInboundLedgers(LedgerMaster &ledgerSource, LedgerMaster &ledgerSink, InboundLedgersBehavior bhvr)
virtual bool isFailure(uint256 const &h) override
virtual void gotStaleData(std::shared_ptr< protocol::TMLedgerData > packet) override
virtual std::size_t fetchRate() override
Returns the rate of historical ledger fetches per minute.
virtual std::shared_ptr< Ledger const > acquire(uint256 const &hash, std::uint32_t seq, InboundLedger::Reason) override
std::unique_ptr< PeerSet > build() override
TestPeerSetBuilder(LedgerReplayMsgHandler &me, LedgerReplayMsgHandler &other, PeerSetBehavior bhvr, PeerFeature peerFeature)
Simulate a network peer.
bool hasLedger(uint256 const &hash, std::uint32_t seq) const override
void setPublisherListSequence(PublicKey const &, std::size_t const) override
bool cluster() const override
Returns true if this connection is a member of the cluster.
std::optional< std::size_t > publisherListSequence(PublicKey const &) const override
void removeTxQueue(uint256 const &) override
Remove hash from the transactions' hashes queue.
beast::IP::Endpoint getRemoteAddress() const override
TestPeer(bool enableLedgerReplay)
int getScore(bool) const override
PublicKey const & getNodePublic() 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
void send(std::shared_ptr< Message > const &m) override
void ledgerRange(std::uint32_t &minSeq, std::uint32_t &maxSeq) const override
void addTxQueue(uint256 const &) override
Aggregate transaction's hash.
id_t id() const override
bool txReduceRelayEnabled() const override
bool isHighLatency() const override
bool hasTxSet(uint256 const &hash) const override
std::string const & fingerprint() const override
uint256 const & getClosedLedgerHash() const override
bool compressionEnabled() const override
bool hasRange(std::uint32_t uMin, std::uint32_t uMax) override
bool supportsFeature(ProtocolFeature f) const override
void sendTxQueue() override
Send aggregated transactions' hashes.
Immutable cryptographic account descriptor.
Definition Account.h:20
A transaction testing environment.
Definition Env.h:102
bool close(NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)
Close and advance the ledger.
Definition Env.cpp:103
Application & app()
Definition Env.h:242
beast::Journal const journal
Definition Env.h:143
Env & apply(JsonValue &&jv, FN const &... fN)
Apply funclets and submit.
Definition Env.h:563
void fund(bool setDefaultRipple, STAmount const &amount, Account const &account)
Definition Env.cpp:271
Set the fee on a JTx.
Definition fee.h:18
Set the regular signature on a JTx.
Definition sig.h:16
T count(T... args)
T emplace_back(T... args)
T find_if(T... args)
T insert(T... args)
T is_same_v
boost::asio::ip::address Address
Definition IPAddress.h:20
A namespace for easy access to logging severity values.
Definition Journal.h:11
Severity
Severity level / threshold of a Journal message.
Definition Journal.h:13
Keylet const & skip() noexcept
The index of the "short" skip list.
Definition Indexes.cpp:177
static autofill_t const autofill
Definition tags.h:23
PrettyAmount drops(Integer i)
Returns an XRP PrettyAmount, which is trivially convertible to STAmount.
Json::Value pay(AccountID const &account, AccountID const &to, AnyAmount amount)
Create a payment.
Definition pay.cpp:11
std::unique_ptr< Config > envconfig()
creates and initializes a default configuration for jtx::Env
Definition envconfig.h:35
XRP_t const XRP
Converts to XRP Issue or STAmount.
Definition amount.cpp:92
static uint256 ledgerHash(LedgerInfo const &info)
void logAll(LedgerServer &server, LedgerReplayClient &client, beast::severities::Severity level=Severity::kTrace)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
base_uint< 256 > uint256
Definition base_uint.h:539
http_response_type makeResponse(bool crawlPublic, http_request_type const &req, beast::IP::Address public_ip, beast::IP::Address remote_ip, uint256 const &sharedValue, std::optional< std::uint32_t > networkID, ProtocolVersion protocol, Application &app)
Make http response.
static constexpr char FEATURE_LEDGER_REPLAY[]
Definition Handshake.h:128
PublicKey derivePublicKey(KeyType type, SecretKey const &sk)
Derive the public key from a secret key.
SecretKey randomSecretKey()
Create a secret key using secure random numbers.
KeyType
Definition KeyType.h:9
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.
boost::beast::http::request< boost::beast::http::dynamic_body > http_request_type
Definition Handoff.h:14
boost::intrusive_ptr< SHAMapItem > make_shamapitem(uint256 const &tag, Slice data)
Definition SHAMapItem.h:142
bool peerFeatureEnabled(headers const &request, std::string const &feature, std::string value, bool config)
Check if a feature should be enabled for a peer.
Definition Handshake.h:179
auto makeRequest(bool crawlPublic, bool comprEnabled, bool ledgerReplayEnabled, bool txReduceRelayEnabled, bool vpReduceRelayEnabled) -> request_type
Make outbound http request.
@ tapNONE
Definition ApplyView.h:12
@ ledgerMaster
ledger master data for signing
STL namespace.
T push_back(T... args)
T size(T... args)
T sleep_for(T... args)
uint256 key
Definition Keylet.h:21
void run() override
Runs the suite.
Test cases: LedgerReplayer_test: – process TMProofPathRequest and TMProofPathResponse – process TMRep...
void run() override
Runs the suite.
void testPeerSetBehavior(PeerSetBehavior peerSetBehavior, int totalReplay=4)
Utility class for (1) creating ledgers with txns and (2) providing the ledgers via the ledgerMaster.
void createAccounts(int newAccounts)
LedgerReplayMsgHandler msgHandler
std::vector< jtx::Account > accounts
void createLedgerHistory()
create ledger history
LedgerServer(beast::unit_test::suite &suite, Parameter const &p)
NetworkOfTwo(beast::unit_test::suite &suite, LedgerServer::Parameter const &param, PeerSetBehavior behavior=PeerSetBehavior::Good, InboundLedgersBehavior inboundBhvr=InboundLedgersBehavior::Good, PeerFeature peerFeature=PeerFeature::LedgerReplayEnabled)
Simulate a peerSet that supplies peers to ledger replay subtasks.
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.
LedgerReplayMsgHandler & remote
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_t > const & getPeerIds() const override
get the set of ids of previously added peers
LedgerReplayMsgHandler & local
std::shared_ptr< TestPeer > dummyPeer
Set the sequence number on a JTx.
Definition seq.h:15
T to_string(T... args)