1#include <test/csf/ledgers.h>
3#include <xrpld/consensus/LedgerTrie.h>
5#include <xrpl/beast/unit_test/suite.h>
22 LedgerHistoryHelper h;
36 LedgerHistoryHelper h;
60 LedgerHistoryHelper h;
86 LedgerHistoryHelper h;
104 LedgerHistoryHelper h;
125 LedgerHistoryHelper h;
149 LedgerHistoryHelper h;
152 BEAST_EXPECT(!t.
remove(h[
"ab"]));
154 BEAST_EXPECT(!t.
remove(h[
"a"]));
160 LedgerHistoryHelper h;
166 BEAST_EXPECT(!t.
remove(h[
"abc"]));
174 LedgerHistoryHelper h;
178 BEAST_EXPECT(t.
remove(h[
"abc"]));
184 BEAST_EXPECT(t.
remove(h[
"abc"], 2));
190 BEAST_EXPECT(t.
remove(h[
"abc"], 300));
197 LedgerHistoryHelper h;
206 BEAST_EXPECT(t.
remove(h[
"abc"]));
216 LedgerHistoryHelper h;
226 BEAST_EXPECT(t.
remove(h[
"abc"]));
236 LedgerHistoryHelper h;
245 BEAST_EXPECT(t.
remove(h[
"abc"]));
254 LedgerHistoryHelper h;
279 LedgerHistoryHelper h;
280 BEAST_EXPECT(t.
empty());
282 Ledger const genesis = h[
""];
284 BEAST_EXPECT(!t.
empty());
286 BEAST_EXPECT(t.
empty());
289 BEAST_EXPECT(!t.
empty());
291 BEAST_EXPECT(t.
empty());
300 LedgerHistoryHelper h;
345 using Seq = Ledger::Seq;
355 LedgerHistoryHelper h;
356 Ledger const genesis = h[
""];
361 BEAST_EXPECT(t.
remove(genesis));
363 BEAST_EXPECT(!t.
remove(genesis));
368 LedgerHistoryHelper h;
377 LedgerHistoryHelper h;
390 LedgerHistoryHelper h;
403 LedgerHistoryHelper h;
421 LedgerHistoryHelper h;
439 LedgerHistoryHelper h;
443 BEAST_EXPECT(h[
"abce"].
id() > h[
"abcd"].
id());
449 BEAST_EXPECT(h[
"abce"].
id() > h[
"abcd"].
id());
458 LedgerHistoryHelper h;
463 BEAST_EXPECT(h[
"abce"].
id() > h[
"abcd"].
id());
481 LedgerHistoryHelper h;
496 LedgerHistoryHelper h;
534 LedgerHistoryHelper h;
627 LedgerHistoryHelper h;
628 BEAST_EXPECT(!t.
remove(h[
""]));
642 BEAST_EXPECT(t.
remove(h[
"e"]));
653 LedgerHistoryHelper h;
675 char const depth = depthDist(gen);
677 for (
char d = 0; d < depth; ++d)
679 char const a = offset + widthDist(gen);
681 offset = (a + 1) * width;
Ancestry trie of ledgers.
std::uint32_t tipSupport(Ledger const &ledger) const
Return count of tip support for the specific ledger.
bool empty() const
Return whether the trie is tracking any ledgers.
bool checkInvariants() const
Check the compressed trie and support invariants.
std::uint32_t branchSupport(Ledger const &ledger) const
Return the count of branch support for the specific ledger.
std::optional< SpanTip< Ledger > > getPreferred(Seq const largestIssued) const
Return the preferred ledger ID.
void insert(Ledger const &ledger, std::uint32_t count=1)
Insert and/or increment the support for the given ledger.
bool remove(Ledger const &ledger, std::uint32_t count=1)
Decrease support for a ledger, removing and compressing if possible.
void run() override
Runs the suite.
BEAST_DEFINE_TESTSUITE(AMMClawback, app, xrpl)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Set the sequence number on a JTx.