3#include <xrpld/app/consensus/RCLValidations.h>
4#include <xrpld/app/ledger/Ledger.h>
6#include <xrpl/basics/base_uint.h>
7#include <xrpl/beast/unit_test.h>
17 testcase(
"Change validation trusted status");
21 v.setFieldU32(sfLedgerSequence, 123456);
24 BEAST_EXPECT(v->isTrusted());
26 BEAST_EXPECT(!v->isTrusted());
29 BEAST_EXPECT(!rcv.trusted());
31 BEAST_EXPECT(rcv.trusted());
33 BEAST_EXPECT(!rcv.trusted());
39 testcase(
"RCLValidatedLedger ancestry");
47 Seq
const maxAncestors = 256;
60 for (
auto i = 0; i < (2 * maxAncestors + 1); ++i)
63 next->updateSkipList();
69 Seq
const diverge = history.
size() / 2;
72 using namespace std::chrono_literals;
74 prev = altHistory.
back();
75 bool forceHash =
true;
76 while (altHistory.
size() < history.
size())
80 next->updateSkipList();
97 BEAST_EXPECT(a.seq() == Seq{0});
98 BEAST_EXPECT(a[Seq{0}] == ID{0});
99 BEAST_EXPECT(a.minSeq() == Seq{0});
106 BEAST_EXPECT(a.seq() == ledger->header().seq);
107 BEAST_EXPECT(a.minSeq() == a.seq() - maxAncestors);
109 for (Seq s = a.seq(); s > 0; s--)
112 BEAST_EXPECT(a[s] == history[s - 1]->header().hash);
114 BEAST_EXPECT(a[s] == ID{0});
124 for (
auto ledger : {history.
back(), history[maxAncestors - 1]})
134 for (Seq s = a.seq(); s > 0; s--)
139 BEAST_EXPECT(
mismatch(a, b) == b.seq() + 1);
140 BEAST_EXPECT(
mismatch(b, a) == b.seq() + 1);
144 BEAST_EXPECT(
mismatch(a, b) == Seq{1});
145 BEAST_EXPECT(
mismatch(b, a) == Seq{1});
152 for (Seq s = 1; s < history.
size(); ++s)
157 BEAST_EXPECT(a.seq() == b.seq());
160 BEAST_EXPECT(a[a.seq()] == b[b.seq()]);
161 BEAST_EXPECT(
mismatch(a, b) == a.seq() + 1);
162 BEAST_EXPECT(
mismatch(b, a) == a.seq() + 1);
166 BEAST_EXPECT(a[a.seq()] != b[b.seq()]);
167 BEAST_EXPECT(
mismatch(a, b) == diverge + 1);
168 BEAST_EXPECT(
mismatch(b, a) == diverge + 1);
176 for (Seq offset = diverge / 2; offset < 3 * diverge / 2; ++offset)
179 if (offset <= diverge)
181 BEAST_EXPECT(
mismatch(a, b) == b.seq() + 1);
185 BEAST_EXPECT(
mismatch(a, b) == diverge + 1);
194 testcase(
"RCLValidatedLedger LedgerTrie");
207 Seq
const maxAncestors = 256;
217 for (
auto i = 0; i < (maxAncestors + 10); ++i)
220 next->updateSkipList();
246 BEAST_EXPECT(trie.
remove(ledg_258, 3));
testcase_t testcase
Memberspace for declaring test cases.
virtual TimeKeeper & timeKeeper()=0
Ancestry trie of ledgers.
std::uint32_t tipSupport(Ledger const &ledger) const
Return count of tip support for the specific ledger.
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.
Wraps a ledger instance for use in generic Validations LedgerTrie.
Wrapper over STValidation for generic Validation code.
time_point closeTime() const
Returns the predicted close time, in network time.
time_point now() const override
Returns the current time.
void run() override
Runs the suite.
void testLedgerTrieRCLValidatedLedger()
void testRCLValidatedLedger()
A transaction testing environment.
ManualTimeKeeper & timeKeeper()
beast::Journal const journal
Keylet const & fees() noexcept
The (fixed) index of the object containing the ledger fees.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::pair< PublicKey, SecretKey > randomKeyPair(KeyType type)
Create a key pair using secure random numbers.
create_genesis_t const create_genesis
NodeID calcNodeID(PublicKey const &)
Calculate the 160-bit node ID from a node public key.
RCLValidatedLedger::Seq mismatch(RCLValidatedLedger const &a, RCLValidatedLedger const &b)