API for improved Unit Testing (RIPD-432):

* Added new test APIs allowing easy ways to create ledgers, apply
  transactions to them, close and advance them.

* Moved Ledger tests from Ledger.cpp to Ledger.test.cpp.

* Changed several TransactionEngine log priorities from lsINFO to lsDEBUG to
  reduce unnecessary verbosity in the log messages while running these tests.

* Moved LedgerConsensus:applyTransactions from a private member function to a
  free function so that it could be accessed externally, and without having to
  reference a LedgerConsensus object.  This was done to facilitate the new
  testing API.
This commit is contained in:
Howard Hinnant
2014-11-19 14:04:36 -05:00
committed by Nik Bougalis
parent c62ccf4870
commit eafa6f960f
8 changed files with 505 additions and 210 deletions

View File

@@ -1899,43 +1899,6 @@ std::vector<uint256> Ledger::getNeededAccountStateHashes (
return ret;
}
//------------------------------------------------------------------------------
class Ledger_test : public beast::unit_test::suite
{
void test_genesis_ledger ()
{
RippleAddress rootSeedMaster
= RippleAddress::createSeedGeneric ("masterpassphrase");
RippleAddress rootGeneratorMaster
= RippleAddress::createGeneratorPublic (rootSeedMaster);
RippleAddress rootAddress
= RippleAddress::createAccountPublic (rootGeneratorMaster, 0);
std::uint64_t startAmount (100000);
Ledger::pointer ledger (std::make_shared <Ledger> (
rootAddress, startAmount));
ledger->updateHash();
expect(ledger->assertSane());
}
void test_getQuality ()
{
uint256 uBig (
"D2DC44E5DC189318DB36EF87D2104CDF0A0FE3A4B698BEEE55038D7EA4C68000");
// VFALCO NOTE This fails in the original version as well.
expect (6125895493223874560 == getQuality (uBig));
}
public:
void run ()
{
test_genesis_ledger ();
test_getQuality ();
}
};
BEAST_DEFINE_TESTSUITE(Ledger,ripple_app,ripple);
Ledger::StaticLockType Ledger::sPendingSaveLock;
std::set<std::uint32_t> Ledger::sPendingSaves;