xrpld
Loading...
Searching...
No Matches
xrpl::test::TestFamily Class Reference

Test implementation of Family for unit tests. More...

#include <TestFamily.h>

Inheritance diagram for xrpl::test::TestFamily:
Collaboration diagram for xrpl::test::TestFamily:

Public Member Functions

 TestFamily (beast::Journal j)
NodeStore::Databasedb () override
NodeStore::Database const & db () const override
beast::Journal const & journal () override
std::shared_ptr< FullBelowCachegetFullBelowCache () override
 Return a pointer to the Family Full Below Cache.
std::shared_ptr< TreeNodeCachegetTreeNodeCache () override
 Return a pointer to the Family Tree Node Cache.
void sweep () override
void missingNodeAcquireBySeq (std::uint32_t refNum, uint256 const &nodeHash) override
 Acquire ledger that has a missing node by ledger sequence.
void missingNodeAcquireByHash (uint256 const &refHash, std::uint32_t refNum) override
 Acquire ledger that has a missing node by ledger hash.
void reset () override
TestStopwatchclock ()
 Access the test clock for time manipulation in tests.

Private Attributes

std::unique_ptr< NodeStore::Databasedb_
TestStopwatch clock_
std::shared_ptr< FullBelowCachefbCache_
std::shared_ptr< TreeNodeCachetnCache_
NodeStore::DummyScheduler scheduler_
beast::Journal j_

Detailed Description

Test implementation of Family for unit tests.

Uses an in-memory NodeStore database and simple caches. The missingNode methods throw since tests shouldn't encounter missing nodes.

Definition at line 19 of file TestFamily.h.

Constructor & Destructor Documentation

◆ TestFamily()

xrpl::test::TestFamily::TestFamily ( beast::Journal j)
explicit

Definition at line 30 of file TestFamily.h.

Member Function Documentation

◆ db() [1/2]

NodeStore::Database & xrpl::test::TestFamily::db ( )
overridevirtual

Implements xrpl::Family.

Definition at line 48 of file TestFamily.h.

◆ db() [2/2]

NodeStore::Database const & xrpl::test::TestFamily::db ( ) const
nodiscardoverridevirtual

Implements xrpl::Family.

Definition at line 54 of file TestFamily.h.

◆ journal()

beast::Journal const & xrpl::test::TestFamily::journal ( )
overridevirtual

Implements xrpl::Family.

Definition at line 60 of file TestFamily.h.

◆ getFullBelowCache()

std::shared_ptr< FullBelowCache > xrpl::test::TestFamily::getFullBelowCache ( )
overridevirtual

Return a pointer to the Family Full Below Cache.

Implements xrpl::Family.

Definition at line 66 of file TestFamily.h.

◆ getTreeNodeCache()

std::shared_ptr< TreeNodeCache > xrpl::test::TestFamily::getTreeNodeCache ( )
overridevirtual

Return a pointer to the Family Tree Node Cache.

Implements xrpl::Family.

Definition at line 72 of file TestFamily.h.

◆ sweep()

void xrpl::test::TestFamily::sweep ( )
overridevirtual

Implements xrpl::Family.

Definition at line 78 of file TestFamily.h.

◆ missingNodeAcquireBySeq()

void xrpl::test::TestFamily::missingNodeAcquireBySeq ( std::uint32_t refNum,
uint256 const & nodeHash )
overridevirtual

Acquire ledger that has a missing node by ledger sequence.

Parameters
refNumSequence of ledger to acquire.
nodeHashHash of missing node to report in throw.

Implements xrpl::Family.

Definition at line 85 of file TestFamily.h.

◆ missingNodeAcquireByHash()

void xrpl::test::TestFamily::missingNodeAcquireByHash ( uint256 const & refHash,
std::uint32_t refNum )
overridevirtual

Acquire ledger that has a missing node by ledger hash.

Parameters
refHashHash of ledger to acquire.
refNumLedger sequence with missing node.

Implements xrpl::Family.

Definition at line 91 of file TestFamily.h.

◆ reset()

void xrpl::test::TestFamily::reset ( )
overridevirtual

Implements xrpl::Family.

Definition at line 97 of file TestFamily.h.

◆ clock()

TestStopwatch & xrpl::test::TestFamily::clock ( )

Access the test clock for time manipulation in tests.

Definition at line 105 of file TestFamily.h.

Member Data Documentation

◆ db_

std::unique_ptr<NodeStore::Database> xrpl::test::TestFamily::db_
private

Definition at line 22 of file TestFamily.h.

◆ clock_

TestStopwatch xrpl::test::TestFamily::clock_
private

Definition at line 23 of file TestFamily.h.

◆ fbCache_

std::shared_ptr<FullBelowCache> xrpl::test::TestFamily::fbCache_
private

Definition at line 24 of file TestFamily.h.

◆ tnCache_

std::shared_ptr<TreeNodeCache> xrpl::test::TestFamily::tnCache_
private

Definition at line 25 of file TestFamily.h.

◆ scheduler_

NodeStore::DummyScheduler xrpl::test::TestFamily::scheduler_
private

Definition at line 26 of file TestFamily.h.

◆ j_

beast::Journal xrpl::test::TestFamily::j_
private

Definition at line 27 of file TestFamily.h.