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

@@ -42,7 +42,7 @@ void TransactionEngine::txnWrite ()
case taaCREATE:
{
WriteLog (lsINFO, TransactionEngine) << "applyTransaction: taaCREATE: " << sleEntry->getText ();
WriteLog (lsDEBUG, TransactionEngine) << "applyTransaction: taaCREATE: " << sleEntry->getText ();
if (mLedger->writeBack (lepCREATE, sleEntry) & lepERROR)
assert (false);
@@ -51,7 +51,7 @@ void TransactionEngine::txnWrite ()
case taaMODIFY:
{
WriteLog (lsINFO, TransactionEngine) << "applyTransaction: taaMODIFY: " << sleEntry->getText ();
WriteLog (lsDEBUG, TransactionEngine) << "applyTransaction: taaMODIFY: " << sleEntry->getText ();
if (mLedger->writeBack (lepNONE, sleEntry) & lepERROR)
assert (false);
@@ -60,7 +60,7 @@ void TransactionEngine::txnWrite ()
case taaDELETE:
{
WriteLog (lsINFO, TransactionEngine) << "applyTransaction: taaDELETE: " << sleEntry->getText ();
WriteLog (lsDEBUG, TransactionEngine) << "applyTransaction: taaDELETE: " << sleEntry->getText ();
if (!mLedger->peekAccountStateMap ()->delItem (it.first))
assert (false);
@@ -117,14 +117,14 @@ TER TransactionEngine::applyTransaction (
return temUNKNOWN;
}
if (ShouldLog (lsINFO, TransactionEngine))
if (ShouldLog (lsDEBUG, TransactionEngine))
{
std::string strToken;
std::string strHuman;
transResultInfo (terResult, strToken, strHuman);
WriteLog (lsINFO, TransactionEngine) <<
WriteLog (lsDEBUG, TransactionEngine) <<
"applyTransaction: terResult=" << strToken <<
" : " << terResult <<
" : " << strHuman;