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
ripple::AmendmentTable_test Class Referencefinal
Inheritance diagram for ripple::AmendmentTable_test:
Inheritance graph
[legend]
Collaboration diagram for ripple::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 ()
 
std::vector< std::pair< PublicKey, SecretKey > > makeValidators (int num, std::unique_ptr< AmendmentTable > const &table)
 
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)
 
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 NetClock::time_point hourTime (std::chrono::hours h)
 
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_
 
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()

ripple::AmendmentTable_test::AmendmentTable_test ( )

Definition at line 171 of file AmendmentTable_test.cpp.

Member Function Documentation

◆ amendmentId()

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

Definition at line 25 of file AmendmentTable_test.cpp.

◆ makeSection() [1/3]

static Section ripple::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 ripple::AmendmentTable_test::makeSection ( std::vector< std::string > const &  amendments)
staticprivate

Definition at line 48 of file AmendmentTable_test.cpp.

◆ makeSection() [3/3]

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

Definition at line 54 of file AmendmentTable_test.cpp.

◆ makeConfig()

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

Definition at line 62 of file AmendmentTable_test.cpp.

◆ makeFeatureInfo()

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

Definition at line 73 of file AmendmentTable_test.cpp.

◆ makeDefaultYes() [1/2]

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

Definition at line 87 of file AmendmentTable_test.cpp.

◆ makeDefaultYes() [2/2]

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

Definition at line 93 of file AmendmentTable_test.cpp.

◆ makeDefaultNo()

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

Definition at line 101 of file AmendmentTable_test.cpp.

◆ makeObsolete()

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

Definition at line 107 of file AmendmentTable_test.cpp.

◆ totalsize()

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

Definition at line 114 of file AmendmentTable_test.cpp.

◆ combine_arg()

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

Definition at line 123 of file AmendmentTable_test.cpp.

◆ combine()

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

Definition at line 136 of file AmendmentTable_test.cpp.

◆ makeTable() [1/3]

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

Definition at line 176 of file AmendmentTable_test.cpp.

◆ makeTable() [2/3]

std::unique_ptr< AmendmentTable > ripple::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 188 of file AmendmentTable_test.cpp.

◆ makeTable() [3/3]

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

Definition at line 199 of file AmendmentTable_test.cpp.

◆ testConstruct()

void ripple::AmendmentTable_test::testConstruct ( )

Definition at line 220 of file AmendmentTable_test.cpp.

◆ testGet()

void ripple::AmendmentTable_test::testGet ( )

Definition at line 249 of file AmendmentTable_test.cpp.

◆ testBadConfig()

void ripple::AmendmentTable_test::testBadConfig ( )

Definition at line 288 of file AmendmentTable_test.cpp.

◆ testEnableVeto()

void ripple::AmendmentTable_test::testEnableVeto ( )

Definition at line 394 of file AmendmentTable_test.cpp.

◆ makeValidators()

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

Definition at line 470 of file AmendmentTable_test.cpp.

◆ hourTime()

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

Definition at line 487 of file AmendmentTable_test.cpp.

◆ doRound()

void ripple::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 
)

Definition at line 494 of file AmendmentTable_test.cpp.

◆ testNoOnUnknown()

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

Definition at line 593 of file AmendmentTable_test.cpp.

◆ testNoOnVetoed()

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

Definition at line 672 of file AmendmentTable_test.cpp.

◆ testVoteEnable()

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

Definition at line 737 of file AmendmentTable_test.cpp.

◆ testDetectMajority()

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

Definition at line 817 of file AmendmentTable_test.cpp.

◆ testLostMajority()

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

Definition at line 886 of file AmendmentTable_test.cpp.

◆ testChangedUNL()

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

Definition at line 963 of file AmendmentTable_test.cpp.

◆ testValidatorFlapping()

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

Definition at line 1120 of file AmendmentTable_test.cpp.

◆ testHasUnsupported()

void ripple::AmendmentTable_test::testHasUnsupported ( )

Definition at line 1206 of file AmendmentTable_test.cpp.

◆ testFeature()

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

Definition at line 1249 of file AmendmentTable_test.cpp.

◆ run()

void ripple::AmendmentTable_test::run ( )
overridevirtual

Runs the suite.

Implements beast::unit_test::suite.

Definition at line 1261 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 158 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 396 of file suite.h.

◆ pass()

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

Record a successful test condition.

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

◆ fail() [2/2]

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

Definition at line 517 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 226 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 413 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 237 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 426 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 445 of file suite.h.

◆ except() [2/4]

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

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

◆ except() [4/4]

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

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

◆ unexcept() [2/2]

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

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

◆ unexpected() [2/2]

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

Definition at line 298 of file suite.h.

◆ p_this_suite()

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

Definition at line 307 of file suite.h.

◆ propagate_abort()

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

Definition at line 536 of file suite.h.

Member Data Documentation

◆ yes_

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

Definition at line 155 of file AmendmentTable_test.cpp.

◆ enabled_

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

Definition at line 157 of file AmendmentTable_test.cpp.

◆ vetoed_

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

Definition at line 158 of file AmendmentTable_test.cpp.

◆ obsolete_

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

Definition at line 159 of file AmendmentTable_test.cpp.

◆ allSupported_

std::vector<std::string> const ripple::AmendmentTable_test::allSupported_
private
Initial value:
{
std::vector< std::string > const obsolete_
std::vector< std::string > const enabled_
std::vector< std::string > const vetoed_
static std::vector< Arg > combine(std::vector< Arg > left, std::vector< Arg > const &right, Args const &... args)
std::vector< std::string > const yes_

Definition at line 160 of file AmendmentTable_test.cpp.

◆ unsupported_

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

Definition at line 162 of file AmendmentTable_test.cpp.

◆ unsupportedMajority_

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

Definition at line 163 of file AmendmentTable_test.cpp.

◆ emptySection_

Section const ripple::AmendmentTable_test::emptySection_
private

Definition at line 165 of file AmendmentTable_test.cpp.

◆ emptyYes_

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

Definition at line 166 of file AmendmentTable_test.cpp.

◆ journal_

test::SuiteJournal ripple::AmendmentTable_test::journal_
private

Definition at line 168 of file AmendmentTable_test.cpp.

◆ abort_

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

Definition at line 54 of file suite.h.

◆ aborted_

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

Definition at line 55 of file suite.h.

◆ runner_

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

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

◆ testcase

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

Memberspace for declaring test cases.

Definition at line 152 of file suite.h.