From e78b641290963eac4462d46a41b5eb90dfa79764 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Wed, 25 Mar 2015 13:37:43 +0100 Subject: [PATCH 1/5] fixed link dependencies for libtestutils --- libtestutils/CMakeLists.txt | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/libtestutils/CMakeLists.txt b/libtestutils/CMakeLists.txt index f79daa47c..202b9823c 100644 --- a/libtestutils/CMakeLists.txt +++ b/libtestutils/CMakeLists.txt @@ -11,9 +11,7 @@ aux_source_directory(. SRC_LIST) include_directories(BEFORE ${JSONCPP_INCLUDE_DIRS}) include_directories(BEFORE ..) -include_directories(${MHD_INCLUDE_DIRS}) include_directories(${JSON_RPC_CPP_INCLUDE_DIRS}) -include_directories(${LEVELDB_INCLUDE_DIRS}) include_directories(${Boost_INCLUDE_DIRS}) set(EXECUTABLE testutils) @@ -26,18 +24,10 @@ else() add_library(${EXECUTABLE} SHARED ${SRC_LIST} ${HEADERS}) endif() -target_link_libraries(${EXECUTABLE} ${LEVELDB_LIBRARIES}) +target_link_libraries(${EXECUTABLE} ${Boost_FILESYSTEM_LIBRARIES}) target_link_libraries(${EXECUTABLE} ${JSONCPP_LIBRARIES}) -target_link_libraries(${EXECUTABLE} ${JSON_RPC_CPP_SERVER_LIBRARIES}) -target_link_libraries(${EXECUTABLE} ${MHD_LIBRARIES}) - -target_link_libraries(${EXECUTABLE} webthree) -target_link_libraries(${EXECUTABLE} secp256k1) -target_link_libraries(${EXECUTABLE} solidity) - -if (NOT ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")) - target_link_libraries(${EXECUTABLE} serpent) -endif() +target_link_libraries(${EXECUTABLE} ethereum) +target_link_libraries(${EXECUTABLE} web3jsonrpc) install( TARGETS ${EXECUTABLE} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib ) install( FILES ${HEADERS} DESTINATION include/${EXECUTABLE} ) From 77b8e7796ac1fb4ef1cf1a19f17da80dbb2dd454 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Wed, 25 Mar 2015 13:47:10 +0100 Subject: [PATCH 2/5] added missing headers --- libtestutils/FixedWebThreeServer.cpp | 20 ++++++++++++++++++++ libtestutils/FixedWebThreeServer.h | 19 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/libtestutils/FixedWebThreeServer.cpp b/libtestutils/FixedWebThreeServer.cpp index 6a1b13b11..c72a106c6 100644 --- a/libtestutils/FixedWebThreeServer.cpp +++ b/libtestutils/FixedWebThreeServer.cpp @@ -1,2 +1,22 @@ +/* + 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 + * @date 2015 + */ #include "FixedWebThreeServer.h" diff --git a/libtestutils/FixedWebThreeServer.h b/libtestutils/FixedWebThreeServer.h index aab12c461..53db2f2b2 100644 --- a/libtestutils/FixedWebThreeServer.h +++ b/libtestutils/FixedWebThreeServer.h @@ -1,4 +1,23 @@ +/* + 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 From 2a892a60da6f99dfa94625dcbbc666e9cade4da7 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Wed, 25 Mar 2015 13:57:07 +0100 Subject: [PATCH 3/5] pr fixes for ShortLivingDirectory --- libtestutils/ShortLivingDirectory.cpp | 13 ++++++------- libtestutils/ShortLivingDirectory.h | 6 +++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/libtestutils/ShortLivingDirectory.cpp b/libtestutils/ShortLivingDirectory.cpp index 56fc101a7..48e1d643d 100644 --- a/libtestutils/ShortLivingDirectory.cpp +++ b/libtestutils/ShortLivingDirectory.cpp @@ -20,21 +20,20 @@ */ #include +#include #include "ShortLivingDirectory.h" -#include "Common.h" using namespace std; using namespace dev; using namespace dev::test; -ShortLivingDirectory::ShortLivingDirectory() -{ - m_path = getRandomPath(); - boost::filesystem::create_directories(m_path); -} - ShortLivingDirectory::ShortLivingDirectory(std::string const& _path) : m_path(_path) { + // we never ever want to delete a directory (including all its contents) that we did not create ourselves. + if (boost::filesystem::exists(m_path)) { + BOOST_THROW_EXCEPTION(FileError()); + } + boost::filesystem::create_directories(m_path); } diff --git a/libtestutils/ShortLivingDirectory.h b/libtestutils/ShortLivingDirectory.h index 6f572c2bc..434120e04 100644 --- a/libtestutils/ShortLivingDirectory.h +++ b/libtestutils/ShortLivingDirectory.h @@ -22,6 +22,7 @@ #pragma once #include +#include "Common.h" namespace dev { @@ -31,11 +32,10 @@ namespace test class ShortLivingDirectory { public: - ShortLivingDirectory(); - ShortLivingDirectory(std::string const& _path); + ShortLivingDirectory(std::string const& _path = getRandomPath()); ~ShortLivingDirectory(); - std::string path(){ return m_path; } + std::string const& path() { return m_path; } private: std::string m_path; From 42b3160f13d8c50de0a8fbac2dbaaaa4df37464d Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Wed, 25 Mar 2015 13:59:02 +0100 Subject: [PATCH 4/5] pr fixes for StateLoader --- libtestutils/StateLoader.cpp | 3 +-- libtestutils/StateLoader.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/libtestutils/StateLoader.cpp b/libtestutils/StateLoader.cpp index 0561e40f1..b56475b5a 100644 --- a/libtestutils/StateLoader.cpp +++ b/libtestutils/StateLoader.cpp @@ -26,8 +26,7 @@ using namespace dev; using namespace dev::eth; using namespace dev::test; -StateLoader::StateLoader(Json::Value const& _json) -: m_state(Address(), OverlayDB(), BaseState::Empty) +StateLoader::StateLoader(Json::Value const& _json) : m_state(Address(), OverlayDB(), BaseState::Empty) { for (string const& name: _json.getMemberNames()) { diff --git a/libtestutils/StateLoader.h b/libtestutils/StateLoader.h index 90f806714..10d7251cc 100644 --- a/libtestutils/StateLoader.h +++ b/libtestutils/StateLoader.h @@ -33,7 +33,7 @@ class StateLoader { public: StateLoader(Json::Value const& _json); - eth::State state() { return m_state; } + eth::State const& state() { return m_state; } private: eth::State m_state; From 14115d96d57b8d469151f0ed60aa6fe5188d8bba Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Wed, 25 Mar 2015 14:19:09 +0100 Subject: [PATCH 5/5] brief docs for libtestutils classes --- libtestutils/BlockChainLoader.h | 3 ++- libtestutils/FixedClient.h | 4 ++++ libtestutils/FixedWebThreeServer.h | 6 ++++++ libtestutils/ShortLivingDirectory.h | 5 +++++ libtestutils/StateLoader.h | 3 +++ 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/libtestutils/BlockChainLoader.h b/libtestutils/BlockChainLoader.h index a3528045c..ed110ff6f 100644 --- a/libtestutils/BlockChainLoader.h +++ b/libtestutils/BlockChainLoader.h @@ -32,7 +32,8 @@ namespace test { /** - * @brief - loads the blockchain from json, creates temporary directory to store it, removes this temporary directory on dealloc + * @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 { diff --git a/libtestutils/FixedClient.h b/libtestutils/FixedClient.h index ce628c651..f0a7c54f6 100644 --- a/libtestutils/FixedClient.h +++ b/libtestutils/FixedClient.h @@ -30,6 +30,10 @@ namespace dev namespace test { +/** + * @brief mvp implementation of ClientBase + * Doesn't support mining interface + */ class FixedClient: public dev::eth::ClientBase { public: diff --git a/libtestutils/FixedWebThreeServer.h b/libtestutils/FixedWebThreeServer.h index 53db2f2b2..33ccbf71e 100644 --- a/libtestutils/FixedWebThreeServer.h +++ b/libtestutils/FixedWebThreeServer.h @@ -24,6 +24,12 @@ #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: diff --git a/libtestutils/ShortLivingDirectory.h b/libtestutils/ShortLivingDirectory.h index 434120e04..bab6a1c20 100644 --- a/libtestutils/ShortLivingDirectory.h +++ b/libtestutils/ShortLivingDirectory.h @@ -29,6 +29,11 @@ namespace dev namespace test { +/** + * @brief temporary directory implementation + * It creates temporary directory in the given path. On dealloc it removes the directory + * @throws if the given path already exists, throws an exception + */ class ShortLivingDirectory { public: diff --git a/libtestutils/StateLoader.h b/libtestutils/StateLoader.h index 10d7251cc..e8f955440 100644 --- a/libtestutils/StateLoader.h +++ b/libtestutils/StateLoader.h @@ -29,6 +29,9 @@ namespace dev namespace test { +/** + * @brief Friend of State, loads State from given JSON object + */ class StateLoader { public: