Fabcoin Core  0.16.2
P2P Digital Currency
Classes | Namespaces | Macros | Functions | Variables
TestHelper.h File Reference

Helper functions to work with json::spirit and test files. More...

#include <thread>
#include <future>
#include <functional>
#include <boost/test/unit_test.hpp>
#include <boost/filesystem.hpp>
#include <boost/progress.hpp>
#include <libethashseal/Ethash.h>
#include <libethereum/State.h>
#include <libethashseal/GenesisInfo.h>
#include <libevm/ExtVMFace.h>
#include <test/libtestutils/Common.h>
#include <test/libtesteth/JsonSpiritHeaders.h>
#include <test/libtesteth/Options.h>
#include <test/libtesteth/ImportTest.h>
#include <test/libtesteth/TestOutputHelper.h>
Include dependency graph for TestHelper.h:

Go to the source code of this file.

Classes

struct  dev::test::ValueTooLarge
 
struct  dev::test::MissingFields
 
class  dev::test::ZeroGasPricer
 
class  dev::test::Listener
 Allows observing test execution process. More...
 
class  dev::test::Listener::ExecTimeGuard
 Test started/finished notification RAII helper. More...
 

Namespaces

 dev
 Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Originally by RenĂ© Nyffenegger.
 
 dev::eth
 
 dev::test
 

Macros

#define ETH_TEST_REQUIRE_NO_THROW(_statement, _message)
 Make sure that no Exception is thrown during testing. More...
 
#define ETH_TEST_CHECK_NO_THROW(_statement, _message)
 Check if an Exception is thrown during testing. More...
 

Functions

void dev::eth::mine (Client &c, int numBlocks)
 
void dev::eth::connectClients (Client &c1, Client &c2)
 
void dev::eth::mine (Block &s, BlockChain const &_bc, SealEngineFace *_sealer)
 
void dev::eth::mine (BlockHeader &_bi, SealEngineFace *_sealer, bool _verify)
 
string dev::test::netIdToString (eth::Network _netId)
 
eth::Network dev::test::stringToNetId (std::string const &_netname)
 
u256 dev::test::toInt (json_spirit::mValue const &_v)
 
byte dev::test::toByte (json_spirit::mValue const &_v)
 
void dev::test::replaceLLLinState (json_spirit::mObject &_o)
 
std::string dev::test::compileLLL (std::string const &_code)
 
bytes dev::test::importCode (json_spirit::mObject &_o)
 
bytes dev::test::importData (json_spirit::mObject const &_o)
 
bytes dev::test::importByteArray (std::string const &_str)
 
void dev::test::copyFile (std::string const &_source, std::string const &_destination)
 
LogEntries dev::test::importLog (json_spirit::mArray &_a)
 
json_spirit::mArray dev::test::exportLog (eth::LogEntries _logs)
 
void dev::test::checkOutput (bytesConstRef _output, json_spirit::mObject &_o)
 
void dev::test::checkStorage (std::map< u256, u256 > _expectedStore, std::map< u256, u256 > _resultStore, Address _expectedAddr)
 
void dev::test::checkLog (LogEntries _resultLogs, LogEntries _expectedLogs)
 
void dev::test::checkCallCreates (eth::Transactions _resultCallCreates, eth::Transactions _expectedCallCreates)
 
dev::eth::BlockHeader dev::test::constructHeader (h256 const &_parentHash, h256 const &_sha3Uncles, Address const &_author, h256 const &_stateRoot, h256 const &_transactionsRoot, h256 const &_receiptsRoot, dev::eth::LogBloom const &_logBloom, u256 const &_difficulty, u256 const &_number, u256 const &_gasLimit, u256 const &_gasUsed, u256 const &_timestamp, bytes const &_extraData)
 
void dev::test::updateEthashSeal (dev::eth::BlockHeader &_header, h256 const &_mixHash, h64 const &_nonce)
 
void dev::test::executeTests (const std::string &_name, const std::string &_testPathAppendix, const std::string &_fillerPathAppendix, std::function< void(json_spirit::mValue &, bool)> doTests, bool _addFillerSuffix=true)
 
void dev::test::userDefinedTest (std::function< void(json_spirit::mValue &, bool)> doTests)
 
RLPStream dev::test::createRLPStreamFromTransactionFields (json_spirit::mObject const &_tObj)
 
LastHashes dev::test::lastHashes (u256 _currentBlockNumber)
 
json_spirit::mObject dev::test::fillJsonWithState (State const &_state)
 
json_spirit::mObject dev::test::fillJsonWithState (State const &_state, eth::AccountMaskMap const &_map)
 
json_spirit::mObject dev::test::fillJsonWithTransaction (Transaction const &_txn)
 
int dev::test::createRandomTest (std::vector< char * > const &_parameters)
 
void dev::test::doTransactionTests (json_spirit::mValue &_v, bool _fillin)
 
void dev::test::doStateTests (json_spirit::mValue &_v, bool _fillin)
 
void dev::test::doVMTests (json_spirit::mValue &_v, bool _fillin)
 
void dev::test::doBlockchainTests (json_spirit::mValue &_v, bool _fillin)
 
void dev::test::doRlpTests (json_spirit::mValue &v, bool _fillin)
 

Variables

bigint const dev::test::c_max256plus1 = bigint(1) << 256
 

Detailed Description

Helper functions to work with json::spirit and test files.

Definition in file TestHelper.h.

Macro Definition Documentation

#define ETH_TEST_CHECK_NO_THROW (   _statement,
  _message 
)
Value:
do \
{ \
try \
{ \
BOOST_TEST_PASSPOINT(); \
_statement; \
} \
catch (boost::exception const& _e) \
{ \
auto msg = std::string(_message " due to an exception thrown by " \
BOOST_STRINGIZE(_statement) "\n") + boost::diagnostic_information(_e); \
BOOST_CHECK_IMPL(false, msg, CHECK, CHECK_MSG); \
} \
catch (...) \
{ \
BOOST_CHECK_IMPL(false, "Unknown exception thrown by " \
BOOST_STRINGIZE(_statement), CHECK, CHECK_MSG ); \
} \
} \
while (0)
#define CHECK(expr)
Definition: Utils.h:12

Check if an Exception is thrown during testing.

If one is thrown show its info and continue the test Our version of BOOST_CHECK_NO_THROW()

Parameters
_statementThe statement for which to make sure no exceptions are thrown
_messageA message to act as a prefix to the expression's error information

Definition at line 93 of file TestHelper.h.

#define ETH_TEST_REQUIRE_NO_THROW (   _statement,
  _message 
)
Value:
do \
{ \
try \
{ \
BOOST_TEST_PASSPOINT(); \
_statement; \
} \
catch (boost::exception const& _e) \
{ \
auto msg = std::string(_message " due to an exception thrown by " \
BOOST_STRINGIZE(_statement) "\n") + boost::diagnostic_information(_e); \
BOOST_CHECK_IMPL(false, msg, REQUIRE, CHECK_MSG); \
} \
catch (...) \
{ \
BOOST_CHECK_IMPL(false, "Unknown exception thrown by " \
BOOST_STRINGIZE(_statement), REQUIRE, CHECK_MSG); \
} \
} \
while (0)

Make sure that no Exception is thrown during testing.

If one is thrown show its info and fail the test. Our version of BOOST_REQUIRE_NO_THROW()

Parameters
_statenentThe statement for which to make sure no exceptions are thrown
_messageA message to act as a prefix to the expression's error information

Definition at line 67 of file TestHelper.h.