diff --git a/CMakeLists.txt b/CMakeLists.txt
index 65436eb72..5c6466b2e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -38,7 +38,6 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set(D_CMAKE_BUILD_TYPE "Release")
set(D_GUI ON)
set(D_TOOLS ON)
-set(D_TESTS ON)
set(D_FATDB ON)
set(D_ETHASHCL ON)
set(D_ETHASHCUDA OFF)
@@ -53,35 +52,24 @@ set(D_ETHSTRATUM OFF)
if (BUNDLE STREQUAL "minimal")
set(D_GUI OFF)
set(D_TOOLS ON)
- set(D_TESTS OFF)
elseif (BUNDLE STREQUAL "full")
set(D_GUI ON)
set(D_TOOLS ON)
- set(D_TESTS ON)
set(D_FATDB ON)
elseif (BUNDLE STREQUAL "cli")
set(D_GUI OFF)
set(D_TOOLS ON)
- set(D_TESTS ON)
set(D_FATDB ON)
elseif (BUNDLE STREQUAL "core")
set(D_GUI ON)
set(D_TOOLS ON)
- set(D_TESTS OFF)
- set(D_FATDB ON)
-elseif (BUNDLE STREQUAL "tests")
- set(D_GUI OFF)
- set(D_TOOLS OFF)
- set(D_TESTS ON)
set(D_FATDB ON)
elseif (BUNDLE STREQUAL "user")
set(D_GUI ON)
set(D_TOOLS ON)
- set(D_TESTS OFF)
elseif (BUNDLE STREQUAL "wallet")
set(D_GUI OFF)
set(D_TOOLS OFF)
- set(D_TESTS OFF)
set(D_MINER OFF)
set(D_ETHASHCL OFF)
set(D_FATDB OFF)
@@ -89,7 +77,6 @@ elseif (BUNDLE STREQUAL "wallet")
elseif (BUNDLE STREQUAL "miner")
set(D_GUI OFF)
set(D_TOOLS OFF)
- set(D_TESTS OFF)
set(D_MINER ON)
set(D_ETHASHCL ON)
set(D_FATDB OFF)
@@ -98,7 +85,6 @@ elseif (BUNDLE STREQUAL "miner")
elseif (BUNDLE STREQUAL "cudaminer")
set(D_GUI OFF)
set(D_TOOLS OFF)
- set(D_TESTS OFF)
set(D_MINER ON)
set(D_ETHASHCL ON)
set(D_ETHASHCUDA ON)
@@ -108,7 +94,6 @@ elseif (BUNDLE STREQUAL "cudaminer")
elseif (BUNDLE STREQUAL "release") # release builds
set(D_GUI ON)
set(D_TOOLS ON)
- set(D_TESTS OFF)
set(D_FATDB OFF)
set(D_ETHASHCL ON)
set(D_JSONRPC ON)
@@ -258,7 +243,6 @@ eth_format_option(JSONRPC)
eth_format_option(MINER)
eth_format_option(PROFILING)
eth_format_option(GUI)
-eth_format_option(TESTS)
eth_format_option(TOOLS)
eth_format_option(ETHASHCL)
eth_format_option(ETHASHCUDA)
@@ -301,7 +285,6 @@ message("------------------------------------------------------------- component
message("-- MINER Build miner ${MINER}")
message("-- TOOLS Build basic tools ${TOOLS}")
message("-- GUI Build GUI components ${GUI}")
-message("-- TESTS Build tests ${TESTS}")
message("-- ETHASHCL Build OpenCL components ${ETHASHCL}")
message("-- ETHASHCUDA Build CUDA components ${ETHASHCUDA}")
message("-- ETHSTRATUM Build Stratum components (experimental) ${ETHSTRATUM}")
@@ -322,7 +305,7 @@ createBuildInfo()
set(DB_INCLUDE_DIRS ${LEVELDB_INCLUDE_DIRS})
set(DB_LIBRARIES ${LEVELDB_LIBRARIES})
-if (TOOLS OR GUI OR TESTS)
+if (TOOLS)
set(GENERAL 1)
else ()
set(GENERAL 0)
diff --git a/ethrpctest/CMakeLists.txt b/ethrpctest/CMakeLists.txt
deleted file mode 100644
index e28b08d70..000000000
--- a/ethrpctest/CMakeLists.txt
+++ /dev/null
@@ -1,35 +0,0 @@
-cmake_policy(SET CMP0015 NEW)
-set(CMAKE_AUTOMOC OFF)
-
-aux_source_directory(. SRC_LIST)
-
-include_directories(BEFORE ${JSONCPP_INCLUDE_DIRS})
-include_directories(BEFORE ..)
-include_directories(${Boost_INCLUDE_DIRS})
-include_directories(${JSON_RPC_CPP_INCLUDE_DIRS})
-
-set(EXECUTABLE ethrpctest)
-
-file(GLOB HEADERS "*.h")
-
-add_executable(${EXECUTABLE} ${SRC_LIST} ${HEADERS})
-
-add_dependencies(${EXECUTABLE} BuildInfo.h)
-
-target_link_libraries(${EXECUTABLE} ${Boost_REGEX_LIBRARIES})
-
-if (READLINE_FOUND)
- target_link_libraries(${EXECUTABLE} ${READLINE_LIBRARIES})
-endif()
-
-target_link_libraries(${EXECUTABLE} ${Boost_FILESYSTEM_LIBRARIES})
-target_link_libraries(${EXECUTABLE} ${Boost_PROGRAM_OPTIONS_LIBRARIES})
-target_link_libraries(${EXECUTABLE} testutils)
-target_link_libraries(${EXECUTABLE} web3jsonrpc)
-
-if (DEFINED WIN32 AND NOT DEFINED CMAKE_COMPILER_IS_MINGW)
- eth_copy_dlls("${EXECUTABLE}" MHD_DLLS)
-endif()
-
-install( TARGETS ${EXECUTABLE} DESTINATION bin )
-
diff --git a/ethrpctest/CommandLineInterface.cpp b/ethrpctest/CommandLineInterface.cpp
deleted file mode 100644
index 9210add3f..000000000
--- a/ethrpctest/CommandLineInterface.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- This file is part of cpp-ethereum.
-
- cpp-ethereum is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- cpp-ethereum is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with cpp-ethereum. If not, see .
-*/
-/** @file CommandLineInterface.cpp
- * @author Marek Kotewicz
- * @date 2015
- */
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include "CommandLineInterface.h"
-#include "BuildInfo.h"
-
-using namespace std;
-using namespace dev;
-using namespace dev::eth;
-using namespace dev::test;
-namespace po = boost::program_options;
-
-bool CommandLineInterface::parseArguments(int argc, char** argv)
-{
- // Declare the supported options.
- po::options_description desc("Allowed options");
- desc.add_options()
- ("help", "Show help message and exit")
- ("json", po::value>()->required(), "input file")
- ("test", po::value>()->required(), "test case name");
-
- // All positional options should be interpreted as input files
- po::positional_options_description p;
-
- // parse the compiler arguments
- try
- {
- po::store(po::command_line_parser(argc, argv).options(desc).positional(p).allow_unregistered().run(), m_args);
-
- if (m_args.count("help"))
- {
- cout << desc;
- return false;
- }
-
- po::notify(m_args);
- }
- catch (po::error const& _exception)
- {
- cout << _exception.what() << endl;
- return false;
- }
-
- return true;
-}
-
-bool CommandLineInterface::processInput()
-{
- string infile = m_args["json"].as>()[0];
-
- auto path = boost::filesystem::path(infile);
- if (!boost::filesystem::exists(path))
- {
- cout << "Non existant input file \"" << infile << "\"" << endl;
- return false;
- }
-
- string test = m_args["test"].as>()[0];
- Json::Value j = dev::test::loadJsonFromFile(path.string());
-
- if (j[test].empty())
- {
- cout << "Non existant test case \"" << infile << "\"" << endl;
- return false;
- }
-
- if (!j[test].isObject())
- {
- cout << "Incorrect JSON file \"" << infile << "\"" << endl;
- return false;
- }
-
- m_json = j[test];
-
- return true;
-}
-
-bool g_exit = false;
-
-void sighandler(int)
-{
- g_exit = true;
-}
-
-void CommandLineInterface::actOnInput()
-{
- BlockChainLoader bcl(m_json);
- cerr << "void CommandLineInterface::actOnInput() FixedClient now accepts eth::Block!!!" << endl;
- FixedClient client(bcl.bc(), eth::Block{}/*bcl.state()*/);
- unique_ptr jsonrpcServer;
- auto server = new jsonrpc::HttpServer(8080, "", "", 2);
- jsonrpcServer.reset(new FixedWebThreeServer(*server, {}, &client));
- jsonrpcServer->StartListening();
-
- signal(SIGABRT, &sighandler);
- signal(SIGTERM, &sighandler);
- signal(SIGINT, &sighandler);
-
- while (!g_exit)
- this_thread::sleep_for(chrono::milliseconds(1000));
-}
diff --git a/ethrpctest/CommandLineInterface.h b/ethrpctest/CommandLineInterface.h
deleted file mode 100644
index b57e1df5e..000000000
--- a/ethrpctest/CommandLineInterface.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- This file is part of cpp-ethereum.
-
- cpp-ethereum is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- cpp-ethereum is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with cpp-ethereum. If not, see .
-*/
-/** CommandLineInterface.h
- * @author Marek Kotewicz
- * @date 2015
- */
-#pragma once
-
-#include
-#include
-
-class CommandLineInterface
-{
-public:
- CommandLineInterface() {}
-
- /// Parse command line arguments and return false if we should not continue
- bool parseArguments(int argc, char** argv);
- /// Parse input file and check if test exists
- bool processInput();
- /// Start FixedJsonRpcServer
- void actOnInput();
-
-private:
-
- /// Compiler arguments variable map
- boost::program_options::variables_map m_args;
-
- /// loaded json test case
- Json::Value m_json;
-};
-
diff --git a/ethrpctest/main.cpp b/ethrpctest/main.cpp
deleted file mode 100644
index 3d710dd5b..000000000
--- a/ethrpctest/main.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- This file is part of cpp-ethereum.
-
- cpp-ethereum is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- cpp-ethereum is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with cpp-ethereum. If not, see .
-*/
-/** main.cpp
- * @author Marek Kotewicz
- * @date 2015
- */
-
-#include "CommandLineInterface.h"
-
-int main(int argc, char** argv)
-{
- CommandLineInterface cli;
- if (!cli.parseArguments(argc, argv))
- return 1;
- if (!cli.processInput())
- return 1;
- cli.actOnInput();
-
- return 0;
-}
diff --git a/test/JsonSpiritHeaders.h b/json_spirit/JsonSpiritHeaders.h
similarity index 99%
rename from test/JsonSpiritHeaders.h
rename to json_spirit/JsonSpiritHeaders.h
index 2b81c8d9c..6cf1c28fc 100644
--- a/test/JsonSpiritHeaders.h
+++ b/json_spirit/JsonSpiritHeaders.h
@@ -29,4 +29,3 @@
#include "../json_spirit/json_spirit_writer_template.h"
#pragma GCC diagnostic pop
#pragma warning(pop)
-
diff --git a/libdevcrypto/SecretStore.cpp b/libdevcrypto/SecretStore.cpp
index 1b1e67e9b..8d97c44f6 100644
--- a/libdevcrypto/SecretStore.cpp
+++ b/libdevcrypto/SecretStore.cpp
@@ -28,7 +28,7 @@
#include
#include
#include
-#include
+#include
#include
using namespace std;
using namespace dev;
diff --git a/libethcore/KeyManager.cpp b/libethcore/KeyManager.cpp
index e00cb68d7..198a255ce 100644
--- a/libethcore/KeyManager.cpp
+++ b/libethcore/KeyManager.cpp
@@ -23,7 +23,7 @@
#include
#include
#include
-#include
+#include
#include
#include
#include
diff --git a/libethereum/Account.cpp b/libethereum/Account.cpp
index 727c35a47..910c3c571 100644
--- a/libethereum/Account.cpp
+++ b/libethereum/Account.cpp
@@ -21,7 +21,7 @@
#include "Account.h"
#include
-#include
+#include
#include
using namespace std;
using namespace dev;
diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp
index 8fda03a88..51d325946 100644
--- a/libethereum/BlockChain.cpp
+++ b/libethereum/BlockChain.cpp
@@ -27,7 +27,7 @@
#include
#include
-#include
+#include
#include
#include
#include
diff --git a/libethereum/CanonBlockChain.cpp b/libethereum/CanonBlockChain.cpp
index 4b4fffc55..97e163d0b 100644
--- a/libethereum/CanonBlockChain.cpp
+++ b/libethereum/CanonBlockChain.cpp
@@ -29,7 +29,7 @@
#include
#include
#include
-#include
+#include
#include "GenesisInfo.h"
#include "State.h"
#include "Defaults.h"
diff --git a/libtestutils/BlockChainLoader.cpp b/libtestutils/BlockChainLoader.cpp
deleted file mode 100644
index 80cb72b99..000000000
--- a/libtestutils/BlockChainLoader.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- This file is part of cpp-ethereum.
-
- cpp-ethereum is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- cpp-ethereum is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with cpp-ethereum. If not, see .
- */
-/** @file BlockChainLoader.cpp
- * @author Marek Kotewicz
- * @date 2015
- */
-
-#include
-#include
-#include "BlockChainLoader.h"
-#include "Common.h"
-using namespace std;
-using namespace dev;
-using namespace dev::test;
-using namespace dev::eth;
-
-BlockChainLoader::BlockChainLoader(Json::Value const& _json)
-{
- // load genesisBlock
- bytes genesisBl = fromHex(_json["genesisRLP"].asString());
-
- Json::FastWriter a;
- m_bc.reset(new FullBlockChain(genesisBl, jsonToAccountMap( a.write(_json["pre"])), m_dir.path(), WithExisting::Kill));
-
- // load pre state
- m_block = m_bc->genesisBlock(State::openDB(m_dir.path(), m_bc->genesisHash(), WithExisting::Kill));
-
- assert(m_block.rootHash() == m_bc->info().stateRoot());
-
- // load blocks
- for (auto const& block: _json["blocks"])
- {
- bytes rlp = fromHex(block["rlp"].asString());
- m_bc->import(rlp, state().db());
- }
-
- // sync state
- m_block.sync(*m_bc);
-}
diff --git a/libtestutils/BlockChainLoader.h b/libtestutils/BlockChainLoader.h
deleted file mode 100644
index a29b941b7..000000000
--- a/libtestutils/BlockChainLoader.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- This file is part of cpp-ethereum.
-
- cpp-ethereum is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- cpp-ethereum is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with cpp-ethereum. If not, see .
- */
-/** @file BlockChainLoader.h
- * @author Marek Kotewicz
- * @date 2015
- */
-
-#pragma once
-#include
-#include
-#include
-#include
-#include
-
-namespace dev
-{
-namespace test
-{
-
-/**
- * @brief Should be used to load test blockchain from json file
- * Loads the blockchain from json, creates temporary directory to store it, removes the directory on dealloc
- */
-class BlockChainLoader
-{
-public:
- BlockChainLoader(Json::Value const& _json);
- eth::BlockChain const& bc() const { return *m_bc; }
- eth::State const& state() const { return m_block.state(); } // TODO remove?
- eth::Block const& block() const { return m_block; }
-
-private:
- TransientDirectory m_dir;
- std::unique_ptr m_bc;
- eth::Block m_block;
-};
-
-}
-}
diff --git a/libtestutils/CMakeLists.txt b/libtestutils/CMakeLists.txt
deleted file mode 100644
index e2bac80cf..000000000
--- a/libtestutils/CMakeLists.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-cmake_policy(SET CMP0015 NEW)
-set(CMAKE_AUTOMOC OFF)
-
-aux_source_directory(. SRC_LIST)
-
-include_directories(BEFORE ${JSONCPP_INCLUDE_DIRS})
-include_directories(BEFORE ..)
-include_directories(${JSON_RPC_CPP_INCLUDE_DIRS})
-include_directories(${Boost_INCLUDE_DIRS})
-
-set(EXECUTABLE testutils)
-
-file(GLOB HEADERS "*.h")
-
-if (NOT JSONRPC)
- list(REMOVE_ITEM SRC_LIST "./FixedWebThreeServer.cpp")
- list(REMOVE_ITEM HEADERS "./FixedWebThreeServer.h")
-endif()
-
-add_library(${EXECUTABLE} ${SRC_LIST} ${HEADERS})
-
-target_link_libraries(${EXECUTABLE} ${Boost_FILESYSTEM_LIBRARIES})
-target_link_libraries(${EXECUTABLE} ${JSONCPP_LIBRARIES})
-target_link_libraries(${EXECUTABLE} ethereum)
-
-if (JSONRPC)
- target_link_libraries(${EXECUTABLE} web3jsonrpc)
-endif()
-
-install( TARGETS ${EXECUTABLE} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib )
-install( FILES ${HEADERS} DESTINATION include/${EXECUTABLE} )
-
diff --git a/libtestutils/Common.cpp b/libtestutils/Common.cpp
deleted file mode 100644
index 8f23685c1..000000000
--- a/libtestutils/Common.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- This file is part of cpp-ethereum.
-
- cpp-ethereum is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- cpp-ethereum is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with cpp-ethereum. If not, see .
- */
-/** @file Common.cpp
- * @author Marek Kotewicz
- * @date 2015
- */
-
-#include
-#include
-#include
-#include
-#include
-#include "Common.h"
-
-using namespace std;
-using namespace dev;
-using namespace dev::test;
-
-const char* TestChannel::name() { return "TST"; }
-
-std::string dev::test::getTestPath()
-{
- string testPath;
- const char* ptestPath = getenv("ETHEREUM_TEST_PATH");
-
- if (ptestPath == NULL)
- {
- ctest << " could not find environment variable ETHEREUM_TEST_PATH \n";
- testPath = "../../../tests";
- }
- else
- testPath = ptestPath;
-
- return testPath;
-}
-
-int dev::test::randomNumber()
-{
- static std::mt19937 randomGenerator(time(0));
- randomGenerator.seed(std::random_device()());
- return std::uniform_int_distribution(1)(randomGenerator);
-}
-
-Json::Value dev::test::loadJsonFromFile(std::string const& _path)
-{
- Json::Reader reader;
- Json::Value result;
- string s = dev::contentsString(_path);
- if (!s.length())
- ctest << "Contents of " + _path + " is empty. Have you cloned the 'tests' repo branch develop and set ETHEREUM_TEST_PATH to its path?";
- else
- ctest << "FIXTURE: loaded test from file: " << _path;
-
- reader.parse(s, result);
- return result;
-}
-
-std::string dev::test::toTestFilePath(std::string const& _filename)
-{
- return getTestPath() + "/" + _filename + ".json";
-}
-
-std::string dev::test::getFolder(std::string const& _file)
-{
- return boost::filesystem::path(_file).parent_path().string();
-}
-
-std::string dev::test::getRandomPath()
-{
- std::stringstream stream;
- stream << getDataDir("EthereumTests") << "/" << randomNumber();
- return stream.str();
-}
-
diff --git a/libtestutils/Common.h b/libtestutils/Common.h
deleted file mode 100644
index 866022464..000000000
--- a/libtestutils/Common.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- This file is part of cpp-ethereum.
-
- cpp-ethereum is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- cpp-ethereum is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with cpp-ethereum. If not, see .
- */
-/** @file Common.h
- * @author Marek Kotewicz
- * @date 2015
- */
-
-#pragma once
-
-#include
-#include
-#include
-
-namespace dev
-{
-namespace test
-{
-
-struct TestChannel: public LogChannel { static const char* name(); };
-#define ctest dev::LogOutputStream()
-
-std::string getTestPath();
-int randomNumber();
-Json::Value loadJsonFromFile(std::string const& _path);
-std::string toTestFilePath(std::string const& _filename);
-std::string getFolder(std::string const& _file);
-std::string getRandomPath();
-
-}
-
-}
diff --git a/libtestutils/FixedClient.cpp b/libtestutils/FixedClient.cpp
deleted file mode 100644
index 95da04cc9..000000000
--- a/libtestutils/FixedClient.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- This file is part of cpp-ethereum.
-
- cpp-ethereum is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- cpp-ethereum is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with cpp-ethereum. If not, see .
- */
-/** @file FixedClient.cpp
- * @author Marek Kotewicz
- * @date 2015
- */
-
-#include "FixedClient.h"
-
-using namespace dev;
-using namespace dev::eth;
-using namespace dev::test;
-
-Block FixedClient::asOf(h256 const& _h) const
-{
- ReadGuard l(x_stateDB);
- Block ret(m_block.db());
- ret.populateFromChain(bc(), _h);
- return ret;
-}
diff --git a/libtestutils/FixedClient.h b/libtestutils/FixedClient.h
deleted file mode 100644
index 86d4a8d05..000000000
--- a/libtestutils/FixedClient.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- This file is part of cpp-ethereum.
-
- cpp-ethereum is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- cpp-ethereum is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with cpp-ethereum. If not, see .
- */
-/** @file FixedClient.h
- * @author Marek Kotewicz
- * @date 2015
- */
-
-#pragma once
-
-#include
-#include
-#include
-
-namespace dev
-{
-namespace test
-{
-
-/**
- * @brief mvp implementation of ClientBase
- * Doesn't support mining interface
- */
-class FixedClient: public dev::eth::ClientBase
-{
-public:
- FixedClient(eth::BlockChain const& _bc, eth::Block const& _block) : m_bc(_bc), m_block(_block) {}
- virtual ~FixedClient() {}
-
- // stub
- virtual void flushTransactions() override {}
- virtual eth::BlockChain& bc() override { BOOST_THROW_EXCEPTION(InterfaceNotSupported("FixedClient::bc()")); }
- virtual eth::BlockChain const& bc() const override { return m_bc; }
- using ClientBase::asOf;
- virtual eth::Block asOf(h256 const& _h) const override;
- virtual eth::Block preMine() const override { ReadGuard l(x_stateDB); return m_block; }
- virtual eth::Block postMine() const override { ReadGuard l(x_stateDB); return m_block; }
- virtual void setBeneficiary(Address _us) override { WriteGuard l(x_stateDB); m_block.setBeneficiary(_us); }
- virtual void prepareForTransaction() override {}
-
-private:
- eth::BlockChain const& m_bc;
- eth::Block m_block;
- mutable SharedMutex x_stateDB; ///< Lock on the state DB, effectively a lock on m_postMine.
-};
-
-}
-}
diff --git a/libtestutils/FixedWebThreeServer.cpp b/libtestutils/FixedWebThreeServer.cpp
deleted file mode 100644
index 0be34cc93..000000000
--- a/libtestutils/FixedWebThreeServer.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- This file is part of cpp-ethereum.
-
- cpp-ethereum is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- cpp-ethereum is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with cpp-ethereum. If not, see .
- */
-/** @file FixedWebThreeStubServer.cpp
- * @author Marek Kotewicz
- * @author Gav Wood
- * @date 2015
- */
-
-#include "FixedWebThreeServer.h"
-#include
-using namespace std;
-using namespace dev;
-using namespace eth;
diff --git a/libtestutils/FixedWebThreeServer.h b/libtestutils/FixedWebThreeServer.h
deleted file mode 100644
index bcaacecd8..000000000
--- a/libtestutils/FixedWebThreeServer.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- This file is part of cpp-ethereum.
-
- cpp-ethereum is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- cpp-ethereum is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with cpp-ethereum. If not, see .
- */
-/** @file FixedWebThreeStubServer.h
- * @author Marek Kotewicz
- * @date 2015
- */
-
-#pragma once
-
-#include
-#include
-#include
-
-/**
- * @brief dummy JSON-RPC api implementation
- * Should be used for test purposes only
- * Supports eth && db interfaces
- * Doesn't support shh && net interfaces
- */
-class FixedWebThreeServer: public dev::WebThreeStubServerBase, public dev::WebThreeStubDatabaseFace
-{
-public:
- FixedWebThreeServer(jsonrpc::AbstractServerConnector& _conn, std::vector const& _allAccounts, dev::eth::Interface* _client):
- WebThreeStubServerBase(_conn, std::make_shared([=](){return _client;}, _allAccounts), _allAccounts),
- m_client(_client)
- {}
-
-private:
- dev::eth::Interface* client() override { return m_client; }
- std::shared_ptr face() override { BOOST_THROW_EXCEPTION(dev::InterfaceNotSupported("dev::shh::Interface")); }
- dev::WebThreeNetworkFace* network() override { BOOST_THROW_EXCEPTION(dev::InterfaceNotSupported("dev::WebThreeNetworkFace")); }
- dev::WebThreeStubDatabaseFace* db() override { return this; }
- std::string get(std::string const& _name, std::string const& _key) override
- {
- std::string k(_name + "/" + _key);
- return m_db[k];
- }
- void put(std::string const& _name, std::string const& _key, std::string const& _value) override
- {
- std::string k(_name + "/" + _key);
- m_db[k] = _value;
- }
-
-private:
- dev::eth::Interface* m_client;
- std::map m_db;
-};
diff --git a/libtestutils/StateLoader.cpp b/libtestutils/StateLoader.cpp
deleted file mode 100644
index e69de29bb..000000000
diff --git a/libtestutils/StateLoader.h b/libtestutils/StateLoader.h
deleted file mode 100644
index e69de29bb..000000000
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
deleted file mode 100644
index dcc7a405c..000000000
--- a/test/CMakeLists.txt
+++ /dev/null
@@ -1,113 +0,0 @@
-cmake_policy(SET CMP0015 NEW)
-
-aux_source_directory(. SRC_LIST)
-
-macro (add_sources)
- file (RELATIVE_PATH _relPath "${CMAKE_SOURCE_DIR}/test" "${CMAKE_CURRENT_SOURCE_DIR}")
- foreach (_src ${ARGN})
- if (_relPath)
- list (APPEND SRC "${_relPath}/${_src}")
- else()
- list (APPEND SRC "${_src}")
- endif()
- endforeach()
- if (_relPath)
- # propagate SRCS to parent directory
- set (SRC ${SRC} PARENT_SCOPE)
- endif()
-endmacro()
-
-add_subdirectory(fuzzTesting)
-add_subdirectory(libdevcore)
-add_subdirectory(libdevcrypto)
-add_subdirectory(libethcore)
-add_subdirectory(libethereum)
-add_subdirectory(libevm)
-add_subdirectory(libnatspec)
-add_subdirectory(libp2p)
-add_subdirectory(external-dependencies)
-
-if (JSCONSOLE)
- add_subdirectory(libjsengine)
-endif()
-
-if (JSONRPC)
-add_subdirectory(libweb3jsonrpc)
-endif ()
-add_subdirectory(libwhisper)
-
-set(SRC_LIST ${SRC_LIST} ${SRC})
-
-include_directories(BEFORE ${JSONCPP_INCLUDE_DIRS})
-include_directories(BEFORE ..)
-include_directories(${Boost_INCLUDE_DIRS})
-include_directories(${CRYPTOPP_INCLUDE_DIRS})
-include_directories(${JSON_RPC_CPP_INCLUDE_DIRS})
-
-if (JSCONSOLE)
- include_directories(${V8_INCLUDE_DIRS})
-endif()
-
-# search for test names and create ctest tests
-enable_testing()
-foreach(file ${SRC_LIST})
- file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/${file} test_list_raw REGEX "BOOST_.*TEST_(SUITE|CASE)")
- set(TestSuite "DEFAULT")
- foreach(test_raw ${test_list_raw})
- string(REGEX REPLACE ".*TEST_(SUITE|CASE)\\(([^ ,\\)]*).*" "\\1 \\2" test ${test_raw})
- if(test MATCHES "^SUITE .*")
- string(SUBSTRING ${test} 6 -1 TestSuite)
- elseif(test MATCHES "^CASE .*")
- string(SUBSTRING ${test} 5 -1 TestCase)
- add_test(NAME ${TestSuite}/${TestCase} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/test COMMAND testeth -t ${TestSuite}/${TestCase})
- endif(test MATCHES "^SUITE .*")
- endforeach(test_raw)
-endforeach(file)
-
-file(GLOB HEADERS "*.h")
-add_executable(testeth ${SRC_LIST} ${HEADERS})
-
-target_link_libraries(testeth ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES})
-target_link_libraries(testeth ${CURL_LIBRARIES})
-target_link_libraries(testeth ${CRYPTOPP_LIBRARIES})
-target_link_libraries(testeth ethereum)
-target_link_libraries(testeth ethcore)
-if (NOT WIN32)
- target_link_libraries(testeth secp256k1)
-endif ()
-
-if (JSCONSOLE)
- target_link_libraries(testeth jsengine)
-endif()
-
-target_link_libraries(testeth testutils)
-
-if (GUI AND NOT JUSTTESTS)
- target_link_libraries(testeth webthree)
- target_link_libraries(testeth natspec)
-endif()
-
-if (JSONRPC)
- target_link_libraries(testeth web3jsonrpc)
- target_link_libraries(testeth ${JSON_RPC_CPP_CLIENT_LIBRARIES})
-endif()
-
-enable_testing()
-set(CTEST_OUTPUT_ON_FAILURE TRUE)
-
-include(EthUtils)
-
-eth_add_test(ClientBase
- ARGS --eth_testfile=BlockTests/bcJS_API_Test --eth_threads=1
- ARGS --eth_testfile=BlockTests/bcJS_API_Test --eth_threads=3
- ARGS --eth_testfile=BlockTests/bcJS_API_Test --eth_threads=10
- ARGS --eth_testfile=BlockTests/bcValidBlockTest --eth_threads=1
- ARGS --eth_testfile=BlockTests/bcValidBlockTest --eth_threads=3
- ARGS --eth_testfile=BlockTests/bcValidBlockTest --eth_threads=10
-)
-
-eth_add_test(JsonRpc
- ARGS --eth_testfile=BlockTests/bcJS_API_Test
- ARGS --eth_testfile=BlockTests/bcValidBlockTest
-)
-
diff --git a/test/JSON_test.sol b/test/JSON_test.sol
deleted file mode 100644
index ffd7cdc40..000000000
--- a/test/JSON_test.sol
+++ /dev/null
@@ -1,120 +0,0 @@
- contract JSON_Test {
- event Log0(uint value) ;
- event Log0Anonym (uint value) anonymous;
- event Log1(bool indexed aBool, uint value);
- event Log1Anonym(bool indexed aBool, uint value) anonymous;
- event Log2(bool indexed aBool, address indexed aAddress, uint value);
- event Log2Anonym(bool indexed aBool, address indexed aAddress, uint value) anonymous;
- event Log3(bool indexed aBool, address indexed aAddress, bytes32 indexed aBytes32, uint value);
- event Log3Anonym(bool indexed aBool, address indexed aAddress, bytes32 indexed aBytes32, uint value) anonymous;
- event Log4(bool indexed aBool, address indexed aAddress, bytes32 indexed aBytes32, int8 aInt8, uint value);
- event Log4Anonym(bool indexed aBool, address indexed aAddress, bytes32 indexed aBytes32, int8 aInt8, uint value) anonymous;
-
- function JSON_Test() {
- }
-
- function setBool(bool _bool) {
- myBool = _bool;
- }
-
- function setInt8(int8 _int8) {
- myInt8 = _int8;
- }
-
- function setUint8(uint8 _uint8) {
- myUint8 = _uint8;
- }
-
- function setInt256(int256 _int256) {
- myInt256 = _int256;
- }
-
- function setUint256(uint256 _uint256) {
- myUint256 = _uint256;
- }
-
- function setAddress(address _address) {
- myAddress = _address;
- }
-
- function setBytes32(bytes32 _bytes32) {
- myBytes32 = _bytes32;
- }
-
- function getBool() returns (bool ret) {
- return myBool;
- }
-
- function getInt8() returns (int8 ret) {
- return myInt8;
- }
-
- function getUint8() returns (uint8 ret) {
- return myUint8;
- }
-
- function getInt256() returns (int256 ret) {
- return myInt256;
- }
-
- function getUint256() returns (uint256 ret) {
- return myUint256;
- }
-
- function getAddress() returns (address ret) {
- return myAddress;
- }
-
- function getBytes32() returns (bytes32 ret) {
- return myBytes32;
- }
-
- function fireEventLog0() {
- Log0(42);
- }
-
- function fireEventLog0Anonym() {
- Log0Anonym(42);
- }
-
- function fireEventLog1() {
- Log1(true, 42);
- }
-
- function fireEventLog1Anonym() {
- Log1Anonym(true, 42);
- }
-
- function fireEventLog2() {
- Log2(true, msg.sender, 42);
- }
-
- function fireEventLog2Anonym() {
- Log2Anonym(true, msg.sender, 42);
- }
-
- function fireEventLog3() {
- Log3(true, msg.sender, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 42);
- }
-
- function fireEventLog3Anonym() {
- Log3Anonym(true, msg.sender, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 42);
- }
-
- function fireEventLog4() {
- Log4(true, msg.sender, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, -23, 42);
- }
-
- function fireEventLog4Anonym() {
- Log4Anonym(true, msg.sender, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, -23, 42);
- }
-
- bool myBool;
- int8 myInt8;
- uint8 myUint8;
- int256 myInt256;
- uint256 myUint256;
- address myAddress;
- bytes32 myBytes32;
-}
-
diff --git a/test/Stats.cpp b/test/Stats.cpp
deleted file mode 100644
index e76d1ee00..000000000
--- a/test/Stats.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- This file is part of cpp-ethereum.
-
- cpp-ethereum is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- cpp-ethereum is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with cpp-ethereum. If not, see .
-*/
-
-#include "Stats.h"
-
-#include
-#include
-#include
-
-namespace dev
-{
-namespace test
-{
-
-Stats& Stats::get()
-{
- static Stats instance;
- return instance;
-}
-
-void Stats::suiteStarted(std::string const& _name)
-{
- m_currentSuite = _name;
-}
-
-void Stats::testStarted(std::string const& _name)
-{
- m_currentTest = _name;
- m_tp = clock::now();
-}
-
-void Stats::testFinished()
-{
- m_stats.push_back({clock::now() - m_tp, m_currentSuite + "/" + m_currentTest});
-}
-
-std::ostream& operator<<(std::ostream& out, Stats::clock::duration const& d)
-{
- return out << std::setw(10) << std::right << std::chrono::duration_cast(d).count() << " us";
-}
-
-Stats::~Stats()
-{
- if (m_stats.empty())
- return;
-
- std::sort(m_stats.begin(), m_stats.end(), [](Stats::Item const& a, Stats::Item const& b){
- return a.duration < b.duration;
- });
-
- auto& out = std::cout;
- auto itr = m_stats.begin();
- auto min = *itr;
- auto max = *m_stats.rbegin();
- std::advance(itr, m_stats.size() / 2);
- auto med = *itr;
- auto tot = std::accumulate(m_stats.begin(), m_stats.end(), clock::duration{}, [](clock::duration const& a, Stats::Item const& v)
- {
- return a + v.duration;
- });
-
- out << "\nSTATS:\n\n" << std::setfill(' ');
-
- if (Options::get().statsOutFile == "out")
- {
- for (auto&& s: m_stats)
- out << " " << std::setw(40) << std::left << s.name.substr(0, 40) << s.duration << " \n";
- out << "\n";
- }
- else if (!Options::get().statsOutFile.empty())
- {
- // Output stats to file
- std::ofstream file{Options::get().statsOutFile};
- for (auto&& s: m_stats)
- file << s.name << "\t" << std::chrono::duration_cast(s.duration).count() << "\n";
- }
-
- out << " tot: " << tot << "\n"
- << " avg: " << (tot / m_stats.size()) << "\n\n"
- << " min: " << min.duration << " (" << min.name << ")\n"
- << " med: " << med.duration << " (" << med.name << ")\n"
- << " max: " << max.duration << " (" << max.name << ")\n";
-}
-
-}
-}
diff --git a/test/Stats.h b/test/Stats.h
deleted file mode 100644
index 9b40c5fce..000000000
--- a/test/Stats.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- This file is part of cpp-ethereum.
-
- cpp-ethereum is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- cpp-ethereum is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with cpp-ethereum. If not, see .
-*/
-
-#pragma once
-
-#include
-#include
-
-#include "TestHelper.h"
-
-namespace dev
-{
-namespace test
-{
-
-class Stats: public Listener
-{
-public:
- using clock = std::chrono::high_resolution_clock;
-
- struct Item
- {
- clock::duration duration;
- std::string name;
- };
-
- static Stats& get();
-
- ~Stats();
-
- void suiteStarted(std::string const& _name) override;
- void testStarted(std::string const& _name) override;
- void testFinished() override;
-
-private:
- clock::time_point m_tp;
- std::string m_currentSuite;
- std::string m_currentTest;
- std::vector- m_stats;
-};
-
-}
-}
diff --git a/test/TestHelper.cpp b/test/TestHelper.cpp
deleted file mode 100644
index beb40a4b4..000000000
--- a/test/TestHelper.cpp
+++ /dev/null
@@ -1,894 +0,0 @@
-/*
- This file is part of cpp-ethereum.
-
- cpp-ethereum is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- cpp-ethereum is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with cpp-ethereum. If not, see .
-*/
-/** @file TestHelper.cpp
- * @author Marko Simovic
- * @date 2014
- */
-
-#include "TestHelper.h"
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include "Stats.h"
-
-using namespace std;
-using namespace dev::eth;
-
-namespace dev
-{
-namespace eth
-{
-
-void mine(Client& c, int numBlocks)
-{
- auto startBlock = c.blockChain().details().number;
-
- c.startMining();
- while(c.blockChain().details().number < startBlock + numBlocks)
- std::this_thread::sleep_for(std::chrono::milliseconds(100));
- c.stopMining();
-}
-
-void connectClients(Client& c1, Client& c2)
-{
- (void)c1;
- (void)c2;
- // TODO: Move to WebThree. eth::Client no longer handles networking.
-#if 0
- short c1Port = 20000;
- short c2Port = 21000;
- c1.startNetwork(c1Port);
- c2.startNetwork(c2Port);
- c2.connect("127.0.0.1", c1Port);
-#endif
-}
-
-void mine(Block& s, BlockChain const& _bc)
-{
- std::unique_ptr sealer(Ethash::createSealEngine());
- s.commitToSeal(_bc);
- Notified sealed;
- sealer->onSealGenerated([&](bytes const& sealedHeader){ sealed = sealedHeader; });
- sealer->generateSeal(s.info());
- sealed.waitNot({});
- sealer.reset();
- s.sealBlock(sealed);
-}
-
-void mine(Ethash::BlockHeader& _bi)
-{
- std::unique_ptr sealer(Ethash::createSealEngine());
- Notified sealed;
- sealer->onSealGenerated([&](bytes const& sealedHeader){ sealed = sealedHeader; });
- sealer->generateSeal(_bi);
- sealed.waitNot({});
- sealer.reset();
- _bi = Ethash::BlockHeader(sealed, CheckNothing, h256{}, HeaderData);
-}
-
-}
-
-namespace test
-{
-
-struct ValueTooLarge: virtual Exception {};
-struct MissingFields : virtual Exception {};
-
-bigint const c_max256plus1 = bigint(1) << 256;
-
-ImportTest::ImportTest(json_spirit::mObject& _o, bool isFiller, testType testTemplate):
- m_statePre(OverlayDB(), eth::BaseState::Empty),
- m_statePost(OverlayDB(), eth::BaseState::Empty),
- m_testObject(_o)
-{
- if (testTemplate == testType::StateTests)
- {
- importEnv(_o["env"].get_obj());
- importTransaction(_o["transaction"].get_obj());
- importState(_o["pre"].get_obj(), m_statePre);
- if (!isFiller)
- {
- if (_o.count("post"))
- importState(_o["post"].get_obj(), m_statePost);
- else
- importState(_o["postState"].get_obj(), m_statePost);
- m_logsExpected = importLog(_o["logs"].get_array());
- }
- }
-}
-
-//executes an imported transacton on preState
-bytes ImportTest::executeTest()
-{
- ExecutionResult res;
- eth::State tmpState = m_statePre;
- try
- {
- std::pair execOut = m_statePre.execute(m_envInfo, m_transaction);
- res = execOut.first;
- m_logs = execOut.second.log();
- }
- catch (Exception const& _e)
- {
- cnote << "Exception: " << diagnostic_information(_e);
- }
- catch (std::exception const& _e)
- {
- cnote << "state execution exception: " << _e.what();
- }
-
- m_statePre.commit();
- m_statePost = m_statePre;
- m_statePre = tmpState;
-
- return res.output;
-}
-
-json_spirit::mObject& ImportTest::makeAllFieldsHex(json_spirit::mObject& _o)
-{
- static const set hashes {"bloom" , "coinbase", "hash", "mixHash", "parentHash", "receiptTrie",
- "stateRoot", "transactionsTrie", "uncleHash", "currentCoinbase",
- "previousHash", "to", "address", "caller", "origin", "secretKey", "data"};
-
- for (auto& i: _o)
- {
- std::string key = i.first;
- if (hashes.count(key))
- continue;
-
- std::string str;
- json_spirit::mValue value = i.second;
-
- if (value.type() == json_spirit::int_type)
- str = toString(value.get_int());
- else if (value.type() == json_spirit::str_type)
- str = value.get_str();
- else continue;
-
- _o[key] = (str.substr(0, 2) == "0x") ? str : toCompactHex(toInt(str), HexPrefix::Add, 1);
- }
- return _o;
-}
-
-void ImportTest::importEnv(json_spirit::mObject& _o)
-{
- assert(_o.count("currentGasLimit") > 0);
- assert(_o.count("currentDifficulty") > 0);
- assert(_o.count("currentNumber") > 0);
- assert(_o.count("currentTimestamp") > 0);
- assert(_o.count("currentCoinbase") > 0);
- m_envInfo.setGasLimit(toInt(_o["currentGasLimit"]));
- m_envInfo.setDifficulty(toInt(_o["currentDifficulty"]));
- m_envInfo.setNumber(toInt(_o["currentNumber"]));
- m_envInfo.setTimestamp(toInt(_o["currentTimestamp"]));
- m_envInfo.setBeneficiary(Address(_o["currentCoinbase"].get_str()));
- m_envInfo.setLastHashes( lastHashes( m_envInfo.number() ) );
-}
-
-// import state from not fully declared json_spirit::mObject, writing to _stateOptionsMap which fields were defined in json
-
-void ImportTest::importState(json_spirit::mObject& _o, State& _state, AccountMaskMap& o_mask)
-{
- std::string jsondata = json_spirit::write_string((json_spirit::mValue)_o, false);
- _state.populateFrom(jsonToAccountMap(jsondata, &o_mask));
-}
-
-void ImportTest::importState(json_spirit::mObject& _o, State& _state)
-{
- AccountMaskMap mask;
- importState(_o, _state, mask);
- for (auto const& i: mask)
- //check that every parameter was declared in state object
- if (!i.second.allSet())
- BOOST_THROW_EXCEPTION(MissingFields() << errinfo_comment("Import State: Missing state fields!"));
-}
-
-void ImportTest::importTransaction (json_spirit::mObject const& _o, eth::Transaction& o_tr)
-{
- if (_o.count("secretKey") > 0)
- {
- assert(_o.count("nonce") > 0);
- assert(_o.count("gasPrice") > 0);
- assert(_o.count("gasLimit") > 0);
- assert(_o.count("to") > 0);
- assert(_o.count("value") > 0);
- assert(_o.count("data") > 0);
-
- if (bigint(_o.at("nonce").get_str()) >= c_max256plus1)
- BOOST_THROW_EXCEPTION(ValueTooLarge() << errinfo_comment("Transaction 'nonce' is equal or greater than 2**256") );
- if (bigint(_o.at("gasPrice").get_str()) >= c_max256plus1)
- BOOST_THROW_EXCEPTION(ValueTooLarge() << errinfo_comment("Transaction 'gasPrice' is equal or greater than 2**256") );
- if (bigint(_o.at("gasLimit").get_str()) >= c_max256plus1)
- BOOST_THROW_EXCEPTION(ValueTooLarge() << errinfo_comment("Transaction 'gasLimit' is equal or greater than 2**256") );
- if (bigint(_o.at("value").get_str()) >= c_max256plus1)
- BOOST_THROW_EXCEPTION(ValueTooLarge() << errinfo_comment("Transaction 'value' is equal or greater than 2**256") );
-
- o_tr = _o.at("to").get_str().empty() ?
- Transaction(toInt(_o.at("value")), toInt(_o.at("gasPrice")), toInt(_o.at("gasLimit")), importData(_o), toInt(_o.at("nonce")), Secret(_o.at("secretKey").get_str())) :
- Transaction(toInt(_o.at("value")), toInt(_o.at("gasPrice")), toInt(_o.at("gasLimit")), Address(_o.at("to").get_str()), importData(_o), toInt(_o.at("nonce")), Secret(_o.at("secretKey").get_str()));
- }
- else
- {
- RLPStream transactionRLPStream = createRLPStreamFromTransactionFields(_o);
- RLP transactionRLP(transactionRLPStream.out());
- try
- {
- o_tr = Transaction(transactionRLP.data(), CheckTransaction::Everything);
- }
- catch (InvalidSignature)
- {
- // create unsigned transaction
- o_tr = _o.at("to").get_str().empty() ?
- Transaction(toInt(_o.at("value")), toInt(_o.at("gasPrice")), toInt(_o.at("gasLimit")), importData(_o), toInt(_o.at("nonce"))) :
- Transaction(toInt(_o.at("value")), toInt(_o.at("gasPrice")), toInt(_o.at("gasLimit")), Address(_o.at("to").get_str()), importData(_o), toInt(_o.at("nonce")));
- }
- catch (Exception& _e)
- {
- cnote << "invalid transaction" << boost::diagnostic_information(_e);
- }
- }
-}
-
-void ImportTest::importTransaction(json_spirit::mObject const& o_tr)
-{
- importTransaction(o_tr, m_transaction);
-}
-
-int ImportTest::compareStates(State const& _stateExpect, State const& _statePost, AccountMaskMap const _expectedStateOptions, WhenError _throw)
-{
- #define CHECK(a,b) \
- { \
- if (_throw == WhenError::Throw) \
- { \
- BOOST_CHECK_MESSAGE(a, b); \
- if (!a) \
- return 1; \
- } \
- else \
- BOOST_WARN_MESSAGE(a,b); \
- }
-
- for (auto const& a: _stateExpect.addresses())
- {
- CHECK(_statePost.addressInUse(a.first), "Compare States: " << a.first << " missing expected address!");
- if (_statePost.addressInUse(a.first))
- {
- AccountMask addressOptions(true);
- if(_expectedStateOptions.size())
- {
- try
- {
- addressOptions = _expectedStateOptions.at(a.first);
- }
- catch(std::out_of_range const&)
- {
- BOOST_ERROR("expectedStateOptions map does not match expectedState in checkExpectedState!");
- break;
- }
- }
-
- if (addressOptions.hasBalance())
- CHECK((_stateExpect.balance(a.first) == _statePost.balance(a.first)),
- "Check State: " << a.first << ": incorrect balance " << _statePost.balance(a.first) << ", expected " << _stateExpect.balance(a.first));
-
- if (addressOptions.hasNonce())
- CHECK((_stateExpect.transactionsFrom(a.first) == _statePost.transactionsFrom(a.first)),
- "Check State: " << a.first << ": incorrect nonce " << _statePost.transactionsFrom(a.first) << ", expected " << _stateExpect.transactionsFrom(a.first));
-
- if (addressOptions.hasStorage())
- {
- unordered_map stateStorage = _statePost.storage(a.first);
- for (auto const& s: _stateExpect.storage(a.first))
- CHECK((stateStorage[s.first] == s.second),
- "Check State: " << a.first << ": incorrect storage [" << s.first << "] = " << toHex(stateStorage[s.first]) << ", expected [" << s.first << "] = " << toHex(s.second));
-
- //Check for unexpected storage values
- stateStorage = _stateExpect.storage(a.first);
- for (auto const& s: _statePost.storage(a.first))
- CHECK((stateStorage[s.first] == s.second),
- "Check State: " << a.first << ": incorrect storage [" << s.first << "] = " << toHex(s.second) << ", expected [" << s.first << "] = " << toHex(stateStorage[s.first]));
- }
-
- if (addressOptions.hasCode())
- CHECK((_stateExpect.code(a.first) == _statePost.code(a.first)),
- "Check State: " << a.first << ": incorrect code '" << toHex(_statePost.code(a.first)) << "', expected '" << toHex(_stateExpect.code(a.first)) << "'");
- }
- }
- return 0;
-}
-
-int ImportTest::exportTest(bytes const& _output)
-{
- int err = 0;
- // export output
- m_testObject["out"] = (_output.size() > 4096 && !Options::get().fulloutput) ? "#" + toString(_output.size()) : toHex(_output, 2, HexPrefix::Add);
-
- // compare expected output with post output
- if (m_testObject.count("expectOut") > 0)
- {
- std::string warning = "Check State: Error! Unexpected output: " + m_testObject["out"].get_str() + " Expected: " + m_testObject["expectOut"].get_str();
- if (Options::get().checkState)
- {
- bool statement = (m_testObject["out"].get_str() == m_testObject["expectOut"].get_str());
- BOOST_CHECK_MESSAGE(statement, warning);
- if (!statement)
- err = 1;
- }
- else
- BOOST_WARN_MESSAGE(m_testObject["out"].get_str() == m_testObject["expectOut"].get_str(), warning);
-
- m_testObject.erase(m_testObject.find("expectOut"));
- }
-
- // export logs
- m_testObject["logs"] = exportLog(m_logs);
-
- // compare expected state with post state
- if (m_testObject.count("expect") > 0)
- {
- eth::AccountMaskMap stateMap;
- State expectState(OverlayDB(), eth::BaseState::Empty);
- importState(m_testObject["expect"].get_obj(), expectState, stateMap);
- compareStates(expectState, m_statePost, stateMap, Options::get().checkState ? WhenError::Throw : WhenError::DontThrow);
- m_testObject.erase(m_testObject.find("expect"));
- }
-
- // export post state
- m_testObject["post"] = fillJsonWithState(m_statePost);
- m_testObject["postStateRoot"] = toHex(m_statePost.rootHash().asBytes());
-
- // export pre state
- m_testObject["pre"] = fillJsonWithState(m_statePre);
- m_testObject["env"] = makeAllFieldsHex(m_testObject["env"].get_obj());
- m_testObject["transaction"] = makeAllFieldsHex(m_testObject["transaction"].get_obj());
- return err;
-}
-
-json_spirit::mObject fillJsonWithTransaction(Transaction _txn)
-{
- json_spirit::mObject txObject;
- txObject["nonce"] = toCompactHex(_txn.nonce(), HexPrefix::Add, 1);
- txObject["data"] = toHex(_txn.data(), 2, HexPrefix::Add);
- txObject["gasLimit"] = toCompactHex(_txn.gas(), HexPrefix::Add, 1);
- txObject["gasPrice"] = toCompactHex(_txn.gasPrice(), HexPrefix::Add, 1);
- txObject["r"] = toCompactHex(_txn.signature().r, HexPrefix::Add, 1);
- txObject["s"] = toCompactHex(_txn.signature().s, HexPrefix::Add, 1);
- txObject["v"] = toCompactHex(_txn.signature().v + 27, HexPrefix::Add, 1);
- txObject["to"] = _txn.isCreation() ? "" : toString(_txn.receiveAddress());
- txObject["value"] = toCompactHex(_txn.value(), HexPrefix::Add, 1);
- return txObject;
-}
-
-json_spirit::mObject fillJsonWithState(State _state)
-{
- json_spirit::mObject oState;
- for (auto const& a: _state.addresses())
- {
- json_spirit::mObject o;
- o["balance"] = toCompactHex(_state.balance(a.first), HexPrefix::Add, 1);
- o["nonce"] = toCompactHex(_state.transactionsFrom(a.first), HexPrefix::Add, 1);
- {
- json_spirit::mObject store;
- for (auto const& s: _state.storage(a.first))
- store[toCompactHex(s.first, HexPrefix::Add, 1)] = toCompactHex(s.second, HexPrefix::Add, 1);
- o["storage"] = store;
- }
- o["code"] = toHex(_state.code(a.first), 2, HexPrefix::Add);
- oState[toString(a.first)] = o;
- }
- return oState;
-}
-
-json_spirit::mArray exportLog(eth::LogEntries _logs)
-{
- json_spirit::mArray ret;
- if (_logs.size() == 0) return ret;
- for (LogEntry const& l: _logs)
- {
- json_spirit::mObject o;
- o["address"] = toString(l.address);
- json_spirit::mArray topics;
- for (auto const& t: l.topics)
- topics.push_back(toString(t));
- o["topics"] = topics;
- o["data"] = toHex(l.data, 2, HexPrefix::Add);
- o["bloom"] = toString(l.bloom());
- ret.push_back(o);
- }
- return ret;
-}
-
-u256 toInt(json_spirit::mValue const& _v)
-{
- switch (_v.type())
- {
- case json_spirit::str_type: return u256(_v.get_str());
- case json_spirit::int_type: return (u256)_v.get_uint64();
- case json_spirit::bool_type: return (u256)(uint64_t)_v.get_bool();
- case json_spirit::real_type: return (u256)(uint64_t)_v.get_real();
- default: cwarn << "Bad type for scalar: " << _v.type();
- }
- return 0;
-}
-
-byte toByte(json_spirit::mValue const& _v)
-{
- switch (_v.type())
- {
- case json_spirit::str_type: return (byte)stoi(_v.get_str());
- case json_spirit::int_type: return (byte)_v.get_uint64();
- case json_spirit::bool_type: return (byte)_v.get_bool();
- case json_spirit::real_type: return (byte)_v.get_real();
- default: cwarn << "Bad type for scalar: " << _v.type();
- }
- return 0;
-}
-
-bytes importByteArray(std::string const& _str)
-{
- return fromHex(_str.substr(0, 2) == "0x" ? _str.substr(2) : _str, WhenError::Throw);
-}
-
-bytes importData(json_spirit::mObject const& _o)
-{
- bytes data;
- if (_o.at("data").type() == json_spirit::str_type)
- data = importByteArray(_o.at("data").get_str());
- else
- for (auto const& j: _o.at("data").get_array())
- data.push_back(toByte(j));
- return data;
-}
-
-bytes importCode(json_spirit::mObject& _o)
-{
- bytes code;
- if (_o["code"].type() == json_spirit::str_type)
- if (_o["code"].get_str().find("0x") != 0)
- code = compileLLL(_o["code"].get_str(), false);
- else
- code = fromHex(_o["code"].get_str().substr(2));
- else if (_o["code"].type() == json_spirit::array_type)
- {
- code.clear();
- for (auto const& j: _o["code"].get_array())
- code.push_back(toByte(j));
- }
- return code;
-}
-
-LogEntries importLog(json_spirit::mArray& _a)
-{
- LogEntries logEntries;
- for (auto const& l: _a)
- {
- json_spirit::mObject o = l.get_obj();
- // cant use BOOST_REQUIRE, because this function is used outside boost test (createRandomTest)
- assert(o.count("address") > 0);
- assert(o.count("topics") > 0);
- assert(o.count("data") > 0);
- assert(o.count("bloom") > 0);
- LogEntry log;
- log.address = Address(o["address"].get_str());
- for (auto const& t: o["topics"].get_array())
- log.topics.push_back(h256(t.get_str()));
- log.data = importData(o);
- logEntries.push_back(log);
- }
- return logEntries;
-}
-
-void checkOutput(bytes const& _output, json_spirit::mObject& _o)
-{
- int j = 0;
-
- if (_o["out"].get_str().find("#") == 0)
- BOOST_CHECK((u256)_output.size() == toInt(_o["out"].get_str().substr(1)));
- else if (_o["out"].type() == json_spirit::array_type)
- for (auto const& d: _o["out"].get_array())
- {
- BOOST_CHECK_MESSAGE(_output[j] == toInt(d), "Output byte [" << j << "] different!");
- ++j;
- }
- else if (_o["out"].get_str().find("0x") == 0)
- BOOST_CHECK(_output == fromHex(_o["out"].get_str().substr(2)));
- else
- BOOST_CHECK(_output == fromHex(_o["out"].get_str()));
-}
-
-void checkStorage(map _expectedStore, map _resultStore, Address _expectedAddr)
-{
- _expectedAddr = _expectedAddr; //unsed parametr when macro
- for (auto&& expectedStorePair : _expectedStore)
- {
- auto& expectedStoreKey = expectedStorePair.first;
- auto resultStoreIt = _resultStore.find(expectedStoreKey);
- if (resultStoreIt == _resultStore.end())
- BOOST_ERROR(_expectedAddr << ": missing store key " << expectedStoreKey);
- else
- {
- auto& expectedStoreValue = expectedStorePair.second;
- auto& resultStoreValue = resultStoreIt->second;
- BOOST_CHECK_MESSAGE(expectedStoreValue == resultStoreValue, _expectedAddr << ": store[" << expectedStoreKey << "] = " << resultStoreValue << ", expected " << expectedStoreValue);
- }
- }
- BOOST_CHECK_EQUAL(_resultStore.size(), _expectedStore.size());
- for (auto&& resultStorePair: _resultStore)
- {
- if (!_expectedStore.count(resultStorePair.first))
- BOOST_ERROR(_expectedAddr << ": unexpected store key " << resultStorePair.first);
- }
-}
-
-void checkLog(LogEntries _resultLogs, LogEntries _expectedLogs)
-{
- BOOST_REQUIRE_EQUAL(_resultLogs.size(), _expectedLogs.size());
-
- for (size_t i = 0; i < _resultLogs.size(); ++i)
- {
- BOOST_CHECK_EQUAL(_resultLogs[i].address, _expectedLogs[i].address);
- BOOST_CHECK_EQUAL(_resultLogs[i].topics, _expectedLogs[i].topics);
- BOOST_CHECK(_resultLogs[i].data == _expectedLogs[i].data);
- }
-}
-
-void checkCallCreates(eth::Transactions _resultCallCreates, eth::Transactions _expectedCallCreates)
-{
- BOOST_REQUIRE_EQUAL(_resultCallCreates.size(), _expectedCallCreates.size());
-
- for (size_t i = 0; i < _resultCallCreates.size(); ++i)
- {
- BOOST_CHECK(_resultCallCreates[i].data() == _expectedCallCreates[i].data());
- BOOST_CHECK(_resultCallCreates[i].receiveAddress() == _expectedCallCreates[i].receiveAddress());
- BOOST_CHECK(_resultCallCreates[i].gas() == _expectedCallCreates[i].gas());
- BOOST_CHECK(_resultCallCreates[i].value() == _expectedCallCreates[i].value());
- }
-}
-
-void userDefinedTest(std::function doTests)
-{
- if (!Options::get().singleTest)
- return;
-
- if (Options::get().singleTestFile.empty() || Options::get().singleTestName.empty())
- {
- cnote << "Missing user test specification\nUsage: testeth --singletest \n";
- return;
- }
-
- auto& filename = Options::get().singleTestFile;
- auto& testname = Options::get().singleTestName;
-
- if (g_logVerbosity != -1)
- VerbosityHolder sentinel(12);
-
- try
- {
- cnote << "Testing user defined test: " << filename;
- json_spirit::mValue v;
- string s = contentsString(filename);
- BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of " + filename + " is empty. ");
- json_spirit::read_string(s, v);
- json_spirit::mObject oSingleTest;
-
- json_spirit::mObject::const_iterator pos = v.get_obj().find(testname);
- if (pos == v.get_obj().end())
- {
- cnote << "Could not find test: " << testname << " in " << filename << "\n";
- return;
- }
- else
- oSingleTest[pos->first] = pos->second;
-
- json_spirit::mValue v_singleTest(oSingleTest);
- doTests(v_singleTest, test::Options::get().fillTests);
- }
- catch (Exception const& _e)
- {
- BOOST_ERROR("Failed Test with Exception: " << diagnostic_information(_e));
- }
- catch (std::exception const& _e)
- {
- BOOST_ERROR("Failed Test with Exception: " << _e.what());
- }
-}
-
-void executeTests(const string& _name, const string& _testPathAppendix, const boost::filesystem::path _pathToFiller, std::function doTests)
-{
- string testPath = getTestPath();
- testPath += _testPathAppendix;
-
- if (Options::get().stats)
- Listener::registerListener(Stats::get());
-
- if (Options::get().fillTests)
- {
- try
- {
- cnote << "Populating tests...";
- json_spirit::mValue v;
- boost::filesystem::path p(__FILE__);
- string s = asString(dev::contents(_pathToFiller.string() + "/" + _name + "Filler.json"));
- BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of " + _pathToFiller.string() + "/" + _name + "Filler.json is empty.");
- json_spirit::read_string(s, v);
- doTests(v, true);
- writeFile(testPath + "/" + _name + ".json", asBytes(json_spirit::write_string(v, true)));
- }
- catch (Exception const& _e)
- {
- BOOST_ERROR("Failed filling test with Exception: " << diagnostic_information(_e));
- }
- catch (std::exception const& _e)
- {
- BOOST_ERROR("Failed filling test with Exception: " << _e.what());
- }
- }
-
- try
- {
- cnote << "TEST " << _name << ":";
- json_spirit::mValue v;
- string s = asString(dev::contents(testPath + "/" + _name + ".json"));
- BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of " + testPath + "/" + _name + ".json is empty. Have you cloned the 'tests' repo branch develop and set ETHEREUM_TEST_PATH to its path?");
- json_spirit::read_string(s, v);
- Listener::notifySuiteStarted(_name);
- doTests(v, false);
- }
- catch (Exception const& _e)
- {
- BOOST_ERROR("Failed test with Exception: " << diagnostic_information(_e));
- }
- catch (std::exception const& _e)
- {
- BOOST_ERROR("Failed test with Exception: " << _e.what());
- }
-}
-
-RLPStream createRLPStreamFromTransactionFields(json_spirit::mObject const& _tObj)
-{
- //Construct Rlp of the given transaction
- RLPStream rlpStream;
- rlpStream.appendList(_tObj.size());
-
- if (_tObj.count("nonce"))
- rlpStream << bigint(_tObj.at("nonce").get_str());
-
- if (_tObj.count("gasPrice"))
- rlpStream << bigint(_tObj.at("gasPrice").get_str());
-
- if (_tObj.count("gasLimit"))
- rlpStream << bigint(_tObj.at("gasLimit").get_str());
-
- if (_tObj.count("to"))
- {
- if (_tObj.at("to").get_str().empty())
- rlpStream << "";
- else
- rlpStream << importByteArray(_tObj.at("to").get_str());
- }
-
- if (_tObj.count("value"))
- rlpStream << bigint(_tObj.at("value").get_str());
-
- if (_tObj.count("data"))
- rlpStream << importData(_tObj);
-
- if (_tObj.count("v"))
- rlpStream << bigint(_tObj.at("v").get_str());
-
- if (_tObj.count("r"))
- rlpStream << bigint(_tObj.at("r").get_str());
-
- if (_tObj.count("s"))
- rlpStream << bigint(_tObj.at("s").get_str());
-
- if (_tObj.count("extrafield"))
- rlpStream << bigint(_tObj.at("extrafield").get_str());
-
- return rlpStream;
-}
-
-Options::Options()
-{
- auto argc = boost::unit_test::framework::master_test_suite().argc;
- auto argv = boost::unit_test::framework::master_test_suite().argv;
-
- for (auto i = 0; i < argc; ++i)
- {
- auto arg = std::string{argv[i]};
- if (arg == "--vm" && i + 1 < argc)
- {
- string vmKind = argv[++i];
- if (vmKind == "interpreter")
- VMFactory::setKind(VMKind::Interpreter);
- else if (vmKind == "jit")
- VMFactory::setKind(VMKind::JIT);
- else if (vmKind == "smart")
- VMFactory::setKind(VMKind::Smart);
- else
- cerr << "Unknown VM kind: " << vmKind << endl;
- }
- else if (arg == "--jit") // TODO: Remove deprecated option "--jit"
- VMFactory::setKind(VMKind::JIT);
- else if (arg == "--vmtrace")
- vmtrace = true;
- else if (arg == "--filltests")
- fillTests = true;
- else if (arg == "--stats" && i + 1 < argc)
- {
- stats = true;
- statsOutFile = argv[i + 1];
- }
- else if (arg == "--performance")
- performance = true;
- else if (arg == "--quadratic")
- quadratic = true;
- else if (arg == "--memory")
- memory = true;
- else if (arg == "--inputlimits")
- inputLimits = true;
- else if (arg == "--bigdata")
- bigData = true;
- else if (arg == "--checkstate")
- checkState = true;
- else if (arg == "--wallet")
- wallet = true;
- else if (arg == "--nonetwork")
- nonetwork = true;
- else if (arg == "--network")
- nonetwork = false;
- else if (arg == "--nodag")
- nodag = true;
- else if (arg == "--all")
- {
- performance = true;
- quadratic = true;
- memory = true;
- inputLimits = true;
- bigData = true;
- wallet = true;
- }
- else if (arg == "--singletest" && i + 1 < argc)
- {
- singleTest = true;
- auto name1 = std::string{argv[i + 1]};
- if (i + 1 < argc) // two params
- {
- auto name2 = std::string{argv[i + 2]};
- if (name2[0] == '-') // not param, another option
- singleTestName = std::move(name1);
- else
- {
- singleTestFile = std::move(name1);
- singleTestName = std::move(name2);
- }
- }
- else
- singleTestName = std::move(name1);
- }
- else if (arg == "--fulloutput")
- fulloutput = true;
- else if (arg == "--verbosity" && i + 1 < argc)
- {
- static std::ostringstream strCout; //static string to redirect logs to
- std::string indentLevel = std::string{argv[i + 1]};
- if (indentLevel == "0")
- {
- logVerbosity = Verbosity::None;
- std::cout.rdbuf(strCout.rdbuf());
- std::cerr.rdbuf(strCout.rdbuf());
- }
- else if (indentLevel == "1")
- logVerbosity = Verbosity::NiceReport;
- else
- logVerbosity = Verbosity::Full;
- }
- else if (arg == "--createRandomTest")
- createRandomTest = true;
- }
-
- //Default option
- if (logVerbosity == Verbosity::NiceReport)
- g_logVerbosity = -1; //disable cnote but leave cerr and cout
-}
-
-Options const& Options::get()
-{
- static Options instance;
- return instance;
-}
-
-LastHashes lastHashes(u256 _currentBlockNumber)
-{
- LastHashes ret;
- for (u256 i = 1; i <= 256 && i <= _currentBlockNumber; ++i)
- ret.push_back(sha3(toString(_currentBlockNumber - i)));
- return ret;
-}
-
-dev::eth::Ethash::BlockHeader constructHeader(
- h256 const& _parentHash,
- h256 const& _sha3Uncles,
- Address const& _coinbaseAddress,
- 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)
-{
- RLPStream rlpStream;
- rlpStream.appendList(Ethash::BlockHeader::Fields);
-
- rlpStream << _parentHash << _sha3Uncles << _coinbaseAddress << _stateRoot << _transactionsRoot << _receiptsRoot << _logBloom
- << _difficulty << _number << _gasLimit << _gasUsed << _timestamp << _extraData << h256{} << Nonce{};
-
- return Ethash::BlockHeader(rlpStream.out(), CheckNothing, h256{}, HeaderData);
-}
-
-void updateEthashSeal(dev::eth::Ethash::BlockHeader& _header, h256 const& _mixHash, dev::eth::Nonce const& _nonce)
-{
- RLPStream source;
- _header.streamRLP(source);
- RLP sourceRlp(source.out());
- RLPStream header;
- header.appendList(Ethash::BlockHeader::Fields);
- for (size_t i = 0; i < BlockInfo::BasicFields; i++)
- header << sourceRlp[i];
-
- header << _mixHash << _nonce;
- _header = Ethash::BlockHeader(header.out(), CheckNothing, h256{}, HeaderData);
-}
-
-namespace
-{
- Listener* g_listener;
-}
-
-void Listener::registerListener(Listener& _listener)
-{
- g_listener = &_listener;
-}
-
-void Listener::notifySuiteStarted(std::string const& _name)
-{
- if (g_listener)
- g_listener->suiteStarted(_name);
-}
-
-void Listener::notifyTestStarted(std::string const& _name)
-{
- if (g_listener)
- g_listener->testStarted(_name);
-}
-
-void Listener::notifyTestFinished()
-{
- if (g_listener)
- g_listener->testFinished();
-}
-
-} } // namespaces
diff --git a/test/TestHelper.h b/test/TestHelper.h
deleted file mode 100644
index 3e38bf99a..000000000
--- a/test/TestHelper.h
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- This file is part of cpp-ethereum.
-
- cpp-ethereum is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- cpp-ethereum is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with cpp-ethereum. If not, see .
-*/
-/** @file TestHelper.h
- * @author Marko Simovic
- * @date 2014
- */
-
-#pragma once
-
-#include
-#include
-#include
-
-#include "JsonSpiritHeaders.h"
-#include
-#include
-#include
-#include
-
-namespace dev
-{
-namespace eth
-{
-
-class Client;
-class State;
-
-void mine(Client& c, int numBlocks);
-void connectClients(Client& c1, Client& c2);
-void mine(Block& _s, BlockChain const& _bc);
-void mine(Ethash::BlockHeader& _bi);
-
-}
-
-namespace test
-{
-
-/// 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()
-/// @param _statenent The statement for which to make sure no exceptions are thrown
-/// @param _message A message to act as a prefix to the expression's error information
-#define ETH_TEST_REQUIRE_NO_THROW(_statement, _message) \
- 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)
-
-/// 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()
-/// @param _statement The statement for which to make sure no exceptions are thrown
-/// @param _message A message to act as a prefix to the expression's error information
-#define ETH_TEST_CHECK_NO_THROW(_statement, _message) \
- 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)
-
-enum class testType
-{
- StateTests,
- BlockChainTests,
- Other
-};
-
-class ImportTest
-{
-public:
- ImportTest(json_spirit::mObject& _o, bool isFiller, testType testTemplate = testType::StateTests);
-
- // imports
- void importEnv(json_spirit::mObject& _o);
- static void importState(json_spirit::mObject& _o, eth::State& _state);
- static void importState(json_spirit::mObject& _o, eth::State& _state, eth::AccountMaskMap& o_mask);
- static void importTransaction (json_spirit::mObject const& _o, eth::Transaction& o_tr);
- void importTransaction(json_spirit::mObject const& _o);
- static json_spirit::mObject& makeAllFieldsHex(json_spirit::mObject& _o);
-
- bytes executeTest();
- int exportTest(bytes const& _output);
- static int compareStates(eth::State const& _stateExpect, eth::State const& _statePost, eth::AccountMaskMap const _expectedStateOptions = eth::AccountMaskMap(), WhenError _throw = WhenError::Throw);
-
- eth::State m_statePre;
- eth::State m_statePost;
- eth::EnvInfo m_envInfo;
- eth::Transaction m_transaction;
- eth::LogEntries m_logs;
- eth::LogEntries m_logsExpected;
-
-private:
- json_spirit::mObject& m_testObject;
-};
-
-class ZeroGasPricer: public eth::GasPricer
-{
-protected:
- u256 ask(eth::Block const&) const override { return 0; }
- u256 bid(eth::TransactionPriority = eth::TransactionPriority::Medium) const override { return 0; }
-};
-
-// helping functions
-u256 toInt(json_spirit::mValue const& _v);
-byte toByte(json_spirit::mValue const& _v);
-bytes importCode(json_spirit::mObject& _o);
-bytes importData(json_spirit::mObject const& _o);
-bytes importByteArray(std::string const& _str);
-eth::LogEntries importLog(json_spirit::mArray& _o);
-json_spirit::mArray exportLog(eth::LogEntries _logs);
-void checkOutput(bytes const& _output, json_spirit::mObject& _o);
-void checkStorage(std::map _expectedStore, std::map _resultStore, Address _expectedAddr);
-void checkLog(eth::LogEntries _resultLogs, eth::LogEntries _expectedLogs);
-void checkCallCreates(eth::Transactions _resultCallCreates, eth::Transactions _expectedCallCreates);
-dev::eth::Ethash::BlockHeader constructHeader(
- h256 const& _parentHash,
- h256 const& _sha3Uncles,
- Address const& _coinbaseAddress,
- 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 updateEthashSeal(dev::eth::Ethash::BlockHeader& _header, h256 const& _mixHash, dev::eth::Nonce const& _nonce);
-void executeTests(const std::string& _name, const std::string& _testPathAppendix, const boost::filesystem::path _pathToFiller, std::function doTests);
-void userDefinedTest(std::function doTests);
-RLPStream createRLPStreamFromTransactionFields(json_spirit::mObject const& _tObj);
-eth::LastHashes lastHashes(u256 _currentBlockNumber);
-json_spirit::mObject fillJsonWithState(eth::State _state);
-json_spirit::mObject fillJsonWithTransaction(eth::Transaction _txn);
-
-//Fill Test Functions
-int createRandomTest(std::vector const& args);
-void doTransactionTests(json_spirit::mValue& _v, bool _fillin);
-void doStateTests(json_spirit::mValue& v, bool _fillin);
-void doVMTests(json_spirit::mValue& v, bool _fillin);
-void doBlockchainTests(json_spirit::mValue& _v, bool _fillin);
-void doRlpTests(json_spirit::mValue& v, bool _fillin);
-
-enum class Verbosity
-{
- Full,
- NiceReport,
- None
-};
-
-class Options
-{
-public:
- bool vmtrace = false; ///< Create EVM execution tracer // TODO: Link with log verbosity?
- bool fillTests = false; ///< Create JSON test files from execution results
- bool stats = false; ///< Execution time stats
- std::string statsOutFile; ///< Stats output file. "out" for standard output
- bool checkState = false;///< Throw error when checking test states
- bool fulloutput = false;///< Replace large output to just it's length
- bool createRandomTest = false; ///< Generate random test
- Verbosity logVerbosity = Verbosity::NiceReport;
-
- /// Test selection
- /// @{
- bool singleTest = false;
- std::string singleTestFile;
- std::string singleTestName;
- bool performance = false;
- bool quadratic = false;
- bool memory = false;
- bool inputLimits = false;
- bool bigData = false;
- bool wallet = false;
- bool nonetwork = true;
- bool nodag = true;
- /// @}
-
- /// Get reference to options
- /// The first time used, options are parsed
- static Options const& get();
-
-private:
- Options();
- Options(Options const&) = delete;
-};
-
-/// Allows observing test execution process.
-/// This class also provides methods for registering and notifying the listener
-class Listener
-{
-public:
- virtual ~Listener() = default;
-
- virtual void suiteStarted(std::string const&) {}
- virtual void testStarted(std::string const& _name) = 0;
- virtual void testFinished() = 0;
-
- static void registerListener(Listener& _listener);
- static void notifySuiteStarted(std::string const& _name);
- static void notifyTestStarted(std::string const& _name);
- static void notifyTestFinished();
-
- /// Test started/finished notification RAII helper
- class ExecTimeGuard
- {
- public:
- ExecTimeGuard(std::string const& _testName) { notifyTestStarted(_testName); }
- ~ExecTimeGuard() { notifyTestFinished(); }
- ExecTimeGuard(ExecTimeGuard const&) = delete;
- ExecTimeGuard& operator=(ExecTimeGuard) = delete;
- };
-};
-
-}
-}
diff --git a/test/TestUtils.cpp b/test/TestUtils.cpp
deleted file mode 100644
index 5e0619c0e..000000000
--- a/test/TestUtils.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- This file is part of cpp-ethereum.
-
- cpp-ethereum is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- cpp-ethereum is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with cpp-ethereum. If not, see .
- */
-/** @file TestUtils.cpp
- * @author Marek Kotewicz
- * @date 2015
- */
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include "TestUtils.h"
-
-using namespace std;
-using namespace dev;
-using namespace dev::eth;
-using namespace dev::test;
-
-namespace dev
-{
-namespace test
-{
-
-bool getCommandLineOption(std::string const& _name);
-std::string getCommandLineArgument(std::string const& _name, bool _require = false);
-
-}
-}
-
-bool dev::test::getCommandLineOption(string const& _name)
-{
- auto argc = boost::unit_test::framework::master_test_suite().argc;
- auto argv = boost::unit_test::framework::master_test_suite().argv;
- bool result = false;
- for (auto i = 0; !result && i < argc; ++i)
- result = _name == argv[i];
- return result;
-}
-
-std::string dev::test::getCommandLineArgument(string const& _name, bool _require)
-{
- auto argc = boost::unit_test::framework::master_test_suite().argc;
- auto argv = boost::unit_test::framework::master_test_suite().argv;
- for (auto i = 1; i < argc; ++i)
- {
- string str = argv[i];
- if (_name == str.substr(0, _name.size()))
- return str.substr(str.find("=") + 1);
- }
- if (_require)
- BOOST_ERROR("Failed getting command line argument: " << _name << " from: " << argv);
- return "";
-}
-
-LoadTestFileFixture::LoadTestFileFixture()
-{
- m_json = loadJsonFromFile(toTestFilePath(getCommandLineArgument("--eth_testfile")));
-}
-
-void ParallelFixture::enumerateThreads(std::function callback) const
-{
- size_t threadsCount = std::stoul(getCommandLineArgument("--eth_threads"), nullptr, 10);
-
- vector workers;
- for (size_t i = 0; i < threadsCount; i++)
- workers.emplace_back(callback);
-
- for_each(workers.begin(), workers.end(), [](thread &t)
- {
- t.join();
- });
-}
-
-void BlockChainFixture::enumerateBlockchains(std::function callback) const
-{
- for (string const& name: m_json.getMemberNames())
- {
- BlockChainLoader bcl(m_json[name]);
- callback(m_json[name], bcl.bc(), bcl.state());
- }
-}
-
-void ClientBaseFixture::enumerateClients(std::function callback) const
-{
- enumerateBlockchains([&callback](Json::Value const& _json, BlockChain const& _bc, State _state) -> void
- {
- cerr << "void ClientBaseFixture::enumerateClients. FixedClient now accepts block not sate!" << endl;
- _state.commit(); //unused variable. remove this line
- FixedClient client(_bc, eth::Block {});
- callback(_json, client);
- });
-}
-
-void ParallelClientBaseFixture::enumerateClients(std::function callback) const
-{
- ClientBaseFixture::enumerateClients([this, &callback](Json::Value const& _json, dev::eth::ClientBase& _client) -> void
- {
- // json is being copied here
- enumerateThreads([callback, _json, &_client]() -> void
- {
- callback(_json, _client);
- });
- });
-}
-
diff --git a/test/TestUtils.h b/test/TestUtils.h
deleted file mode 100644
index a7a0eacf0..000000000
--- a/test/TestUtils.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- This file is part of cpp-ethereum.
-
- cpp-ethereum is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- cpp-ethereum is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with cpp-ethereum. If not, see .
- */
-/** @file TestUtils.h
- * @author Marek Kotewicz
- * @date 2015
- */
-
-#pragma once
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-namespace dev
-{
-namespace test
-{
-
-// should be used for multithread tests
-static SharedMutex x_boostTest;
-#define ETH_CHECK_EQUAL(x, y) { dev::WriteGuard(x_boostTest); BOOST_CHECK_EQUAL(x, y); }
-#define ETH_CHECK_EQUAL_COLLECTIONS(xb, xe, yb, ye) { dev::WriteGuard(x_boostTest); BOOST_CHECK_EQUAL_COLLECTIONS(xb, xe, yb, ye); }
-#define ETH_REQUIRE(x) { dev::WriteGuard(x_boostTest); BOOST_REQUIRE(x); }
-
-struct LoadTestFileFixture
-{
- LoadTestFileFixture();
-
-protected:
- Json::Value m_json;
-};
-
-struct ParallelFixture
-{
- void enumerateThreads(std::function callback) const;
-};
-
-struct BlockChainFixture: public LoadTestFileFixture
-{
- void enumerateBlockchains(std::function callback) const;
-};
-
-struct ClientBaseFixture: public BlockChainFixture
-{
- void enumerateClients(std::function callback) const;
-};
-
-// important BOOST TEST do have problems with thread safety!!!
-// BOOST_CHECK is not thread safe
-// BOOST_MESSAGE is not thread safe
-// http://boost.2283326.n4.nabble.com/Is-boost-test-thread-safe-td3471644.html
-// http://lists.boost.org/boost-users/2010/03/57691.php
-// worth reading
-// https://codecrafter.wordpress.com/2012/11/01/c-unit-test-framework-adapter-part-3/
-struct ParallelClientBaseFixture: public ClientBaseFixture, public ParallelFixture
-{
- void enumerateClients(std::function callback) const;
-};
-
-struct JsonRpcFixture: public ClientBaseFixture
-{
-
-};
-
-}
-}
diff --git a/test/boostTest.cpp b/test/boostTest.cpp
deleted file mode 100644
index 7c2b06830..000000000
--- a/test/boostTest.cpp
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- This file is part of cpp-ethereum.
-
- cpp-ethereum is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- cpp-ethereum is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with cpp-ethereum. If not, see .
-*/
-/** @file boostTest.cpp
- * @author Dimitry Khokhlov
- * @date 2015
- * Stub for generating main boost.test module.
- * Original code taken from boost sources.
- */
-
-#define BOOST_TEST_MODULE EthereumTests
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-//#define BOOST_DISABLE_WIN32 //disables SEH warning
-#define BOOST_TEST_NO_MAIN
-#include
-#pragma GCC diagnostic pop
-#include
-
-using namespace boost::unit_test;
-
-std::vector originalArgs;
-static std::ostringstream strCout;
-std::streambuf* oldCoutStreamBuf;
-
-//Custom Boost Initialization
-test_suite* init_func(int argc, char* argv[])
-{
- //Required for boost. -nowarning
- (void) argc;
- (void) argv;
-
- //restore output for creating test
- std::cout.rdbuf(oldCoutStreamBuf);
- std::cerr.rdbuf(oldCoutStreamBuf);
- const auto& opt = dev::test::Options::get();
- if (opt.createRandomTest)
- {
- //For no reason BOOST tend to remove valuable arg -t "TestSuiteName", so using original parametrs instead
- if (dev::test::createRandomTest(originalArgs))
- throw framework::internal_error("Create Random Test Error!");
- else
- {
- //disable post output so the test json would be clean
- std::cout.rdbuf(strCout.rdbuf());
- std::cerr.rdbuf(strCout.rdbuf());
- throw framework::nothing_to_test();
- }
- }
- return 0;
-}
-
-//Custom Boost Unit Test Main
-int main( int argc, char* argv[] )
-{
- for (int i = 0; i < argc; i++)
- originalArgs.push_back(argv[i]);
-
- //disable initial output
- oldCoutStreamBuf = std::cout.rdbuf();
- std::cout.rdbuf(strCout.rdbuf());
- std::cerr.rdbuf(strCout.rdbuf());
-
- try
- {
- framework::init(init_func, argc, argv);
-
- if( !runtime_config::test_to_run().is_empty() )
- {
- test_case_filter filter(runtime_config::test_to_run());
-
- traverse_test_tree(framework::master_test_suite().p_id, filter);
- }
-
- framework::run();
-
- results_reporter::make_report();
-
- return runtime_config::no_result_code()
- ? boost::exit_success
- : results_collector.results(framework::master_test_suite().p_id).result_code();
- }
- catch (framework::nothing_to_test const&)
- {
- return boost::exit_success;
- }
- catch (framework::internal_error const& ex)
- {
- results_reporter::get_stream() << "Boost.Test framework internal error: " << ex.what() << std::endl;
-
- return boost::exit_exception_failure;
- }
- catch (framework::setup_error const& ex)
- {
- results_reporter::get_stream() << "Test setup error: " << ex.what() << std::endl;
-
- return boost::exit_exception_failure;
- }
- catch (...)
- {
- results_reporter::get_stream() << "Boost.Test framework internal error: unknown reason" << std::endl;
-
- return boost::exit_exception_failure;
- }
-}
diff --git a/test/deprecated/fork.cpp b/test/deprecated/fork.cpp
deleted file mode 100644
index a2eb6f4eb..000000000
--- a/test/deprecated/fork.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- This file is part of cpp-ethereum.
-
- cpp-ethereum is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- cpp-ethereum is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with cpp-ethereum. If not, see .
-*/
-/** @file fork.cpp
- * @author Marko Simovic
- * @date 2014
- * Tests for different forking behavior
- */
-
-#include
-#include
-
-#include
-#include
-#include
-#include "TestHelper.h"
-using namespace std;
-using namespace dev;
-using namespace dev::eth;
-
-// Disabled since tests shouldn't block. Need a short cut to avoid real mining.
-/*
-BOOST_AUTO_TEST_CASE(simple_chain_fork)
-{
- //start a client and mine a short chain
- Client c1("TestClient1", KeyPair::create().address(),
- (boost::filesystem::temp_directory_path() / boost::filesystem::unique_path()).string());
- mine(c1, 4);
-
- //start another client and mine a longer chain
- Client c2("TestClient2", KeyPair::create().address(),
- (boost::filesystem::temp_directory_path() / boost::filesystem::unique_path()).string());
- mine(c2, 6);
-
- //connect the two clients up to resolve chain
- c1.startNetwork(20000);
- c2.startNetwork(21000);
- c2.connect("127.0.0.1", 20000);
-
- //mine an extra block to cement it
- mine(c1, 1);
-
- //check the balances are where they should be
- //c1's chain should have been clobbered by c2
- BOOST_REQUIRE(c1.state().balance(c1.address()) == 0);
- BOOST_REQUIRE(c2.state().balance(c2.address()) > 0);
-}
-*/
diff --git a/test/deprecated/kademlia.cpp b/test/deprecated/kademlia.cpp
deleted file mode 100644
index a9d7701cf..000000000
--- a/test/deprecated/kademlia.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- This file is part of cpp-ethereum.
-
- cpp-ethereum is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- cpp-ethereum is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with cpp-ethereum. If not, see .
-*/
-/** @file kademlia.cpp
- * @author Alex Leverington
- * @date 2014
- */
-
diff --git a/test/deprecated/main.cpp b/test/deprecated/main.cpp
deleted file mode 100644
index 47e96f337..000000000
--- a/test/deprecated/main.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- This file is part of cpp-ethereum.
-
- cpp-ethereum is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- cpp-ethereum is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with cpp-ethereum. If not, see .
-*/
-/** @file main.cpp
- * @author Gav Wood
- * @date 2014
- * Main test functions.
- */
-
-#include
-
-int trieTest();
-int rlpTest();
-int daggerTest();
-int cryptoTest();
-int stateTest();
-int vmTest();
-int hexPrefixTest();
-int peerTest(int argc, char** argv);
-
-#include
-#include
-using namespace std;
-using namespace dev;
-using namespace dev::eth;
-
-//BOOST_AUTO_TEST_CASE(basic_tests)
-//{
-/* RLPStream s;
- BlockInfo::genesis().streamRLP(s, false);
- std::cout << RLP(s.out()) << std::endl;
- std::cout << toHex(s.out()) << std::endl;
- std::cout << sha3(s.out()) << std::endl;*/
-
-// int r = 0;
-// r += daggerTest();
-// r += stateTest();
-// r += peerTest(argc, argv);
-// BOOST_REQUIRE(!r);
-//}
-
diff --git a/test/deprecated/txTest.cpp b/test/deprecated/txTest.cpp
deleted file mode 100644
index a70a68f01..000000000
--- a/test/deprecated/txTest.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- This file is part of cpp-ethereum.
-
- cpp-ethereum is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- cpp-ethereum is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with cpp-ethereum. If not, see .
-*/
-/** @file txTest.cpp
- * @author Marko Simovic
- * @date 2014
- * Simple peer transaction send test.
- */
-
-#include
-#include
-
-#include
-#include
-#include
-#include "TestHelper.h"
-using namespace std;
-using namespace dev;
-using namespace dev::eth;
-
-// Disabled since tests shouldn't block. Need a short cut to avoid real mining.
-/*
-BOOST_AUTO_TEST_CASE(mine_local_simple_tx)
-{
- KeyPair kp1 = KeyPair::create();
- KeyPair kp2 = KeyPair::create();
-
- Client c1("TestClient1", kp1.address(), (boost::filesystem::temp_directory_path() / boost::filesystem::unique_path()).string());
-
- //mine some blocks so that client 1 has a balance
- mine(c1, 1);
- auto c1bal = c1.state().balance(kp1.address());
- BOOST_REQUIRE(c1bal > 0);
-
- //send c2 some eth from c1
- auto txAmount = c1bal / 2u;
- auto gasPrice = 10 * szabo;
- auto gas = dev::eth::c_callGas;
- c1.submitTransaction(kp1.secret(), txAmount, kp2.address(), bytes(), gas, gasPrice);
-
- //mine some more to include the transaction on chain
- mine(c1, 1);
- auto c2bal = c1.state().balance(kp2.address());
- BOOST_REQUIRE(c2bal > 0);
- BOOST_REQUIRE(c2bal == txAmount);
-}
-
-BOOST_AUTO_TEST_CASE(mine_and_send_to_peer)
-{
- KeyPair kp1 = KeyPair::create();
- KeyPair kp2 = KeyPair::create();
-
- Client c1("TestClient1", kp1.address(), (boost::filesystem::temp_directory_path() / boost::filesystem::unique_path()).string());
- Client c2("TestClient2", kp2.address(), (boost::filesystem::temp_directory_path() / boost::filesystem::unique_path()).string());
-
- connectClients(c1, c2);
-
- //mine some blocks so that client 1 has a balance
- mine(c1, 1);
- auto c1bal = c1.state().balance(kp1.address());
- BOOST_REQUIRE(c1bal > 0);
-
- //send c2 some eth from c1
- auto txAmount = c1bal / 2u;
- auto gasPrice = 10 * szabo;
- auto gas = dev::eth::c_callGas;
- c1.submitTransaction(kp1.secret(), txAmount, kp2.address(), bytes(), gas, gasPrice);
-
- //mine some more to include the transaction on chain
- mine(c1, 1);
- auto c2bal = c2.state().balance(kp2.address());
- BOOST_REQUIRE(c2bal > 0);
- BOOST_REQUIRE(c2bal == txAmount);
-}
-
-BOOST_AUTO_TEST_CASE(mine_and_send_to_peer_fee_check)
-{
- KeyPair kp1 = KeyPair::create();
- KeyPair kp2 = KeyPair::create();
-
- Client c1("TestClient1", kp1.address(), (boost::filesystem::temp_directory_path() / boost::filesystem::unique_path()).string());
- Client c2("TestClient2", kp2.address(), (boost::filesystem::temp_directory_path() / boost::filesystem::unique_path()).string());
-
- connectClients(c1, c2);
-
- //mine some blocks so that client 1 has a balance
- mine(c1, 1);
-
- auto c1StartBalance = c1.state().balance(kp1.address());
- auto c2StartBalance = c2.state().balance(kp2.address());
- BOOST_REQUIRE(c1StartBalance > 0);
- BOOST_REQUIRE(c2StartBalance == 0);
-
- //send c2 some eth from c1
- auto txAmount = c1StartBalance / 2u;
- auto gasPrice = 10 * szabo;
- auto gas = dev::eth::c_callGas;
- c1.submitTransaction(kp1.secret(), txAmount, c2.address(), bytes(), gas, gasPrice);
-
- //mine some more, this time with second client (so he can get fees from first client's tx)
- mine(c2, 1);
-
- auto c1EndBalance = c1.state().balance(kp1.address());
- auto c2EndBalance = c2.state().balance(kp2.address());
- BOOST_REQUIRE(c1EndBalance > 0);
- BOOST_REQUIRE(c1EndBalance == c1StartBalance - txAmount - gasPrice * gas);
- BOOST_REQUIRE(c2EndBalance > 0);
-}
-*/
diff --git a/test/external-dependencies/CMakeLists.txt b/test/external-dependencies/CMakeLists.txt
deleted file mode 100644
index 3ceda13b0..000000000
--- a/test/external-dependencies/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-cmake_policy(SET CMP0015 NEW)
-
-aux_source_directory(. SRCS)
-
-add_sources(${SRCS})
diff --git a/test/external-dependencies/boost.cpp b/test/external-dependencies/boost.cpp
deleted file mode 100644
index 91bf384b1..000000000
--- a/test/external-dependencies/boost.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- This file is part of cpp-ethereum.
-
- cpp-ethereum is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- cpp-ethereum is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with cpp-ethereum. If not, see .
-*/
-/** @file boost.cpp
- * @author Lefteris Karapetsas
- * @date 2015
- * Tests for external dependencies: Boost
- */
-
-#include
-#include
-
-BOOST_AUTO_TEST_SUITE(ExtDepBoost)
-
-// test that reproduces issue https://github.com/ethereum/cpp-ethereum/issues/1977
-BOOST_AUTO_TEST_CASE(u256_overflow_test)
-{
- dev::u256 a = 14;
- dev::bigint b = dev::bigint("115792089237316195423570985008687907853269984665640564039457584007913129639948");
- // to fix cast `a` to dev::bigint
- BOOST_CHECK(a < b);
-}
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/test/fuzzTesting/CMakeLists.txt b/test/fuzzTesting/CMakeLists.txt
deleted file mode 100644
index 3ceda13b0..000000000
--- a/test/fuzzTesting/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-cmake_policy(SET CMP0015 NEW)
-
-aux_source_directory(. SRCS)
-
-add_sources(${SRCS})
diff --git a/test/fuzzTesting/createRandomTest.cpp b/test/fuzzTesting/createRandomTest.cpp
deleted file mode 100644
index 373df595f..000000000
--- a/test/fuzzTesting/createRandomTest.cpp
+++ /dev/null
@@ -1,463 +0,0 @@
-/*
- This file is part of cpp-ethereum.
-
- cpp-ethereum is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- cpp-ethereum is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with cpp-ethereum. If not, see .
-*/
-/** @file createRandomTest.cpp
- * @author Dimitry Khokhlov
- * @date 2015
- */
-
-#include
-#include
-
-#include
-#include
-#include
-#include
-
-//String Variables
-extern std::string const c_testExampleStateTest;
-extern std::string const c_testExampleTransactionTest;
-extern std::string const c_testExampleVMTest;
-extern std::string const c_testExampleBlockchainTest;
-extern std::string const c_testExampleRLPTest;
-
-//Main Test functinos
-void fillRandomTest(std::function _doTests, std::string const& _testString, bool _debug = false);
-int checkRandomTest(std::function _doTests, json_spirit::mValue& _value, bool _debug = false);
-
-//Helper Functions
-std::vector getTypes();
-void parseTestWithTypes(std::string& test);
-
-namespace dev { namespace test {
-int createRandomTest(std::vector const& args)
-{
- std::string testSuite;
- std::string testFillString;
- json_spirit::mValue testmValue;
- bool checktest = false;
- bool filldebug = false;
- bool debug = false;
- bool filltest = false;
-
- for (unsigned i = 0; i < args.size(); ++i)
- {
- auto arg = std::string{args.at(i)};
- dev::test::Options& options = const_cast(dev::test::Options::get());
- if (arg == "--fulloutput")
- options.fulloutput = true;
- else
- if (arg == "-t" && i + 1 < args.size())
- {
- testSuite = args.at(i+1);
- if (testSuite != "BlockChainTests" && testSuite != "TransactionTests" && testSuite != "StateTests"
- && testSuite != "VMTests" && testSuite != "RLPTests")
- testSuite = "";
- }
- else
- if ((arg == "-checktest" || arg == "-filltest") && i + 1 < args.size())
- {
- std::string s;
- for (unsigned j = i+1; j < args.size(); ++j)
- s += args.at(j);
- if (asserts(s.length() > 0))
- {
- std::cerr << "Error! Content of argument is empty! (Usage -checktest textstream)" << std::endl;
- return 1;
- }
- if (arg == "-filltest")
- {
- testFillString = s;
- filltest = true;
- }
- else
- {
- read_string(s, testmValue);
- checktest = true;
- }
- }
- else
- if (arg == "--debug")
- debug = true;
- else
- if (arg == "--filldebug")
- filldebug = true;
- }
-
- if (testSuite == "")
- {
- std::cerr << "Error! Test suite not supported! (Usage -t TestSuite)" << std::endl;
- return 1;
- }
- else
- {
- if (checktest)
- std::cout << "Testing: " << testSuite.substr(0, testSuite.length() - 1) << std::endl;
-
- if (testSuite == "BlockChainTests")
- {
- if (checktest)
- return checkRandomTest(dev::test::doBlockchainTests, testmValue, debug);
- else
- fillRandomTest(dev::test::doBlockchainTests, (filltest) ? testFillString : c_testExampleBlockchainTest, filldebug);
- }
- else
- if (testSuite == "TransactionTests")
- {
- if (checktest)
- return checkRandomTest(dev::test::doTransactionTests, testmValue, debug);
- else
- fillRandomTest(dev::test::doTransactionTests, (filltest) ? testFillString : c_testExampleTransactionTest, filldebug);
- }
- else
- if (testSuite == "StateTests")
- {
- if (checktest)
- return checkRandomTest(dev::test::doStateTests, testmValue, debug);
- else
- fillRandomTest(dev::test::doStateTests, (filltest) ? testFillString : c_testExampleStateTest, filldebug);
- }
- else
- if (testSuite == "VMTests")
- {
- if (checktest)
- {
- dev::eth::VMFactory::setKind(dev::eth::VMKind::JIT);
- return checkRandomTest(dev::test::doVMTests, testmValue, debug);
- }
- else
- fillRandomTest(dev::test::doVMTests, (filltest) ? testFillString : c_testExampleVMTest, filldebug);
- }
- else
- if (testSuite == "RLPTests")
- {
- if (checktest)
- return checkRandomTest(dev::test::doRlpTests, testmValue, debug);
- else
- fillRandomTest(dev::test::doRlpTests, (filltest) ? testFillString : c_testExampleRLPTest, filldebug);
- }
- }
-
- return 0;
-}
-}} //namespaces
-
-int checkRandomTest(std::function _doTests, json_spirit::mValue& _value, bool _debug)
-{
- bool ret = 0;
- try
- {
- //redirect all output to the stream
- std::ostringstream strCout;
- std::streambuf* oldCoutStreamBuf = std::cout.rdbuf();
- if (!_debug)
- {
- std::cout.rdbuf( strCout.rdbuf() );
- std::cerr.rdbuf( strCout.rdbuf() );
- }
-
- _doTests(_value, false);
-
- //restroe output
- if (!_debug)
- {
- std::cout.rdbuf(oldCoutStreamBuf);
- std::cerr.rdbuf(oldCoutStreamBuf);
- }
- }
- catch (dev::Exception const& _e)
- {
- std::cout << "Failed test with Exception: " << diagnostic_information(_e) << std::endl;
- ret = 1;
- }
- catch (std::exception const& _e)
- {
- std::cout << "Failed test with Exception: " << _e.what() << std::endl;
- ret = 1;
- }
- return ret;
-}
-
-void fillRandomTest(std::function _doTests, std::string const& _testString, bool _debug)
-{
- //redirect all output to the stream
- std::ostringstream strCout;
- std::streambuf* oldCoutStreamBuf = std::cout.rdbuf();
- if (!_debug)
- {
- std::cout.rdbuf( strCout.rdbuf() );
- std::cerr.rdbuf( strCout.rdbuf() );
- }
-
- json_spirit::mValue v;
- try
- {
- std::string newTest = _testString;
- parseTestWithTypes(newTest);
- json_spirit::read_string(newTest, v);
- _doTests(v, true);
- }
- catch(...)
- {
- std::cerr << "Test fill exception!";
- }
-
- //restroe output
- if (!_debug)
- {
- std::cout.rdbuf(oldCoutStreamBuf);
- std::cerr.rdbuf(oldCoutStreamBuf);
- }
- std::cout << json_spirit::write_string(v, true);
-}
-
-/// Parse Test string replacing keywords to fuzzed values
-void parseTestWithTypes(std::string& _test)
-{
- dev::test::RandomCodeOptions options;
- options.setWeight(dev::eth::Instruction::STOP, 10); //default 50
- options.setWeight(dev::eth::Instruction::SSTORE, 70);
- options.setWeight(dev::eth::Instruction::CALL, 75);
- options.setWeight(dev::eth::Instruction::CALLCODE, 55);
- options.addAddress(dev::Address("0xffffffffffffffffffffffffffffffffffffffff"));
- options.addAddress(dev::Address("0x1000000000000000000000000000000000000000"));
- options.addAddress(dev::Address("0x095e7baea6a6c7c4c2dfeb977efac326af552d87"));
- options.addAddress(dev::Address("0x945304eb96065b2a98b57a48a06ae28d285a71b5"));
- options.addAddress(dev::Address("0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b"));
- options.addAddress(dev::Address("0x0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6"));
- options.addAddress(dev::Address("0x0000000000000000000000000000000000000001"));
- options.addAddress(dev::Address("0x0000000000000000000000000000000000000002"));
- options.addAddress(dev::Address("0x0000000000000000000000000000000000000003"));
- options.addAddress(dev::Address("0x0000000000000000000000000000000000000004"));
- options.smartCodeProbability = 60;
-
- std::vector types = getTypes();
- for (unsigned i = 0; i < types.size(); i++)
- {
- std::size_t pos = _test.find(types.at(i));
- while (pos != std::string::npos)
- {
- if (types.at(i) == "[RLP]")
- {
- std::string debug;
- int randomDepth = 1 + dev::test::RandomCode::randomUniInt() % 10;
- _test.replace(pos, 5, dev::test::RandomCode::rndRLPSequence(randomDepth, debug));
- cnote << debug;
- }
- else
- if (types.at(i) == "[CODE]")
- _test.replace(pos, 6, "0x"+dev::test::RandomCode::generate(10, options));
- else
- if (types.at(i) == "[HEX]")
- _test.replace(pos, 5, dev::test::RandomCode::randomUniIntHex());
- else
- if (types.at(i) == "[HEX32]")
- _test.replace(pos, 7, dev::test::RandomCode::randomUniIntHex(std::numeric_limits::max()));
- else
- if (types.at(i) == "[GASLIMIT]")
- _test.replace(pos, 10, dev::test::RandomCode::randomUniIntHex(dev::u256("3000000000")));
- else
- if (types.at(i) == "[HASH20]")
- _test.replace(pos, 8, dev::test::RandomCode::rndByteSequence(20));
- else
- if (types.at(i) == "[0xHASH32]")
- _test.replace(pos, 10, "0x" + dev::test::RandomCode::rndByteSequence(32));
- else
- if (types.at(i) == "[HASH32]")
- _test.replace(pos, 8, dev::test::RandomCode::rndByteSequence(32));
- else
- if (types.at(i) == "[V]")
- {
- int random = dev::test::RandomCode::randomUniInt() % 100;
- if (random < 30)
- _test.replace(pos, 3, "0x1c");
- else
- if (random < 60)
- _test.replace(pos, 3, "0x1d");
- else
- _test.replace(pos, 3, "0x" + dev::test::RandomCode::rndByteSequence(1));
- }
-
- pos = _test.find(types.at(i));
- }
- }
-}
-
-std::vector getTypes()
-{
- return {"[RLP]", "[CODE]", "[HEX]", "[HEX32]", "[HASH20]", "[HASH32]", "[0xHASH32]", "[V]", "[GASLIMIT]"};
-}
-
-std::string const c_testExampleTransactionTest = R"(
-{
- "randomTransactionTest" : {
- "transaction" :
- {
- "data" : "[CODE]",
- "gasLimit" : "[HEX]",
- "gasPrice" : "[HEX]",
- "nonce" : "[HEX]",
- "to" : "[HASH20]",
- "value" : "[HEX]",
- "v" : "[V]",
- "r" : "[0xHASH32]",
- "s" : "[0xHASH32]"
- }
- }
-}
-)";
-
-std::string const c_testExampleStateTest = R"(
-{
- "randomStatetest" : {
- "env" : {
- "currentCoinbase" : "[HASH20]",
- "currentDifficulty" : "[HEX]",
- "currentGasLimit" : "[GASLIMIT]",
- "currentNumber" : "[HEX32]",
- "currentTimestamp" : "[HEX]",
- "previousHash" : "[HASH32]"
- },
- "pre" : {
- "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
- "balance" : "[HEX]",
- "code" : "[CODE]",
- "nonce" : "[V]",
- "storage" : {
- }
- },
- "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
- "balance" : "[HEX]",
- "code" : "[CODE]",
- "nonce" : "[V]",
- "storage" : {
- }
- },
- "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
- "balance" : "[HEX]",
- "code" : "0x",
- "nonce" : "0",
- "storage" : {
- }
- }
- },
- "transaction" : {
- "data" : "[CODE]",
- "gasLimit" : "[HEX]",
- "gasPrice" : "[HEX32]",
- "nonce" : "0",
- "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
- "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
- "value" : "[HEX]"
- }
- }
-}
-)";
-
-std::string const c_testExampleVMTest = R"(
-{
- "randomVMTest": {
- "env" : {
- "previousHash" : "[HASH32]",
- "currentNumber" : "[HEX]",
- "currentGasLimit" : "[GASLIMIT]",
- "currentDifficulty" : "[HEX]",
- "currentTimestamp" : "[HEX]",
- "currentCoinbase" : "[HASH20]"
- },
- "pre" : {
- "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
- "balance" : "[HEX]",
- "nonce" : "[HEX]",
- "code" : "[CODE]",
- "storage": {}
- }
- },
- "exec" : {
- "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
- "origin" : "[HASH20]",
- "caller" : "[HASH20]",
- "value" : "[HEX]",
- "data" : "[CODE]",
- "gasPrice" : "[V]",
- "gas" : "[HEX]"
- }
- }
-}
-)";
-
-std::string const c_testExampleRLPTest = R"(
-{
- "randomRLPTest" : {
- "out" : "[RLP]"
- }
-}
-)";
-
-std::string const c_testExampleBlockchainTest = R"(
-{
- "randomBlockTest" : {
- "genesisBlockHeader" : {
- "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
- "coinbase" : "[HASH20]",
- "difficulty" : "131072",
- "extraData" : "[CODE]",
- "gasLimit" : "3141592",
- "gasUsed" : "0",
- "mixHash" : "[0xHASH32]",
- "nonce" : "0x0102030405060708",
- "number" : "0",
- "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
- "receiptTrie" : "[0xHASH32]",
- "stateRoot" : "[0xHASH32]",
- "timestamp" : "[HEX]",
- "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
- "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
- },
- "pre" : {
- "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
- "balance" : "[HEX]",
- "nonce" : "0",
- "code" : "",
- "storage": {}
- },
- "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
- "balance" : "[HEX]",
- "nonce" : "0",
- "code" : "[CODE]",
- "storage": {}
- }
- },
- "blocks" : [
- {
- "transactions" : [
- {
- "data" : "[CODE]",
- "gasLimit" : "[HEX]",
- "gasPrice" : "[V]",
- "nonce" : "0",
- "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
- "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
- "value" : "[V]"
- }
- ],
- "uncleHeaders" : [
- ]
- }
- ]
- }
-}
-)";
diff --git a/test/fuzzTesting/fuzzHelper.cpp b/test/fuzzTesting/fuzzHelper.cpp
deleted file mode 100644
index 63fad5a46..000000000
--- a/test/fuzzTesting/fuzzHelper.cpp
+++ /dev/null
@@ -1,425 +0,0 @@
-/*
- This file is part of cpp-ethereum.
-
- cpp-ethereum is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- cpp-ethereum is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with cpp-ethereum. If not, see .
-*/
-/** @file fuzzHelper.cpp
- * @author Dimitry Khokhlov
- * @date 2015
- */
-
-#include "fuzzHelper.h"
-
-#include
-#include
-#include
-#include
-
-namespace dev
-{
-namespace test
-{
-
-boost::random::mt19937 RandomCode::gen;
-boostIntDistrib RandomCode::opCodeDist = boostIntDistrib (0, 255);
-boostIntDistrib RandomCode::opLengDist = boostIntDistrib (1, 32);
-boostIntDistrib RandomCode::uniIntDist = boostIntDistrib (0, 0x7fffffff);
-boostUint64Distrib RandomCode::uInt64Dist = boostUint64Distrib (0, std::numeric_limits::max());
-
-boostIntGenerator RandomCode::randOpCodeGen = boostIntGenerator(gen, opCodeDist);
-boostIntGenerator RandomCode::randOpLengGen = boostIntGenerator(gen, opLengDist);
-boostIntGenerator RandomCode::randUniIntGen = boostIntGenerator(gen, uniIntDist);
-boostUInt64Generator RandomCode::randUInt64Gen = boostUInt64Generator(gen, uInt64Dist);
-
-int RandomCode::recursiveRLP(std::string& _result, int _depth, std::string& _debug)
-{
- bool genValidRlp = true;
- int bugProbability = randUniIntGen() % 100;
- if (bugProbability < 80)
- genValidRlp = false;
-
- if (_depth > 1)
- {
- //create rlp blocks
- int size = 1 + randUniIntGen() % 4;
- for (auto i = 0; i < size; i++)
- {
- std::string blockstr;
- std::string blockDebug;
- recursiveRLP(blockstr, _depth - 1, blockDebug);
- _result += blockstr;
- _debug += blockDebug;
- }
-
- //make rlp header
- int length = _result.size() / 2;
- std::string header;
- int rtype = 0;
- int rnd = randUniIntGen() % 100;
- if (rnd < 10)
- {
- //make header as array
- if (length <= 55)
- {
- header = toCompactHex(128 + length);
- rtype = 1;
- }
- else
- {
- std::string hexlength = toCompactHex(length);
- header = toCompactHex(183 + hexlength.size() / 2) + hexlength;
- rtype = 2;
- }
- }
- else
- {
- //make header as list
- if (length <= 55)
- {
- header = toCompactHex(192 + length);
- rtype = 3;
- }
- else
- {
- std::string hexlength = toCompactHex(length, HexPrefix::DontAdd, 1);
- header = toCompactHex(247 + hexlength.size() / 2) + hexlength;
- rtype = 4;
- }
- }
- _result = header + _result;
- _debug = "[" + header + "(" + toString(length) + "){" + toString(rtype) + "}]" + _debug;
- return _result.size() / 2;
- }
- if (_depth == 1)
- {
- bool genbug = false;
- bool genbug2 = false;
- int bugProbability = randUniIntGen() % 100;
- if (bugProbability < 50 && !genValidRlp)
- genbug = true;
- bugProbability = randUniIntGen() % 100; //more randomness
- if (bugProbability < 50 && !genValidRlp)
- genbug2 = true;
-
- std::string emptyZeros = genValidRlp ? "" : genbug ? "00" : "";
- std::string emptyZeros2 = genValidRlp ? "" : genbug2 ? "00" : "";
-
- int rnd = randUniIntGen() % 5;
- switch (rnd)
- {
- case 0:
- {
- //single byte [0x00, 0x7f]
- std::string rlp = emptyZeros + toCompactHex(genbug ? randUniIntGen() % 255 : randUniIntGen() % 128, HexPrefix::DontAdd, 1);
- _result.insert(0, rlp);
- _debug.insert(0, "[" + rlp + "]");
- return 1;
- }
- case 1:
- {
- //string 0-55 [0x80, 0xb7] + string
- int len = genbug ? randUniIntGen() % 255 : randUniIntGen() % 55;
- std::string hex = rndByteSequence(len);
- if (len == 1)
- if (genValidRlp && fromHex(hex)[0] < 128)
- hex = toCompactHex((u64)128);
-
- _result.insert(0, toCompactHex(128 + len) + emptyZeros + hex);
- _debug.insert(0, "[" + toCompactHex(128 + len) + "(" + toString(len) + ")]" + emptyZeros + hex);
- return len + 1;
- }
- case 2:
- {
- //string more 55 [0xb8, 0xbf] + length + string
- int len = randUniIntGen() % 100;
- if (len < 56 && genValidRlp)
- len = 56;
-
- std::string hex = rndByteSequence(len);
- std::string hexlen = emptyZeros2 + toCompactHex(len, HexPrefix::DontAdd, 1);
- std::string rlpblock = toCompactHex(183 + hexlen.size() / 2) + hexlen + emptyZeros + hex;
- _debug.insert(0, "[" + toCompactHex(183 + hexlen.size() / 2) + hexlen + "(" + toString(len) + "){2}]" + emptyZeros + hex);
- _result.insert(0, rlpblock);
- return rlpblock.size() / 2;
- }
- case 3:
- {
- //list 0-55 [0xc0, 0xf7] + data
- int len = genbug ? randUniIntGen() % 255 : randUniIntGen() % 55;
- std::string hex = emptyZeros + rndByteSequence(len);
- _result.insert(0, toCompactHex(192 + len) + hex);
- _debug.insert(0, "[" + toCompactHex(192 + len) + "(" + toString(len) + "){3}]" + hex);
- return len + 1;
- }
- case 4:
- {
- //list more 55 [0xf8, 0xff] + length + data
- int len = randUniIntGen() % 100;
- if (len < 56 && genValidRlp)
- len = 56;
- std::string hexlen = emptyZeros2 + toCompactHex(len, HexPrefix::DontAdd, 1);
- std::string rlpblock = toCompactHex(247 + hexlen.size() / 2) + hexlen + emptyZeros + rndByteSequence(len);
- _debug.insert(0, "[" + toCompactHex(247 + hexlen.size() / 2) + hexlen + "(" + toString(len) + "){4}]" + emptyZeros + rndByteSequence(len));
- _result.insert(0, rlpblock);
- return rlpblock.size() / 2;
- }
- }
- }
- return 0;
-}
-
-std::string RandomCode::rndRLPSequence(int _depth, std::string& _debug)
-{
- refreshSeed();
- std::string hash;
- _depth = std::min(std::max(1, _depth), 7); //limit depth to avoid overkill
- recursiveRLP(hash, _depth, _debug);
- return hash;
-}
-
-std::string RandomCode::rndByteSequence(int _length, SizeStrictness _sizeType)
-{
- refreshSeed();
- std::string hash = "";
- _length = (_sizeType == SizeStrictness::Strict) ? std::max(0, _length) : randomUniInt() % _length;
- for (auto i = 0; i < _length; i++)
- {
- uint8_t byte = randOpCodeGen();
- hash += toCompactHex(byte, HexPrefix::DontAdd, 1);
- }
- return hash;
-}
-
-//generate smart random code
-std::string RandomCode::generate(int _maxOpNumber, RandomCodeOptions _options)
-{
- refreshSeed();
- std::string code;
-
- //random opCode amount
- boostIntDistrib sizeDist (0, _maxOpNumber);
- boostIntGenerator rndSizeGen(gen, sizeDist);
- int size = (int)rndSizeGen();
-
- boostWeightGenerator randOpCodeWeight (gen, _options.opCodeProbability);
- bool weightsDefined = _options.opCodeProbability.probabilities().size() == 255;
-
- for (auto i = 0; i < size; i++)
- {
- uint8_t opcode = weightsDefined ? randOpCodeWeight() : randOpCodeGen();
- dev::eth::InstructionInfo info = dev::eth::instructionInfo((dev::eth::Instruction) opcode);
-
- if (info.name.find("INVALID_INSTRUCTION") != std::string::npos)
- {
- //Byte code is yet not implemented
- if (_options.useUndefinedOpCodes == false)
- {
- i--;
- continue;
- }
- }
- else
- {
- if (info.name.find("PUSH") != std::string::npos)
- code += toCompactHex(opcode);
- code += fillArguments((dev::eth::Instruction) opcode, _options);
- }
-
- if (info.name.find("PUSH") == std::string::npos)
- {
- std::string byte = toCompactHex(opcode);
- code += (byte == "") ? "00" : byte;
- }
- }
- return code;
-}
-
-std::string RandomCode::randomUniIntHex(u256 _maxVal)
-{
- if (_maxVal == 0)
- _maxVal = std::numeric_limits::max();
- refreshSeed();
- int rand = randUniIntGen() % 100;
- if (rand < 50)
- return "0x" + toCompactHex((u256)randUniIntGen() % _maxVal);
- return "0x" + toCompactHex((u256)randUInt64Gen() % _maxVal);
-}
-
-int RandomCode::randomUniInt()
-{
- refreshSeed();
- return (int)randUniIntGen();
-}
-
-void RandomCode::refreshSeed()
-{
- auto now = std::chrono::steady_clock::now().time_since_epoch();
- auto timeSinceEpoch = std::chrono::duration_cast(now).count();
- gen.seed(static_cast(timeSinceEpoch));
-}
-
-std::string RandomCode::getPushCode(std::string const& _hex)
-{
- int length = _hex.length() / 2;
- int pushCode = 96 + length - 1;
- return toCompactHex(pushCode) + _hex;
-}
-
-std::string RandomCode::getPushCode(int _value)
-{
- std::string hexString = toCompactHex(_value);
- return getPushCode(hexString);
-}
-
-std::string RandomCode::fillArguments(dev::eth::Instruction _opcode, RandomCodeOptions const& _options)
-{
- dev::eth::InstructionInfo info = dev::eth::instructionInfo(_opcode);
-
- std::string code;
- bool smart = false;
- unsigned num = info.args;
- int rand = randUniIntGen() % 100;
- if (rand < _options.smartCodeProbability)
- smart = true;
-
- if (smart)
- {
- //PUSH1 ... PUSH32
- if (dev::eth::Instruction::PUSH1 <= _opcode && _opcode <= dev::eth::Instruction::PUSH32)
- {
- code += rndByteSequence(int(_opcode) - int(dev::eth::Instruction::PUSH1) + 1);
- return code;
- }
-
- //SWAP1 ... SWAP16 || DUP1 ... DUP16
- bool isSWAP = (dev::eth::Instruction::SWAP1 <= _opcode && _opcode <= dev::eth::Instruction::SWAP16);
- bool isDUP = (dev::eth::Instruction::DUP1 <= _opcode && _opcode <= dev::eth::Instruction::DUP16);
-
- if (isSWAP || isDUP)
- {
- int times = 0;
- if (isSWAP)
- times = int(_opcode) - int(dev::eth::Instruction::SWAP1) + 2;
- else
- if (isDUP)
- times = int(_opcode) - int(dev::eth::Instruction::DUP1) + 1;
-
- for (int i = 0; i < times; i ++)
- code += getPushCode(randUniIntGen() % 32);
-
- return code;
- }
-
- switch (_opcode)
- {
- case dev::eth::Instruction::CREATE:
- //(CREATE value mem1 mem2)
- code += getPushCode(randUniIntGen() % 128); //memlen1
- code += getPushCode(randUniIntGen() % 32); //memlen1
- code += getPushCode(randUniIntGen()); //value
- break;
- case dev::eth::Instruction::CALL:
- case dev::eth::Instruction::CALLCODE:
- //(CALL gaslimit address value memstart1 memlen1 memstart2 memlen2)
- //(CALLCODE gaslimit address value memstart1 memlen1 memstart2 memlen2)
- code += getPushCode(randUniIntGen() % 128); //memlen2
- code += getPushCode(randUniIntGen() % 32); //memstart2
- code += getPushCode(randUniIntGen() % 128); //memlen1
- code += getPushCode(randUniIntGen() % 32); //memlen1
- code += getPushCode(randUniIntGen()); //value
- code += getPushCode(toString(_options.getRandomAddress()));//address
- code += getPushCode(randUniIntGen()); //gaslimit
- break;
- case dev::eth::Instruction::SUICIDE: //(SUICIDE address)
- code += getPushCode(toString(_options.getRandomAddress()));
- break;
- case dev::eth::Instruction::RETURN: //(RETURN memlen1 memlen2)
- code += getPushCode(randUniIntGen() % 128); //memlen1
- code += getPushCode(randUniIntGen() % 32); //memlen1
- break;
- default:
- smart = false;
- }
- }
-
- if (smart == false)
- for (unsigned i = 0; i < num; i++)
- {
- //generate random parameters
- int length = randOpLengGen();
- code += getPushCode(rndByteSequence(length));
- }
- return code;
-}
-
-
-//Ramdom Code Options
-RandomCodeOptions::RandomCodeOptions() : useUndefinedOpCodes(false), smartCodeProbability(50)
-{
- //each op code with same weight-probability
- for (auto i = 0; i < 255; i++)
- mapWeights.insert(std::pair(i, 50));
- setWeights();
-}
-
-void RandomCodeOptions::setWeight(dev::eth::Instruction _opCode, int _weight)
-{
- mapWeights.at((int)_opCode) = _weight;
- setWeights();
-}
-
-void RandomCodeOptions::addAddress(dev::Address const& _address)
-{
- addressList.push_back(_address);
-}
-
-dev::Address RandomCodeOptions::getRandomAddress() const
-{
- if (addressList.size() > 0)
- {
- int index = RandomCode::randomUniInt() % addressList.size();
- return addressList[index];
- }
- return Address(RandomCode::rndByteSequence(20));
-}
-
-void RandomCodeOptions::setWeights()
-{
- std::vector weights;
- for (auto const& element: mapWeights)
- weights.push_back(element.second);
- opCodeProbability = boostDescreteDistrib(weights);
-}
-
-BOOST_AUTO_TEST_SUITE(RandomCodeTests)
-
-BOOST_AUTO_TEST_CASE(rndCode)
-{
- std::string code;
- cnote << "Testing Random Code: ";
- try
- {
- code = dev::test::RandomCode::generate(10);
- }
- catch(...)
- {
- BOOST_ERROR("Exception thrown when generating random code!");
- }
- cnote << code;
-}
-
-BOOST_AUTO_TEST_SUITE_END()
-
-}
-}
diff --git a/test/fuzzTesting/fuzzHelper.h b/test/fuzzTesting/fuzzHelper.h
deleted file mode 100644
index a061333bb..000000000
--- a/test/fuzzTesting/fuzzHelper.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- This file is part of cpp-ethereum.
-
- cpp-ethereum is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- cpp-ethereum is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with cpp-ethereum. If not, see .
-*/
-/** @file fuzzHelper.h
- * @author Dimitry Khokhlov
- * @date 2015
- */
-
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-
-#pragma once
-
-namespace dev
-{
-namespace test
-{
-
-typedef boost::random::uniform_int_distribution<> boostIntDistrib;
-typedef boost::random::discrete_distribution<> boostDescreteDistrib;
-typedef boost::uniform_int boostUint64Distrib;
-
-typedef boost::random::variate_generator boostIntGenerator;
-typedef boost::random::variate_generator boostWeightGenerator;
-typedef boost::random::variate_generator boostUInt64Generator;
-
-struct RandomCodeOptions
-{
-public:
- RandomCodeOptions();
- void setWeight(dev::eth::Instruction _opCode, int _weight);
- void addAddress(dev::Address const& _address);
- dev::Address getRandomAddress() const;
-
- bool useUndefinedOpCodes;
- int smartCodeProbability;
- boostDescreteDistrib opCodeProbability;
-private:
- void setWeights();
- std::map mapWeights;
- std::vector addressList;
-};
-
-enum class SizeStrictness
-{
- Strict,
- Random
-};
-
-struct RlpDebug
-{
- std::string rlp;
- int insertions;
-};
-
-class RandomCode
-{
-public:
- /// Generate random vm code
- static std::string generate(int _maxOpNumber = 1, RandomCodeOptions _options = RandomCodeOptions());
-
- /// Generate random byte string of a given length
- static std::string rndByteSequence(int _length = 1, SizeStrictness _sizeType = SizeStrictness::Strict);
-
- /// Generate random rlp byte sequence of a given depth (e.g [[[]],[]]). max depth level = 20.
- /// The _debug string contains returned rlp string with analysed sections
- /// [] - length section/ or single byte rlp encoding
- /// () - decimal representation of length
- /// {1} - Array
- /// {2} - Array more than 55
- /// {3} - List
- /// {4} - List more than 55
- static std::string rndRLPSequence(int _depth, std::string& _debug);
-
- /// Generate random int64
- static std::string randomUniIntHex(u256 _maxVal = 0);
- static int randomUniInt();
-
-private:
- static std::string fillArguments(dev::eth::Instruction _opcode, RandomCodeOptions const& _options);
- static std::string getPushCode(int _value);
- static std::string getPushCode(std::string const& _hex);
- static int recursiveRLP(std::string& _result, int _depth, std::string& _debug);
- static void refreshSeed();
-
- static boost::random::mt19937 gen; ///< Random generator
- static boostIntDistrib opCodeDist; ///< 0..255 opcodes
- static boostIntDistrib opLengDist; ///< 1..32 byte string
- static boostIntDistrib uniIntDist; ///< 0..0x7fffffff
- static boostUint64Distrib uInt64Dist; ///< 0..2**64
-
- static boostIntGenerator randUniIntGen; ///< Generate random UniformInt from uniIntDist
- static boostIntGenerator randOpCodeGen; ///< Generate random value from opCodeDist
- static boostIntGenerator randOpLengGen; ///< Generate random length from opLengDist
- static boostUInt64Generator randUInt64Gen; ///< Generate random uInt64
-};
-
-}
-}
diff --git a/test/libdevcore/Base36.cpp b/test/libdevcore/Base36.cpp
deleted file mode 100644
index febc1dec9..000000000
--- a/test/libdevcore/Base36.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- This file is part of cpp-ethereum.
-
- cpp-ethereum is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- cpp-ethereum is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with cpp-ethereum. If not, see .
-*/
-/** @file Base36.cpp
- * @author Marek Kotewicz
- * @date 2015
- */
-
-#include
-#include
-#include
-
-using namespace std;
-using namespace dev;
-using namespace dev::eth;
-
-BOOST_AUTO_TEST_SUITE(Base36Tests)
-
-BOOST_AUTO_TEST_CASE(basicEncoding)
-{
- FixedHash<2> value("0x0048");
- string encoded = toBase36<2>(value);
- BOOST_CHECK_EQUAL(encoded, "20");
-}
-
-BOOST_AUTO_TEST_CASE(basicEncoding2)
-{
- FixedHash<2> value("0x0072");
- string encoded = toBase36<2>(value);
- BOOST_CHECK_EQUAL(encoded, "36");
-}
-
-BOOST_AUTO_TEST_CASE(basicEncoding3)
-{
- FixedHash<2> value("0xffff");
- string encoded = toBase36<2>(value);
- BOOST_CHECK_EQUAL(encoded, "1EKF");
-}
-
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/test/libdevcore/CMakeLists.txt b/test/libdevcore/CMakeLists.txt
deleted file mode 100644
index 3ceda13b0..000000000
--- a/test/libdevcore/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-cmake_policy(SET CMP0015 NEW)
-
-aux_source_directory(. SRCS)
-
-add_sources(${SRCS})
diff --git a/test/libdevcore/FixedHash.cpp b/test/libdevcore/FixedHash.cpp
deleted file mode 100644
index dc5ced2c1..000000000
--- a/test/libdevcore/FixedHash.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- This file is part of cpp-ethereum.
-
- cpp-ethereum is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- cpp-ethereum is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with cpp-ethereum. If not, see .
-*/
-/** @file FixedHash.cpp
- * @author Lefterus
- * @date 2015
- */
-
-#include
-#include "../TestHelper.h"
-
-using namespace std;
-using namespace dev;
-
-namespace dev
-{
-namespace test
-{
-
-BOOST_AUTO_TEST_SUITE(FixedHashTests)
-
-BOOST_AUTO_TEST_CASE(FixedHashComparisons)
-{
- FixedHash<4> h1(sha3("abcd"));
- FixedHash<4> h2(sha3("abcd"));
- FixedHash<4> h3(sha3("aadd"));
- FixedHash<4> h4(0xBAADF00D);
- FixedHash<4> h5(0xAAAAAAAA);
- FixedHash<4> h6(0xBAADF00D);
-
- BOOST_CHECK(h1 == h2);
- BOOST_CHECK(h2 != h3);
-
- BOOST_CHECK(h4 > h5);
- BOOST_CHECK(h5 < h4);
- BOOST_CHECK(h6 <= h4);
- BOOST_CHECK(h6 >= h4);
-}
-
-BOOST_AUTO_TEST_CASE(FixedHashXOR)
-{
- FixedHash<2> h1("0xAAAA");
- FixedHash<2> h2("0xBBBB");
-
- BOOST_CHECK((h1 ^ h2) == FixedHash<2>("0x1111"));
- h1 ^= h2;
- BOOST_CHECK(h1 == FixedHash<2>("0x1111"));
-}
-
-BOOST_AUTO_TEST_CASE(FixedHashOR)
-{
- FixedHash<4> h1("0xD3ADB33F");
- FixedHash<4> h2("0xBAADF00D");
- FixedHash<4> res("0xFBADF33F");
-
- BOOST_CHECK((h1 | h2) == res);
- h1 |= h2;
- BOOST_CHECK(h1 == res);
-}
-
-BOOST_AUTO_TEST_CASE(FixedHashAND)
-{
- FixedHash<4> h1("0xD3ADB33F");
- FixedHash<4> h2("0xBAADF00D");
- FixedHash<4> h3("0x92aDB00D");
-
- BOOST_CHECK((h1 & h2) == h3);
- h1 &= h2;
- BOOST_CHECK(h1 = h3);
-}
-
-BOOST_AUTO_TEST_CASE(FixedHashInvert)
-{
- FixedHash<4> h1("0xD3ADB33F");
- FixedHash<4> h2("0x2C524CC0");
-
- BOOST_CHECK(~h1 == h2);
-}
-
-BOOST_AUTO_TEST_CASE(FixedHashContains)
-{
- FixedHash<4> h1("0xD3ADB331");
- FixedHash<4> h2("0x0000B331");
- FixedHash<4> h3("0x0000000C");
-
- BOOST_CHECK(h1.contains(h2));
- BOOST_CHECK(!h1.contains(h3));
-}
-
-void incrementSingleIteration(unsigned seed)
-{
- unsigned next = seed + 1;
-
- FixedHash<4> h1(seed);
- FixedHash<4> h2 = h1;
- FixedHash<4> h3(next);
-
- FixedHash<32> hh1(seed);
- FixedHash<32> hh2 = hh1;
- FixedHash<32> hh3(next);
-
- BOOST_CHECK_EQUAL(++h2, h3);
- BOOST_CHECK_EQUAL(++hh2, hh3);
-
- BOOST_CHECK(h2 > h1);
- BOOST_CHECK(hh2 > hh1);
-
- unsigned reverse1 = ((FixedHash<4>::Arith)h2).convert_to();
- unsigned reverse2 = ((FixedHash<32>::Arith)hh2).convert_to();
-
- BOOST_CHECK_EQUAL(next, reverse1);
- BOOST_CHECK_EQUAL(next, reverse2);
-}
-
-BOOST_AUTO_TEST_CASE(FixedHashIncrement)
-{
- incrementSingleIteration(0);
- incrementSingleIteration(1);
- incrementSingleIteration(0xBAD);
- incrementSingleIteration(0xBEEF);
- incrementSingleIteration(0xFFFF);
- incrementSingleIteration(0xFEDCBA);
- incrementSingleIteration(0x7FFFFFFF);
-
- FixedHash<4> h(0xFFFFFFFF);
- FixedHash<4> zero;
- BOOST_CHECK_EQUAL(++h, zero);
-}
-
-BOOST_AUTO_TEST_SUITE_END()
-
-}
-}
diff --git a/test/libdevcore/RangeMask.cpp b/test/libdevcore/RangeMask.cpp
deleted file mode 100644
index 05f58963a..000000000
--- a/test/libdevcore/RangeMask.cpp
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- This file is part of cpp-ethereum.
-
- cpp-ethereum is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- cpp-ethereum is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with cpp-ethereum. If not, see .
-*/
-/** @file RangeMask.cpp
- * @author Christian
- * @date 2015
- */
-
-#include
-#include "../TestHelper.h"
-
-using namespace std;
-using namespace dev;
-
-namespace dev
-{
-namespace test
-{
-
-BOOST_AUTO_TEST_SUITE(RangeMaskTest)
-
-BOOST_AUTO_TEST_CASE(constructor)
-{
- using RM = RangeMask;
- using Range = pair;
- for (RM r: {RM(), RM(1, 10), RM(Range(2, 10))})
- {
- BOOST_CHECK(r.empty());
- BOOST_CHECK(!r.contains(0));
- BOOST_CHECK(!r.contains(1));
- BOOST_CHECK_EQUAL(0, r.size());
- }
- BOOST_CHECK(RM().full());
- BOOST_CHECK(!RM(1, 10).full());
- BOOST_CHECK(!RM(Range(2, 10)).full());
-}
-
-BOOST_AUTO_TEST_CASE(simple_unions)
-{
- using RM = RangeMask;
- using Range = pair;
- RM m(Range(0, 2000));
- m.unionWith(Range(1, 2));
- BOOST_CHECK_EQUAL(m.size(), 1);
- m.unionWith(Range(50, 250));
- BOOST_CHECK_EQUAL(m.size(), 201);
- m.unionWith(Range(10, 16));
- BOOST_CHECK_EQUAL(m.size(), 207);
- BOOST_CHECK(m.contains(1));
- BOOST_CHECK(m.contains(11));
- BOOST_CHECK(m.contains(51));
- BOOST_CHECK(m.contains(200));
- BOOST_CHECK(!m.contains(2));
- BOOST_CHECK(!m.contains(7));
- BOOST_CHECK(!m.contains(17));
- BOOST_CHECK(!m.contains(258));
-}
-
-BOOST_AUTO_TEST_CASE(empty_union)
-{
- using RM = RangeMask;
- using Range = pair;
- RM m(Range(0, 2000));
- m.unionWith(Range(3, 6));
- BOOST_CHECK_EQUAL(m.size(), 3);
- m.unionWith(Range(50, 50));
- BOOST_CHECK_EQUAL(m.size(), 3);
- m.unionWith(Range(0, 0));
- BOOST_CHECK_EQUAL(m.size(), 3);
- m.unionWith(Range(1, 1));
- BOOST_CHECK_EQUAL(m.size(), 3);
- m.unionWith(Range(2, 2));
- BOOST_CHECK_EQUAL(m.size(), 3);
- m.unionWith(Range(3, 3));
- BOOST_CHECK_EQUAL(m.size(), 3);
-}
-
-BOOST_AUTO_TEST_CASE(overlapping_unions)
-{
- using RM = RangeMask;
- using Range = pair;
- RM m(Range(0, 2000));
- m.unionWith(Range(10, 20));
- BOOST_CHECK_EQUAL(10, m.size());
- m.unionWith(Range(30, 40));
- BOOST_CHECK_EQUAL(20, m.size());
- m.unionWith(Range(15, 30));
- BOOST_CHECK_EQUAL(40 - 10, m.size());
- m.unionWith(Range(50, 60));
- m.unionWith(Range(45, 55));
- // [40, 45) still missing here
- BOOST_CHECK_EQUAL(60 - 10 - 5, m.size());
- m.unionWith(Range(15, 56));
- BOOST_CHECK_EQUAL(60 - 10, m.size());
- m.unionWith(Range(15, 65));
- BOOST_CHECK_EQUAL(65 - 10, m.size());
- m.unionWith(Range(5, 70));
- BOOST_CHECK_EQUAL(70 - 5, m.size());
-}
-
-BOOST_AUTO_TEST_CASE(complement)
-{
- using RM = RangeMask;
- using Range = pair;
- RM m(Range(0, 2000));
- m.unionWith(7).unionWith(9);
- m = ~m;
- m.unionWith(7).unionWith(9);
- m = ~m;
- BOOST_CHECK(m.empty());
-
- m += Range(0, 10);
- m += Range(1000, 2000);
- m.invert();
- BOOST_CHECK_EQUAL(m.size(), 1000 - 10);
-}
-
-BOOST_AUTO_TEST_CASE(iterator)
-{
- using RM = RangeMask;
- using Range = pair;
- RM m(Range(0, 2000));
- m.unionWith(Range(7, 9));
- m.unionWith(11);
- m.unionWith(Range(200, 205));
-
- vector elements;
- copy(m.begin(), m.end(), back_inserter(elements));
- BOOST_CHECK(elements == (vector{7, 8, 11, 200, 201, 202, 203, 204}));
-}
-
-BOOST_AUTO_TEST_SUITE_END()
-
-}
-}
diff --git a/test/libdevcore/core.cpp b/test/libdevcore/core.cpp
deleted file mode 100644
index e7c7c86a1..000000000
--- a/test/libdevcore/core.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- This file is part of cpp-ethereum.
-
- cpp-ethereum is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- cpp-ethereum is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with cpp-ethereum. If not, see .
-*/
-/** @file core.cpp
- * @author Dimitry Khokhlov
- * @date 2014
- * CORE test functions.
- */
-
-#include
-#include
-#include
-
-BOOST_AUTO_TEST_SUITE(CoreLibTests)
-
-BOOST_AUTO_TEST_CASE(byteRef)
-{
- cnote << "bytesRef copyTo and toString...";
- dev::bytes originalSequence = dev::fromHex("0102030405060708091011121314151617181920212223242526272829303132");
- dev::bytesRef out(&originalSequence.at(0), 32);
- dev::h256 hash32("1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347");
- hash32.ref().copyTo(out);
-
- BOOST_CHECK_MESSAGE(out.size() == 32, "Error wrong result size when h256::ref().copyTo(dev::bytesRef out)");
- BOOST_CHECK_MESSAGE(out.toBytes() == originalSequence, "Error when h256::ref().copyTo(dev::bytesRef out)");
-}
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/test/libdevcore/rlp.cpp b/test/libdevcore/rlp.cpp
deleted file mode 100644
index 47176d6c0..000000000
--- a/test/libdevcore/rlp.cpp
+++ /dev/null
@@ -1,314 +0,0 @@
-/*
- This file is part of cpp-ethereum.
-
- cpp-ethereum is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- cpp-ethereum is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with cpp-ethereum. If not, see .
-*/
-/** @file rlp.cpp
- * @author Gav Wood
- * @date 2014
- * RLP test functions.
- */
-
-#include
-#include
-
-#include
-
-#include