1#include <test/shamap/common.h>
2#include <test/unit_test/SuiteJournal.h>
4#include <xrpl/basics/Blob.h>
5#include <xrpl/basics/Log.h>
6#include <xrpl/basics/SHAMapHash.h>
7#include <xrpl/basics/Slice.h>
8#include <xrpl/basics/UnorderedContainers.h>
9#include <xrpl/basics/contract.h>
10#include <xrpl/basics/random.h>
11#include <xrpl/beast/unit_test/suite.h>
12#include <xrpl/beast/utility/Journal.h>
13#include <xrpl/beast/xor_shift_engine.h>
14#include <xrpl/protocol/Serializer.h>
15#include <xrpl/protocol/digest.h>
16#include <xrpl/shamap/SHAMap.h>
17#include <xrpl/shamap/SHAMapItem.h>
18#include <xrpl/shamap/SHAMapMissingNode.h>
19#include <xrpl/shamap/SHAMapSyncFilter.h>
20#include <xrpl/shamap/SHAMapTreeNode.h>
22#include <boost/smart_ptr/intrusive_ptr.hpp>
71 Map::iterator
const it =
map.find(nodeHash);
74 JLOG(
journal.fatal()) <<
"Test filter missing node";
84 static boost::intrusive_ptr<Item>
88 for (
int d = 0; d < 3; ++d)
A generic endpoint for log messages.
void pass()
Record a successful test condition.
uint256 const & asUInt256() const
SHAMapSyncFilter()=default
A SHAMap is both a radix tree with a fan-out of 16 and a Merkle tree.
bool addItem(SHAMapNodeType type, boost::intrusive_ptr< SHAMapItem const > item)
uint256 getSHA512Half() const
Slice slice() const noexcept
void onFetch(Map &map, SHAMapHash const &hash, Blob const &blob)
hash_map< SHAMapHash, Blob > Map
static boost::intrusive_ptr< Item > makeRandomItemMember(beast::xor_shift_engine &r)
static void addRandomItems(std::size_t n, Table &t, beast::xor_shift_engine &r)
static constexpr auto kTableItems
static constexpr auto kTableItemsExtra
void run() override
Runs the suite.
detail::XorShiftEngine<> xor_shift_engine
XOR-shift Generator.
Severity
Severity level / threshold of a Journal message.
BEAST_DEFINE_TESTSUITE(IntrusiveShared, basics, xrpl)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
sha512_half_hasher::result_type sha512Half(Args const &... args)
Returns the SHA512-Half of a series of objects.
std::enable_if_t< std::is_integral_v< Integral > &&detail::is_engine< Engine >::value, Integral > randInt(Engine &engine, Integral min, Integral max)
Return a uniformly distributed random integer.
boost::intrusive_ptr< SHAMapItem > makeShamapitem(uint256 const &tag, Slice data)
std::unordered_map< Key, Value, Hash, Pred, Allocator > hash_map
std::vector< unsigned char > Blob
Storage for linear binary data.
XRPL_NO_SANITIZE_ADDRESS void Throw(Args &&... args)
std::enable_if_t< std::is_same_v< T, char >||std::is_same_v< T, unsigned char >, Slice > makeSlice(std::array< T, N > const &a)
void operator()(std::uint32_t refNum) const
void gotNode(bool fromFilter, SHAMapHash const &nodeHash, std::uint32_t ledgerSeq, Blob &&nodeData, SHAMapNodeType type) const override
std::optional< Blob > getNode(SHAMapHash const &nodeHash) const override
TestFilter(Map &map, beast::Journal journal)