xrpld
Loading...
Searching...
No Matches
xrpl::AmendmentTable_test Class Referencefinal
Inheritance diagram for xrpl::AmendmentTable_test:
Collaboration diagram for xrpl::AmendmentTable_test:

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 SuitethisSuite ()
 Returns the "current" running suite.

Public Attributes

LogOs< char > log
 Logging output stream.
TestcaseT testcase
 Memberspace for declaring test cases.

Private Member Functions

std::unique_ptr< ConfigmakeConfig ()
void propagateAbort () const

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 combineArg (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 ** pThisSuite ()

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 44 of file AmendmentTable_test.cpp.

Constructor & Destructor Documentation

◆ AmendmentTable_test()

xrpl::AmendmentTable_test::AmendmentTable_test ( )

Definition at line 182 of file AmendmentTable_test.cpp.

Member Function Documentation

◆ amendmentId()

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

Definition at line 48 of file AmendmentTable_test.cpp.

◆ makeSection() [1/3]

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

Definition at line 60 of file AmendmentTable_test.cpp.

◆ makeSection() [2/3]

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

Definition at line 69 of file AmendmentTable_test.cpp.

◆ makeSection() [3/3]

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

Definition at line 75 of file AmendmentTable_test.cpp.

◆ makeConfig()

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

Definition at line 83 of file AmendmentTable_test.cpp.

◆ makeFeatureInfo()

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

Definition at line 92 of file AmendmentTable_test.cpp.

◆ makeDefaultYes() [1/2]

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

Definition at line 104 of file AmendmentTable_test.cpp.

◆ makeDefaultYes() [2/2]

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

Definition at line 110 of file AmendmentTable_test.cpp.

◆ makeDefaultNo()

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

Definition at line 118 of file AmendmentTable_test.cpp.

◆ makeObsolete()

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

Definition at line 124 of file AmendmentTable_test.cpp.

◆ totalsize()

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

Definition at line 131 of file AmendmentTable_test.cpp.

◆ combineArg()

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

Definition at line 140 of file AmendmentTable_test.cpp.

◆ combine()

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

Definition at line 150 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 187 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 198 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 209 of file AmendmentTable_test.cpp.

◆ testConstruct()

void xrpl::AmendmentTable_test::testConstruct ( )

Definition at line 225 of file AmendmentTable_test.cpp.

◆ testGet()

void xrpl::AmendmentTable_test::testGet ( )

Definition at line 254 of file AmendmentTable_test.cpp.

◆ testBadConfig()

void xrpl::AmendmentTable_test::testBadConfig ( )

Definition at line 293 of file AmendmentTable_test.cpp.

◆ testEnableVeto()

void xrpl::AmendmentTable_test::testEnableVeto ( )

Definition at line 393 of file AmendmentTable_test.cpp.

◆ makeValidators()

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

Definition at line 466 of file AmendmentTable_test.cpp.

◆ hourTime()

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

Definition at line 482 of file AmendmentTable_test.cpp.

◆ doRound()

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 489 of file AmendmentTable_test.cpp.

◆ testNoOnUnknown()

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

Definition at line 580 of file AmendmentTable_test.cpp.

◆ testNoOnVetoed()

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

Definition at line 658 of file AmendmentTable_test.cpp.

◆ testVoteEnable()

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

Definition at line 718 of file AmendmentTable_test.cpp.

◆ testDetectMajority()

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

Definition at line 797 of file AmendmentTable_test.cpp.

◆ testLostMajority()

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

Definition at line 862 of file AmendmentTable_test.cpp.

◆ testChangedUNL()

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

Definition at line 935 of file AmendmentTable_test.cpp.

◆ testValidatorFlapping()

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

Definition at line 1082 of file AmendmentTable_test.cpp.

◆ testHasUnsupported()

void xrpl::AmendmentTable_test::testHasUnsupported ( )

Definition at line 1163 of file AmendmentTable_test.cpp.

◆ testFeature()

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

Definition at line 1201 of file AmendmentTable_test.cpp.

◆ run()

void xrpl::AmendmentTable_test::run ( )
overridevirtual

Runs the suite.

Implements beast::unit_test::Suite.

Definition at line 1213 of file AmendmentTable_test.cpp.

◆ thisSuite()

Suite * beast::unit_test::Suite::thisSuite ( )
staticinherited

Returns the "current" running suite.

If no suite is running, nullptr is returned.

Definition at line 155 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 388 of file suite.h.

◆ pass()

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

Record a successful test condition.

Definition at line 500 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 522 of file suite.h.

◆ fail() [2/2]

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

Definition at line 509 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 223 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 405 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 234 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 418 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 433 of file suite.h.

◆ except() [2/4]

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

Definition at line 253 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 450 of file suite.h.

◆ except() [4/4]

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

Definition at line 262 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 467 of file suite.h.

◆ unexcept() [2/2]

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

Definition at line 271 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 278 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 484 of file suite.h.

◆ unexpected() [2/2]

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

Definition at line 291 of file suite.h.

◆ pThisSuite()

Suite ** beast::unit_test::Suite::pThisSuite ( )
staticprivateinherited

Definition at line 300 of file suite.h.

◆ propagateAbort()

void beast::unit_test::Suite::propagateAbort ( ) const
privateinherited

Definition at line 528 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 168 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 169 of file AmendmentTable_test.cpp.

◆ vetoed_

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

Definition at line 170 of file AmendmentTable_test.cpp.

◆ obsolete_

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

Definition at line 171 of file AmendmentTable_test.cpp.

◆ allSupported_

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

Definition at line 172 of file AmendmentTable_test.cpp.

◆ unsupported_

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

Definition at line 173 of file AmendmentTable_test.cpp.

◆ unsupportedMajority_

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

Definition at line 174 of file AmendmentTable_test.cpp.

◆ emptySection_

Section const xrpl::AmendmentTable_test::emptySection_
private

Definition at line 176 of file AmendmentTable_test.cpp.

◆ emptyYes_

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

Definition at line 177 of file AmendmentTable_test.cpp.

◆ journal_

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

Definition at line 179 of file AmendmentTable_test.cpp.

◆ abort_

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

Definition at line 52 of file suite.h.

◆ aborted_

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

Definition at line 53 of file suite.h.

◆ runner_

Runner* beast::unit_test::Suite::runner_ = nullptr
privateinherited

Definition at line 54 of file suite.h.

◆ log

LogOs<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 146 of file suite.h.

◆ testcase

TestcaseT beast::unit_test::Suite::testcase
inherited

Memberspace for declaring test cases.

Definition at line 149 of file suite.h.