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)
node_store::Databasedb () override
node_store::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< node_store::Databasedb_
TestStopwatch clock_
std::shared_ptr< FullBelowCachefbCache_
std::shared_ptr< TreeNodeCachetnCache_
node_store::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 29 of file TestFamily.h.

Constructor & Destructor Documentation

◆ TestFamily()

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

Definition at line 40 of file TestFamily.h.

Member Function Documentation

◆ db() [1/2]

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

Implements xrpl::Family.

Definition at line 58 of file TestFamily.h.

◆ db() [2/2]

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

Implements xrpl::Family.

Definition at line 64 of file TestFamily.h.

◆ journal()

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

Implements xrpl::Family.

Definition at line 70 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 76 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 82 of file TestFamily.h.

◆ sweep()

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

Implements xrpl::Family.

Definition at line 88 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 95 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 101 of file TestFamily.h.

◆ reset()

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

Implements xrpl::Family.

Definition at line 107 of file TestFamily.h.

◆ clock()

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

Access the test clock for time manipulation in tests.

Definition at line 117 of file TestFamily.h.

Member Data Documentation

◆ db_

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

Definition at line 32 of file TestFamily.h.

◆ clock_

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

Definition at line 33 of file TestFamily.h.

◆ fbCache_

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

Definition at line 34 of file TestFamily.h.

◆ tnCache_

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

Definition at line 35 of file TestFamily.h.

◆ scheduler_

node_store::DummyScheduler xrpl::test::TestFamily::scheduler_
private

Definition at line 36 of file TestFamily.h.

◆ j_

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

Definition at line 37 of file TestFamily.h.