rippled
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
xrpl::AmendmentTable_test Class Referencefinal
Inheritance diagram for xrpl::AmendmentTable_test:
Inheritance graph
[legend]
Collaboration diagram for xrpl::AmendmentTable_test:
Collaboration graph
[legend]

Public Member Functions

 AmendmentTable_test ()
 
std::unique_ptr< AmendmentTablemakeTable (Application &app, std::chrono::seconds majorityTime, std::vector< AmendmentTable::FeatureInfo > const &supported, Section const &enabled, Section const &vetoed)
 
std::unique_ptr< AmendmentTablemakeTable (test::jtx::Env &env, std::chrono::seconds majorityTime, std::vector< AmendmentTable::FeatureInfo > const &supported, Section const &enabled, Section const &vetoed)
 
std::unique_ptr< AmendmentTablemakeTable (test::jtx::Env &env, std::chrono::seconds majorityTime)
 
void testConstruct ()
 
void testGet ()
 
void testBadConfig ()
 
void testEnableVeto ()
 
void testNoOnUnknown (FeatureBitset const &feat)
 
void testNoOnVetoed (FeatureBitset const &feat)
 
void testVoteEnable (FeatureBitset const &feat)
 
void testDetectMajority (FeatureBitset const &feat)
 
void testLostMajority (FeatureBitset const &feat)
 
void testChangedUNL (FeatureBitset const &feat)
 
void testValidatorFlapping (FeatureBitset const &feat)
 
void testHasUnsupported ()
 
void testFeature (FeatureBitset const &feat)
 
void run () override
 Runs the suite.
 
template<class = void>
void operator() (runner &r)
 Invokes the test using the specified runner.
 
template<class = void>
void pass ()
 Record a successful test condition.
 
template<class F , class String >
bool except (F &&f, String const &reason)
 
template<class F >
bool except (F &&f)
 
template<class E , class F , class String >
bool except (F &&f, String const &reason)
 
template<class E , class F >
bool except (F &&f)
 
template<class F , class String >
bool unexcept (F &&f, String const &reason)
 
template<class F >
bool unexcept (F &&f)
 
std::string const & arg () const
 Return the argument associated with the runner.
 
template<class Condition , class String >
bool unexpected (Condition shouldBeFalse, String const &reason)
 
template<class Condition >
bool unexpected (Condition shouldBeFalse)
 
template<class String >
void fail (String const &reason, char const *file, int line)
 Record a failure.
 
template<class = void>
void fail (std::string const &reason="")
 
template<class Condition >
bool expect (Condition const &shouldBeTrue)
 Evaluate a test condition.
 
template<class Condition , class String >
bool expect (Condition const &shouldBeTrue, String const &reason)
 
template<class Condition >
bool expect (Condition const &shouldBeTrue, char const *file, int line)
 
template<class Condition , class String >
bool expect (Condition const &shouldBeTrue, String const &reason, char const *file, int line)
 

Static Public Member Functions

static std::vector< std::pair< PublicKey, SecretKey > > makeValidators (int num, std::unique_ptr< AmendmentTable > const &table)
 
static NetClock::time_point hourTime (std::chrono::hours h)
 
static void doRound (Rules const &rules, AmendmentTable &table, std::chrono::hours hour, std::vector< std::pair< PublicKey, SecretKey > > const &validators, std::vector< std::pair< uint256, int > > const &votes, std::vector< uint256 > &ourVotes, std::set< uint256 > &enabled, majorityAmendments_t &majority)
 
static suitethis_suite ()
 Returns the "current" running suite.
 

Public Attributes

log_os< char > log
 Logging output stream.
 
testcase_t testcase
 Memberspace for declaring test cases.
 

Private Member Functions

std::unique_ptr< ConfigmakeConfig ()
 
void propagate_abort ()
 

Static Private Member Functions

static uint256 amendmentId (std::string in)
 
static Section makeSection (std::string const &name, std::vector< std::string > const &amendments)
 
static Section makeSection (std::vector< std::string > const &amendments)
 
static Section makeSection (uint256 const &amendment)
 
static std::vector< AmendmentTable::FeatureInfomakeFeatureInfo (std::vector< std::string > const &amendments, VoteBehavior voteBehavior)
 
static std::vector< AmendmentTable::FeatureInfomakeDefaultYes (std::vector< std::string > const &amendments)
 
static std::vector< AmendmentTable::FeatureInfomakeDefaultYes (uint256 const amendment)
 
static std::vector< AmendmentTable::FeatureInfomakeDefaultNo (std::vector< std::string > const &amendments)
 
static std::vector< AmendmentTable::FeatureInfomakeObsolete (std::vector< std::string > const &amendments)
 
template<class Arg , class... Args>
static size_t totalsize (std::vector< Arg > const &src, Args const &... args)
 
template<class Arg , class... Args>
static void combine_arg (std::vector< Arg > &dest, std::vector< Arg > const &src, Args const &... args)
 
template<class Arg , class... Args>
static std::vector< Arg > combine (std::vector< Arg > left, std::vector< Arg > const &right, Args const &... args)
 
static suite ** p_this_suite ()
 

Private Attributes

std::vector< std::string > const yes_ {"g", "i", "k", "m", "o", "q", "r", "s", "t", "u"}
 
std::vector< std::string > const enabled_ {"b", "d", "f", "h", "j", "l", "n", "p"}
 
std::vector< std::string > const vetoed_ {"a", "c", "e"}
 
std::vector< std::string > const obsolete_ {"0", "1", "2"}
 
std::vector< std::string > const allSupported_ {combine(yes_, enabled_, vetoed_, obsolete_)}
 
std::vector< std::string > const unsupported_ {"v", "w", "x"}
 
std::vector< std::string > const unsupportedMajority_ {"y", "z"}
 
Section const emptySection_
 
std::vector< AmendmentTable::FeatureInfo > const emptyYes_
 
test::SuiteJournal journal_
 
bool abort_ = false
 
bool aborted_ = false
 
runner * runner_ = nullptr
 

Detailed Description

Definition at line 21 of file AmendmentTable_test.cpp.

Constructor & Destructor Documentation

◆ AmendmentTable_test()

xrpl::AmendmentTable_test::AmendmentTable_test ( )

Definition at line 159 of file AmendmentTable_test.cpp.

Member Function Documentation

◆ amendmentId()

static uint256 xrpl::AmendmentTable_test::amendmentId ( std::string  in)
staticprivate

Definition at line 25 of file AmendmentTable_test.cpp.

◆ makeSection() [1/3]

static Section xrpl::AmendmentTable_test::makeSection ( std::string const &  name,
std::vector< std::string > const &  amendments 
)
staticprivate

Definition at line 37 of file AmendmentTable_test.cpp.

◆ makeSection() [2/3]

static Section xrpl::AmendmentTable_test::makeSection ( std::vector< std::string > const &  amendments)
staticprivate

Definition at line 46 of file AmendmentTable_test.cpp.

◆ makeSection() [3/3]

static Section xrpl::AmendmentTable_test::makeSection ( uint256 const &  amendment)
staticprivate

Definition at line 52 of file AmendmentTable_test.cpp.

◆ makeConfig()

std::unique_ptr< Config > xrpl::AmendmentTable_test::makeConfig ( )
private

Definition at line 60 of file AmendmentTable_test.cpp.

◆ makeFeatureInfo()

static std::vector< AmendmentTable::FeatureInfo > xrpl::AmendmentTable_test::makeFeatureInfo ( std::vector< std::string > const &  amendments,
VoteBehavior  voteBehavior 
)
staticprivate

Definition at line 69 of file AmendmentTable_test.cpp.

◆ makeDefaultYes() [1/2]

static std::vector< AmendmentTable::FeatureInfo > xrpl::AmendmentTable_test::makeDefaultYes ( std::vector< std::string > const &  amendments)
staticprivate

Definition at line 81 of file AmendmentTable_test.cpp.

◆ makeDefaultYes() [2/2]

static std::vector< AmendmentTable::FeatureInfo > xrpl::AmendmentTable_test::makeDefaultYes ( uint256 const  amendment)
staticprivate

Definition at line 87 of file AmendmentTable_test.cpp.

◆ makeDefaultNo()

static std::vector< AmendmentTable::FeatureInfo > xrpl::AmendmentTable_test::makeDefaultNo ( std::vector< std::string > const &  amendments)
staticprivate

Definition at line 95 of file AmendmentTable_test.cpp.

◆ makeObsolete()

static std::vector< AmendmentTable::FeatureInfo > xrpl::AmendmentTable_test::makeObsolete ( std::vector< std::string > const &  amendments)
staticprivate

Definition at line 101 of file AmendmentTable_test.cpp.

◆ totalsize()

template<class Arg , class... Args>
static size_t xrpl::AmendmentTable_test::totalsize ( std::vector< Arg > const &  src,
Args const &...  args 
)
staticprivate

Definition at line 108 of file AmendmentTable_test.cpp.

◆ combine_arg()

template<class Arg , class... Args>
static void xrpl::AmendmentTable_test::combine_arg ( std::vector< Arg > &  dest,
std::vector< Arg > const &  src,
Args const &...  args 
)
staticprivate

Definition at line 117 of file AmendmentTable_test.cpp.

◆ combine()

template<class Arg , class... Args>
static std::vector< Arg > xrpl::AmendmentTable_test::combine ( std::vector< Arg >  left,
std::vector< Arg > const &  right,
Args const &...  args 
)
staticprivate

Definition at line 127 of file AmendmentTable_test.cpp.

◆ makeTable() [1/3]

std::unique_ptr< AmendmentTable > xrpl::AmendmentTable_test::makeTable ( Application app,
std::chrono::seconds  majorityTime,
std::vector< AmendmentTable::FeatureInfo > const &  supported,
Section const &  enabled,
Section const &  vetoed 
)

Definition at line 164 of file AmendmentTable_test.cpp.

◆ makeTable() [2/3]

std::unique_ptr< AmendmentTable > xrpl::AmendmentTable_test::makeTable ( test::jtx::Env env,
std::chrono::seconds  majorityTime,
std::vector< AmendmentTable::FeatureInfo > const &  supported,
Section const &  enabled,
Section const &  vetoed 
)

Definition at line 175 of file AmendmentTable_test.cpp.

◆ makeTable() [3/3]

std::unique_ptr< AmendmentTable > xrpl::AmendmentTable_test::makeTable ( test::jtx::Env env,
std::chrono::seconds  majorityTime 
)

Definition at line 186 of file AmendmentTable_test.cpp.

◆ testConstruct()

void xrpl::AmendmentTable_test::testConstruct ( )

Definition at line 202 of file AmendmentTable_test.cpp.

◆ testGet()

void xrpl::AmendmentTable_test::testGet ( )

Definition at line 231 of file AmendmentTable_test.cpp.

◆ testBadConfig()

void xrpl::AmendmentTable_test::testBadConfig ( )

Definition at line 270 of file AmendmentTable_test.cpp.

◆ testEnableVeto()

void xrpl::AmendmentTable_test::testEnableVeto ( )

Definition at line 370 of file AmendmentTable_test.cpp.

◆ makeValidators()

static std::vector< std::pair< PublicKey, SecretKey > > xrpl::AmendmentTable_test::makeValidators ( int  num,
std::unique_ptr< AmendmentTable > const &  table 
)
static

Definition at line 443 of file AmendmentTable_test.cpp.

◆ hourTime()

static NetClock::time_point xrpl::AmendmentTable_test::hourTime ( std::chrono::hours  h)
static

Definition at line 459 of file AmendmentTable_test.cpp.

◆ doRound()

static void xrpl::AmendmentTable_test::doRound ( Rules const &  rules,
AmendmentTable table,
std::chrono::hours  hour,
std::vector< std::pair< PublicKey, SecretKey > > const &  validators,
std::vector< std::pair< uint256, int > > const &  votes,
std::vector< uint256 > &  ourVotes,
std::set< uint256 > &  enabled,
majorityAmendments_t majority 
)
static

Definition at line 466 of file AmendmentTable_test.cpp.

◆ testNoOnUnknown()

void xrpl::AmendmentTable_test::testNoOnUnknown ( FeatureBitset const &  feat)

Definition at line 557 of file AmendmentTable_test.cpp.

◆ testNoOnVetoed()

void xrpl::AmendmentTable_test::testNoOnVetoed ( FeatureBitset const &  feat)

Definition at line 635 of file AmendmentTable_test.cpp.

◆ testVoteEnable()

void xrpl::AmendmentTable_test::testVoteEnable ( FeatureBitset const &  feat)

Definition at line 695 of file AmendmentTable_test.cpp.

◆ testDetectMajority()

void xrpl::AmendmentTable_test::testDetectMajority ( FeatureBitset const &  feat)

Definition at line 774 of file AmendmentTable_test.cpp.

◆ testLostMajority()

void xrpl::AmendmentTable_test::testLostMajority ( FeatureBitset const &  feat)

Definition at line 839 of file AmendmentTable_test.cpp.

◆ testChangedUNL()

void xrpl::AmendmentTable_test::testChangedUNL ( FeatureBitset const &  feat)

Definition at line 912 of file AmendmentTable_test.cpp.

◆ testValidatorFlapping()

void xrpl::AmendmentTable_test::testValidatorFlapping ( FeatureBitset const &  feat)

Definition at line 1060 of file AmendmentTable_test.cpp.

◆ testHasUnsupported()

void xrpl::AmendmentTable_test::testHasUnsupported ( )

Definition at line 1141 of file AmendmentTable_test.cpp.

◆ testFeature()

void xrpl::AmendmentTable_test::testFeature ( FeatureBitset const &  feat)

Definition at line 1183 of file AmendmentTable_test.cpp.

◆ run()

void xrpl::AmendmentTable_test::run ( )
overridevirtual

Runs the suite.

Implements beast::unit_test::suite.

Definition at line 1195 of file AmendmentTable_test.cpp.

◆ this_suite()

static suite * beast::unit_test::suite::this_suite ( )
staticinherited

Returns the "current" running suite.

If no suite is running, nullptr is returned.

Definition at line 156 of file suite.h.

◆ operator()()

template<class >
void beast::unit_test::suite::operator() ( runner r)
inherited

Invokes the test using the specified runner.

Data members are set up here instead of the constructor as a convenience to writing the derived class to avoid repetition of forwarded constructor arguments to the base. Normally this is called by the framework for you.

Definition at line 389 of file suite.h.

◆ pass()

template<class >
void beast::unit_test::suite::pass ( )
inherited

Record a successful test condition.

Definition at line 497 of file suite.h.

◆ fail() [1/2]

template<class String >
void beast::unit_test::suite::fail ( String const &  reason,
char const *  file,
int  line 
)
inherited

Record a failure.

Parameters
reasonOptional text added to the output on a failure.
fileThe source code file where the test failed.
lineThe source code line number where the test failed.

Definition at line 519 of file suite.h.

◆ fail() [2/2]

template<class >
void beast::unit_test::suite::fail ( std::string const &  reason = "")
inherited

Definition at line 506 of file suite.h.

◆ expect() [1/4]

template<class Condition >
bool beast::unit_test::suite::expect ( Condition const &  shouldBeTrue)
inherited

Evaluate a test condition.

This function provides improved logging by incorporating the file name and line number into the reported output on failure, as well as additional text specified by the caller.

Parameters
shouldBeTrueThe condition to test. The condition is evaluated in a boolean context.
reasonOptional added text to output on a failure.
fileThe source code file where the test failed.
lineThe source code line number where the test failed.
Returns
true if the test condition indicates success.

Definition at line 224 of file suite.h.

◆ expect() [2/4]

template<class Condition , class String >
bool beast::unit_test::suite::expect ( Condition const &  shouldBeTrue,
String const &  reason 
)
inherited

Definition at line 406 of file suite.h.

◆ expect() [3/4]

template<class Condition >
bool beast::unit_test::suite::expect ( Condition const &  shouldBeTrue,
char const *  file,
int  line 
)
inherited

Definition at line 235 of file suite.h.

◆ expect() [4/4]

template<class Condition , class String >
bool beast::unit_test::suite::expect ( Condition const &  shouldBeTrue,
String const &  reason,
char const *  file,
int  line 
)
inherited

Definition at line 419 of file suite.h.

◆ except() [1/4]

template<class F , class String >
bool beast::unit_test::suite::except ( F &&  f,
String const &  reason 
)
inherited

Definition at line 434 of file suite.h.

◆ except() [2/4]

template<class F >
bool beast::unit_test::suite::except ( F &&  f)
inherited

Definition at line 254 of file suite.h.

◆ except() [3/4]

template<class E , class F , class String >
bool beast::unit_test::suite::except ( F &&  f,
String const &  reason 
)
inherited

Definition at line 451 of file suite.h.

◆ except() [4/4]

template<class E , class F >
bool beast::unit_test::suite::except ( F &&  f)
inherited

Definition at line 263 of file suite.h.

◆ unexcept() [1/2]

template<class F , class String >
bool beast::unit_test::suite::unexcept ( F &&  f,
String const &  reason 
)
inherited

Definition at line 468 of file suite.h.

◆ unexcept() [2/2]

template<class F >
bool beast::unit_test::suite::unexcept ( F &&  f)
inherited

Definition at line 272 of file suite.h.

◆ arg()

std::string const & beast::unit_test::suite::arg ( ) const
inherited

Return the argument associated with the runner.

Definition at line 279 of file suite.h.

◆ unexpected() [1/2]

template<class Condition , class String >
bool beast::unit_test::suite::unexpected ( Condition  shouldBeFalse,
String const &  reason 
)
inherited

Definition at line 485 of file suite.h.

◆ unexpected() [2/2]

template<class Condition >
bool beast::unit_test::suite::unexpected ( Condition  shouldBeFalse)
inherited

Definition at line 292 of file suite.h.

◆ p_this_suite()

static suite ** beast::unit_test::suite::p_this_suite ( )
staticprivateinherited

Definition at line 301 of file suite.h.

◆ propagate_abort()

void beast::unit_test::suite::propagate_abort ( )
privateinherited

Definition at line 525 of file suite.h.

Member Data Documentation

◆ yes_

std::vector<std::string> const xrpl::AmendmentTable_test::yes_ {"g", "i", "k", "m", "o", "q", "r", "s", "t", "u"}
private

Definition at line 145 of file AmendmentTable_test.cpp.

◆ enabled_

std::vector<std::string> const xrpl::AmendmentTable_test::enabled_ {"b", "d", "f", "h", "j", "l", "n", "p"}
private

Definition at line 146 of file AmendmentTable_test.cpp.

◆ vetoed_

std::vector<std::string> const xrpl::AmendmentTable_test::vetoed_ {"a", "c", "e"}
private

Definition at line 147 of file AmendmentTable_test.cpp.

◆ obsolete_

std::vector<std::string> const xrpl::AmendmentTable_test::obsolete_ {"0", "1", "2"}
private

Definition at line 148 of file AmendmentTable_test.cpp.

◆ allSupported_

std::vector<std::string> const xrpl::AmendmentTable_test::allSupported_ {combine(yes_, enabled_, vetoed_, obsolete_)}
private

Definition at line 149 of file AmendmentTable_test.cpp.

◆ unsupported_

std::vector<std::string> const xrpl::AmendmentTable_test::unsupported_ {"v", "w", "x"}
private

Definition at line 150 of file AmendmentTable_test.cpp.

◆ unsupportedMajority_

std::vector<std::string> const xrpl::AmendmentTable_test::unsupportedMajority_ {"y", "z"}
private

Definition at line 151 of file AmendmentTable_test.cpp.

◆ emptySection_

Section const xrpl::AmendmentTable_test::emptySection_
private

Definition at line 153 of file AmendmentTable_test.cpp.

◆ emptyYes_

std::vector<AmendmentTable::FeatureInfo> const xrpl::AmendmentTable_test::emptyYes_
private

Definition at line 154 of file AmendmentTable_test.cpp.

◆ journal_

test::SuiteJournal xrpl::AmendmentTable_test::journal_
private

Definition at line 156 of file AmendmentTable_test.cpp.

◆ abort_

bool beast::unit_test::suite::abort_ = false
privateinherited

Definition at line 53 of file suite.h.

◆ aborted_

bool beast::unit_test::suite::aborted_ = false
privateinherited

Definition at line 54 of file suite.h.

◆ runner_

runner* beast::unit_test::suite::runner_ = nullptr
privateinherited

Definition at line 55 of file suite.h.

◆ log

log_os<char> beast::unit_test::suite::log
inherited

Logging output stream.

Text sent to the log output stream will be forwarded to the output stream associated with the runner.

Definition at line 147 of file suite.h.

◆ testcase

testcase_t beast::unit_test::suite::testcase
inherited

Memberspace for declaring test cases.

Definition at line 150 of file suite.h.