Browse Source

FuzzTests: simple block test + NOBOOST flag

cl-refactor
Dimitry 10 years ago
parent
commit
2b16073d5b
  1. 5
      CMakeLists.txt
  2. 3
      test/TestHelper.h
  3. 23
      test/fuzzTesting/createRandomTest.cpp

5
CMakeLists.txt

@ -31,6 +31,7 @@ option(FATDB "Build with ability to list entries in the Trie. Doubles DB size, s
option(USENPM "Use npm to recompile ethereum.js if it was changed" OFF)
option(PROFILING "Build in support for profiling" OFF)
set(BUNDLE "none" CACHE STRING "Predefined bundle of software to build (none, full, user, tests, minimal).")
option(MINER "Build the CLI miner component" ON)
option(ETHKEY "Build the CLI key manager component" ON)
@ -40,6 +41,7 @@ option(TOOLS "Build the tools components" ON)
option(NCURSES "Build the NCurses components" OFF)
option(GUI "Build GUI components (AlethZero, Mix)" ON)
option(TESTS "Build the tests." ON)
option(NOBOOST "No use of boost macros in test functions" OFF)
option(EVMJIT "Build just-in-time compiler for EVM code (requires LLVM)" OFF)
option(ETHASHCL "Build in support for GPU mining via OpenCL" OFF)
option(JSCONSOLE "Build in javascript console" OFF)
@ -82,6 +84,7 @@ function(configureProject)
add_definitions(-DETH_CURL)
endif()
add_definitions(-DNOBOOST)
add_definitions(-DETH_TRUE)
endfunction()
@ -195,6 +198,7 @@ eth_format_option(PROFILING)
eth_format_option(SOLIDITY)
eth_format_option(GUI)
eth_format_option(TESTS)
eth_format_option(NOBOOST)
eth_format_option(TOOLS)
eth_format_option(ETHASHCL)
eth_format_option(JSCONSOLE)
@ -316,6 +320,7 @@ message("-- SERPENT Build Serpent language components ${SERPENT}
message("-- GUI Build GUI components ${GUI}")
message("-- NCURSES Build NCurses components ${NCURSES}")
message("-- TESTS Build tests ${TESTS}")
message("-- NOBOOST No BOOST macros in test functions ${NOBOOST}")
message("-- ETHASHCL Build OpenCL components (experimental!) ${ETHASHCL}")
message("-- JSCONSOLE Build with javascript console ${JSCONSOLE}")
message("-- EVMJIT Build LLVM-based JIT EVM (experimental!) ${EVMJIT}")

3
test/TestHelper.h

@ -31,8 +31,7 @@
#include <libevm/ExtVMFace.h>
#include <libtestutils/Common.h>
#define DONTUSE_BOOST_MACROS
#ifdef DONTUSE_BOOST_MACROS
#ifdef NOBOOST
#define TBOOST_THROW_EXCEPTION(arg) throw dev::Exception();
#define TBOOST_REQUIRE(arg) if(arg == false) throw dev::Exception();
#define TBOOST_REQUIRE_EQUAL(arg1, arg2) if(arg1 != arg2) throw dev::Exception();

23
test/fuzzTesting/createRandomTest.cpp

@ -154,17 +154,16 @@ int checkRandomTest(std::function<void(json_spirit::mValue&, bool)> doTests, jso
void fillRandomTest(std::function<void(json_spirit::mValue&, bool)> doTests, std::string const& testString)
{
//redirect all output to the stream
//std::ostringstream strCout;
//std::streambuf* oldCoutStreamBuf = std::cout.rdbuf();
//std::cout.rdbuf( strCout.rdbuf() );
//std::cerr.rdbuf( strCout.rdbuf() );
std::ostringstream strCout;
std::streambuf* oldCoutStreamBuf = std::cout.rdbuf();
std::cout.rdbuf( strCout.rdbuf() );
std::cerr.rdbuf( strCout.rdbuf() );
json_spirit::mValue v;
try
{
std::string newTest = testString;
parseTestWithTypes(newTest);
std::cout << newTest;
json_spirit::read_string(newTest, v);
doTests(v, true);
}
@ -174,8 +173,8 @@ void fillRandomTest(std::function<void(json_spirit::mValue&, bool)> doTests, std
}
//restroe output
//std::cout.rdbuf(oldCoutStreamBuf);
//std::cerr.rdbuf(oldCoutStreamBuf);
std::cout.rdbuf(oldCoutStreamBuf);
std::cerr.rdbuf(oldCoutStreamBuf);
std::cout << json_spirit::write_string(v, true);
}
@ -246,7 +245,7 @@ std::vector<std::string> getTypes()
std::string const c_testExampleTransactionTest = R"(
{
"TransactionTest" : {
"randomTransactionTest" : {
"transaction" :
{
"data" : "[CODE]",
@ -344,7 +343,7 @@ std::string const c_testExampleVMTest = R"(
std::string const c_testExampleBlockchainTest = R"(
{
"blockTest" : {
"randomBlockTest" : {
"genesisBlockHeader" : {
"bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"coinbase" : "[HASH20]",
@ -359,8 +358,8 @@ std::string const c_testExampleBlockchainTest = R"(
"receiptTrie" : "[0xHASH32]",
"stateRoot" : "[0xHASH32]",
"timestamp" : "[HEX]",
"transactionsTrie" : "[0xHASH32]",
"uncleHash" : "[0xHASH32]"
"transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
},
"pre" : {
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
@ -371,7 +370,7 @@ std::string const c_testExampleBlockchainTest = R"(
},
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "[HEX]",
"nonce" : "[HEX]",
"nonce" : "0",
"code" : "[CODE]",
"storage": {}
}

Loading…
Cancel
Save