rippled
Public Member Functions | Public Attributes | List of all members
ripple::test::csf::LedgerHistoryHelper Struct Reference

Helper for writing unit tests with controlled ledger histories. More...

Collaboration diagram for ripple::test::csf::LedgerHistoryHelper:
Collaboration graph
[legend]

Public Member Functions

 LedgerHistoryHelper ()
 
Ledger const & operator[] (std::string const &s)
 Get or create the ledger with the given string history. More...
 

Public Attributes

LedgerOracle oracle
 
Tx::ID nextTx {0}
 
std::unordered_map< std::string, Ledgerledgers
 
std::set< char > seen
 

Detailed Description

Helper for writing unit tests with controlled ledger histories.

This class allows clients to refer to distinct ledgers as strings, where each character in the string indicates a unique ledger. It enforces the uniqueness at runtime, but this simplifies creation of alternate ledger histories, e.g.

HistoryHelper hh; hh["a"] hh["ab"] hh["ac"] hh["abd"]

Creates a history like b - d / a - c

Definition at line 323 of file ledgers.h.

Constructor & Destructor Documentation

◆ LedgerHistoryHelper()

ripple::test::csf::LedgerHistoryHelper::LedgerHistoryHelper ( )

Definition at line 330 of file ledgers.h.

Member Function Documentation

◆ operator[]()

Ledger const& ripple::test::csf::LedgerHistoryHelper::operator[] ( std::string const &  s)

Get or create the ledger with the given string history.

Creates any necessary intermediate ledgers, but asserts if a letter is re-used (e.g. "abc" then "adc" would assert)

Definition at line 341 of file ledgers.h.

Member Data Documentation

◆ oracle

LedgerOracle ripple::test::csf::LedgerHistoryHelper::oracle

Definition at line 325 of file ledgers.h.

◆ nextTx

Tx::ID ripple::test::csf::LedgerHistoryHelper::nextTx {0}

Definition at line 326 of file ledgers.h.

◆ ledgers

std::unordered_map<std::string, Ledger> ripple::test::csf::LedgerHistoryHelper::ledgers

Definition at line 327 of file ledgers.h.

◆ seen

std::set<char> ripple::test::csf::LedgerHistoryHelper::seen

Definition at line 328 of file ledgers.h.