From 338e5bd0887a4b02d6e94ca30bf2cfcb00c530e0 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Mon, 20 Apr 2015 22:48:53 +0200 Subject: [PATCH] Restructure test folders --- {test => libdevcrypto}/trie.cpp | 0 {test => libp2p}/net.cpp | 0 libtestutils/Common.cpp | 6 + libtestutils/Common.h | 1 + test/CMakeLists.txt | 89 +-- test/TestHelper.cpp | 10 +- test/TestHelper.h | 3 +- test/{ => deprecated}/fork.cpp | 0 test/{ => deprecated}/kademlia.cpp | 0 test/{ => deprecated}/main.cpp | 0 test/{ => deprecated}/txTest.cpp | 0 test/fuzzTesting/CMakeLists.txt | 31 + .../checkRandomStateTest.cpp | 2 +- test/{ => fuzzTesting}/checkRandomVMTest.cpp | 3 +- .../createRandomStateTest.cpp | 4 +- test/{ => fuzzTesting}/createRandomVMTest.cpp | 2 +- test/libdevcore/CMakeLists.txt | 5 + test/{ => libdevcore}/rlp.cpp | 4 +- test/libdevcrypto/CMakeLists.txt | 5 + test/{ => libdevcrypto}/MemTrie.cpp | 0 test/{ => libdevcrypto}/MemTrie.h | 0 test/{ => libdevcrypto}/TrieHash.cpp | 0 test/{ => libdevcrypto}/TrieHash.h | 0 test/{ => libdevcrypto}/crypto.cpp | 0 test/{ => libdevcrypto}/hexPrefix.cpp | 4 +- test/libdevcrypto/trie.cpp | 553 ++++++++++++++++ test/libethcore/CMakeLists.txt | 5 + test/{ => libethcore}/commonjs.cpp | 0 test/{ => libethcore}/dagger.cpp | 4 +- .../bcInvalidHeaderTestFiller.json | 0 .../bcJS_API_TestFiller.json | 0 .../bcUncleHeaderValiditiyFiller.json | 0 .../BlockTestsFiller}/bcUncleTestFiller.json | 0 .../bcValidBlockTestFiller.json | 0 test/libethereum/CMakeLists.txt | 5 + test/{ => libethereum}/ClientBase.cpp | 2 +- .../StateTestsFiller}/ManyFunctions.sol | 0 .../ManyFunctionsGenerator.py | 0 .../stBlockHashTestFiller.json | 0 .../stCallCreateCallCodeTestFiller.json | 0 .../StateTestsFiller}/stExampleFiller.json | 0 .../stInitCodeTestFiller.json | 0 .../StateTestsFiller}/stLogTestsFiller.json | 0 .../stMemoryStressTestFiller.json | 0 .../StateTestsFiller}/stMemoryTestFiller.json | 0 .../stPreCompiledContractsFiller.json | 0 .../stQuadraticComplexityTestFiller.json | 0 .../stRecursiveCreateFiller.json | 0 .../StateTestsFiller}/stRefundTestFiller.json | 0 .../stSolidityTestFiller.json | 0 .../stSpecialTestFiller.json | 0 .../stSystemOperationsTestFiller.json | 0 .../stTransactionTestFiller.json | 0 .../tt10mbDataFieldFiller.json | 0 .../ttTransactionTestFiller.json | 0 test/{ => libethereum}/blockchain.cpp | 16 +- test/{ => libethereum}/genesis.cpp | 4 +- test/{ => libethereum}/state.cpp | 34 +- test/{ => libethereum}/stateOriginal.cpp | 2 +- test/{ => libethereum}/transaction.cpp | 8 +- test/libevm/CMakeLists.txt | 5 + .../VMTestsFiller/performanceTester.sol} | 0 .../vmArithmeticTestFiller.json | 0 .../vmBitwiseLogicOperationTestFiller.json | 0 .../VMTestsFiller}/vmBlockInfoTestFiller.json | 0 .../vmEnvironmentalInfoTestFiller.json | 0 .../vmIOandFlowOperationsTestFiller.json | 0 .../VMTestsFiller}/vmLogTestFiller.json | 0 .../vmPerformanceTestFiller.json | 0 .../vmPushDupSwapTestFiller.json | 0 .../VMTestsFiller}/vmSha3TestFiller.json | 0 .../vmSystemOperationsTestFiller.json | 0 .../VMTestsFiller}/vmtestsFiller.json | 0 test/{ => libevm}/vm.cpp | 28 +- test/{ => libevm}/vm.h | 2 +- test/{ => libevmcore}/Assembly.cpp | 0 test/libevmcore/CMakeLists.txt | 5 + test/libnatspec/CMakeLists.txt | 5 + test/{ => libnatspec}/natspec.cpp | 0 test/libp2p/CMakeLists.txt | 5 + test/libp2p/net.cpp | 372 +++++++++++ test/{ => libp2p}/peer.cpp | 0 test/{ => libp2p}/rlpx.cpp | 0 test/libsolidity/CMakeLists.txt | 5 + test/{ => libsolidity}/SolidityABIJSON.cpp | 2 +- test/{ => libsolidity}/SolidityCompiler.cpp | 0 .../SolidityEndToEndTest.cpp | 2 +- .../SolidityExpressionCompiler.cpp | 2 +- test/{ => libsolidity}/SolidityInterface.cpp | 2 +- .../SolidityNameAndTypeResolution.cpp | 2 +- .../{ => libsolidity}/SolidityNatspecJSON.cpp | 2 +- test/{ => libsolidity}/SolidityOptimizer.cpp | 2 +- test/{ => libsolidity}/SolidityParser.cpp | 2 +- test/{ => libsolidity}/SolidityScanner.cpp | 0 test/{ => libsolidity}/SolidityTypes.cpp | 0 .../solidityExecutionFramework.h | 2 +- test/{ => libweb3jsonrpc}/AccountHolder.cpp | 0 test/libweb3jsonrpc/CMakeLists.txt | 5 + test/{ => libweb3jsonrpc}/jsonrpc.cpp | 4 +- test/libweb3jsonrpc/webthreestubclient.h | 596 ++++++++++++++++++ test/libwhisper/CMakeLists.txt | 5 + test/{ => libwhisper}/whisperTopic.cpp | 0 test/randomTestFiller.json | 29 - 103 files changed, 1741 insertions(+), 145 deletions(-) rename {test => libdevcrypto}/trie.cpp (100%) rename {test => libp2p}/net.cpp (100%) rename test/{ => deprecated}/fork.cpp (100%) rename test/{ => deprecated}/kademlia.cpp (100%) rename test/{ => deprecated}/main.cpp (100%) rename test/{ => deprecated}/txTest.cpp (100%) create mode 100644 test/fuzzTesting/CMakeLists.txt rename test/{ => fuzzTesting}/checkRandomStateTest.cpp (99%) rename test/{ => fuzzTesting}/checkRandomVMTest.cpp (99%) rename test/{ => fuzzTesting}/createRandomStateTest.cpp (99%) rename test/{ => fuzzTesting}/createRandomVMTest.cpp (99%) create mode 100644 test/libdevcore/CMakeLists.txt rename test/{ => libdevcore}/rlp.cpp (98%) create mode 100644 test/libdevcrypto/CMakeLists.txt rename test/{ => libdevcrypto}/MemTrie.cpp (100%) rename test/{ => libdevcrypto}/MemTrie.h (100%) rename test/{ => libdevcrypto}/TrieHash.cpp (100%) rename test/{ => libdevcrypto}/TrieHash.h (100%) rename test/{ => libdevcrypto}/crypto.cpp (100%) rename test/{ => libdevcrypto}/hexPrefix.cpp (96%) create mode 100644 test/libdevcrypto/trie.cpp create mode 100644 test/libethcore/CMakeLists.txt rename test/{ => libethcore}/commonjs.cpp (100%) rename test/{ => libethcore}/dagger.cpp (97%) rename test/{ => libethereum/BlockTestsFiller}/bcInvalidHeaderTestFiller.json (100%) rename test/{ => libethereum/BlockTestsFiller}/bcJS_API_TestFiller.json (100%) rename test/{ => libethereum/BlockTestsFiller}/bcUncleHeaderValiditiyFiller.json (100%) rename test/{ => libethereum/BlockTestsFiller}/bcUncleTestFiller.json (100%) rename test/{ => libethereum/BlockTestsFiller}/bcValidBlockTestFiller.json (100%) create mode 100644 test/libethereum/CMakeLists.txt rename test/{ => libethereum}/ClientBase.cpp (99%) rename test/{ => libethereum/StateTestsFiller}/ManyFunctions.sol (100%) rename test/{ => libethereum/StateTestsFiller}/ManyFunctionsGenerator.py (100%) rename test/{ => libethereum/StateTestsFiller}/stBlockHashTestFiller.json (100%) rename test/{ => libethereum/StateTestsFiller}/stCallCreateCallCodeTestFiller.json (100%) rename test/{ => libethereum/StateTestsFiller}/stExampleFiller.json (100%) rename test/{ => libethereum/StateTestsFiller}/stInitCodeTestFiller.json (100%) rename test/{ => libethereum/StateTestsFiller}/stLogTestsFiller.json (100%) rename test/{ => libethereum/StateTestsFiller}/stMemoryStressTestFiller.json (100%) rename test/{ => libethereum/StateTestsFiller}/stMemoryTestFiller.json (100%) rename test/{ => libethereum/StateTestsFiller}/stPreCompiledContractsFiller.json (100%) rename test/{ => libethereum/StateTestsFiller}/stQuadraticComplexityTestFiller.json (100%) rename test/{ => libethereum/StateTestsFiller}/stRecursiveCreateFiller.json (100%) rename test/{ => libethereum/StateTestsFiller}/stRefundTestFiller.json (100%) rename test/{ => libethereum/StateTestsFiller}/stSolidityTestFiller.json (100%) rename test/{ => libethereum/StateTestsFiller}/stSpecialTestFiller.json (100%) rename test/{ => libethereum/StateTestsFiller}/stSystemOperationsTestFiller.json (100%) rename test/{ => libethereum/StateTestsFiller}/stTransactionTestFiller.json (100%) rename test/{ => libethereum/TransactionTestsFiller}/tt10mbDataFieldFiller.json (100%) rename test/{ => libethereum/TransactionTestsFiller}/ttTransactionTestFiller.json (100%) rename test/{ => libethereum}/blockchain.cpp (96%) rename test/{ => libethereum}/genesis.cpp (97%) rename test/{ => libethereum}/state.cpp (77%) rename test/{ => libethereum}/stateOriginal.cpp (98%) rename test/{ => libethereum}/transaction.cpp (96%) create mode 100644 test/libevm/CMakeLists.txt rename test/{PerformaceTester.sol => libevm/VMTestsFiller/performanceTester.sol} (100%) rename test/{ => libevm/VMTestsFiller}/vmArithmeticTestFiller.json (100%) rename test/{ => libevm/VMTestsFiller}/vmBitwiseLogicOperationTestFiller.json (100%) rename test/{ => libevm/VMTestsFiller}/vmBlockInfoTestFiller.json (100%) rename test/{ => libevm/VMTestsFiller}/vmEnvironmentalInfoTestFiller.json (100%) rename test/{ => libevm/VMTestsFiller}/vmIOandFlowOperationsTestFiller.json (100%) rename test/{ => libevm/VMTestsFiller}/vmLogTestFiller.json (100%) rename test/{ => libevm/VMTestsFiller}/vmPerformanceTestFiller.json (100%) rename test/{ => libevm/VMTestsFiller}/vmPushDupSwapTestFiller.json (100%) rename test/{ => libevm/VMTestsFiller}/vmSha3TestFiller.json (100%) rename test/{ => libevm/VMTestsFiller}/vmSystemOperationsTestFiller.json (100%) rename test/{ => libevm/VMTestsFiller}/vmtestsFiller.json (100%) rename test/{ => libevm}/vm.cpp (90%) rename test/{ => libevm}/vm.h (99%) rename test/{ => libevmcore}/Assembly.cpp (100%) create mode 100644 test/libevmcore/CMakeLists.txt create mode 100644 test/libnatspec/CMakeLists.txt rename test/{ => libnatspec}/natspec.cpp (100%) create mode 100644 test/libp2p/CMakeLists.txt create mode 100644 test/libp2p/net.cpp rename test/{ => libp2p}/peer.cpp (100%) rename test/{ => libp2p}/rlpx.cpp (100%) create mode 100644 test/libsolidity/CMakeLists.txt rename test/{ => libsolidity}/SolidityABIJSON.cpp (99%) rename test/{ => libsolidity}/SolidityCompiler.cpp (100%) rename test/{ => libsolidity}/SolidityEndToEndTest.cpp (99%) rename test/{ => libsolidity}/SolidityExpressionCompiler.cpp (99%) rename test/{ => libsolidity}/SolidityInterface.cpp (99%) rename test/{ => libsolidity}/SolidityNameAndTypeResolution.cpp (99%) rename test/{ => libsolidity}/SolidityNatspecJSON.cpp (99%) rename test/{ => libsolidity}/SolidityOptimizer.cpp (99%) rename test/{ => libsolidity}/SolidityParser.cpp (99%) rename test/{ => libsolidity}/SolidityScanner.cpp (100%) rename test/{ => libsolidity}/SolidityTypes.cpp (100%) rename test/{ => libsolidity}/solidityExecutionFramework.h (99%) rename test/{ => libweb3jsonrpc}/AccountHolder.cpp (100%) create mode 100644 test/libweb3jsonrpc/CMakeLists.txt rename test/{ => libweb3jsonrpc}/jsonrpc.cpp (99%) create mode 100644 test/libweb3jsonrpc/webthreestubclient.h create mode 100644 test/libwhisper/CMakeLists.txt rename test/{ => libwhisper}/whisperTopic.cpp (100%) delete mode 100644 test/randomTestFiller.json diff --git a/test/trie.cpp b/libdevcrypto/trie.cpp similarity index 100% rename from test/trie.cpp rename to libdevcrypto/trie.cpp diff --git a/test/net.cpp b/libp2p/net.cpp similarity index 100% rename from test/net.cpp rename to libp2p/net.cpp diff --git a/libtestutils/Common.cpp b/libtestutils/Common.cpp index 86f96f667..6bc9d2c15 100644 --- a/libtestutils/Common.cpp +++ b/libtestutils/Common.cpp @@ -20,6 +20,7 @@ */ #include +#include #include #include #include @@ -71,6 +72,11 @@ std::string dev::test::toTestFilePath(std::string const& _filename) return getTestPath() + "/" + _filename + ".json"; } +std::string dev::test::getFolder(std::string const& _line) +{ + return boost::filesystem::path(_line).parent_path().string(); +} + std::string dev::test::getRandomPath() { std::stringstream stream; diff --git a/libtestutils/Common.h b/libtestutils/Common.h index 4757a3b7a..33acd36f1 100644 --- a/libtestutils/Common.h +++ b/libtestutils/Common.h @@ -37,6 +37,7 @@ 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& _line); std::string getRandomPath(); } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 90af5122e..bbb351232 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,10 +1,42 @@ cmake_policy(SET CMP0015 NEW) aux_source_directory(. SRC_LIST) -list(REMOVE_ITEM SRC_LIST "./createRandomVMTest.cpp") -list(REMOVE_ITEM SRC_LIST "./createRandomStateTest.cpp") -list(REMOVE_ITEM SRC_LIST "./checkRandomVMTest.cpp") -list(REMOVE_ITEM SRC_LIST "./checkRandomStateTest.cpp") + +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_sources(boostTest.cpp) + +add_subdirectory(fuzzTesting) +add_subdirectory(libdevcore) +add_subdirectory(libdevcrypto) +add_subdirectory(libethcore) +add_subdirectory(libethereum) +add_subdirectory(libevm) +add_subdirectory(libevmcore) +add_subdirectory(libnatspec) +add_subdirectory(libp2p) +add_subdirectory(libsolidity) +add_subdirectory(libweb3jsonrpc) +add_subdirectory(libwhisper) + +message(STATUS "${SRC}") +message("AHA") + +set(SRC_LIST ${SRC_LIST} ${SRC}) +message(STATUS "${SRC_LIST}") if (NOT JSONRPC) list(REMOVE_ITEM SRC_LIST "./AccountHolder.cpp") @@ -17,27 +49,23 @@ include_directories(${CRYPTOPP_INCLUDE_DIRS}) include_directories(${JSON_RPC_CPP_INCLUDE_DIRS}) # 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) +#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}) -add_executable(createRandomVMTest createRandomVMTest.cpp vm.cpp TestHelper.cpp Stats.cpp) -add_executable(createRandomStateTest createRandomStateTest.cpp TestHelper.cpp Stats.cpp) -add_executable(checkRandomVMTest checkRandomVMTest.cpp vm.cpp TestHelper.cpp Stats.cpp) -add_executable(checkRandomStateTest checkRandomStateTest.cpp TestHelper.cpp Stats.cpp) target_link_libraries(testeth ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES}) target_link_libraries(testeth ${CURL_LIBRARIES}) @@ -57,23 +85,6 @@ if (JSONRPC) target_link_libraries(testeth ${JSON_RPC_CPP_CLIENT_LIBRARIES}) endif() -target_link_libraries(createRandomVMTest ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES}) -target_link_libraries(createRandomVMTest ethereum) -target_link_libraries(createRandomVMTest ethcore) -target_link_libraries(createRandomVMTest testutils) -target_link_libraries(createRandomStateTest ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES}) -target_link_libraries(createRandomStateTest ethereum) -target_link_libraries(createRandomStateTest ethcore) -target_link_libraries(createRandomStateTest testutils) -target_link_libraries(checkRandomVMTest ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES}) -target_link_libraries(checkRandomVMTest ethereum) -target_link_libraries(checkRandomVMTest ethcore) -target_link_libraries(checkRandomVMTest testutils) -target_link_libraries(checkRandomStateTest ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES}) -target_link_libraries(checkRandomStateTest ethereum) -target_link_libraries(checkRandomStateTest ethcore) -target_link_libraries(checkRandomStateTest testutils) - enable_testing() set(CTEST_OUTPUT_ON_FAILURE TRUE) diff --git a/test/TestHelper.cpp b/test/TestHelper.cpp index ed844e961..3d0856829 100644 --- a/test/TestHelper.cpp +++ b/test/TestHelper.cpp @@ -23,9 +23,6 @@ #include #include - -#include - #include #include #include @@ -592,7 +589,7 @@ void userDefinedTest(string testTypeFlag, std::function doTests) +void executeTests(const string& _name, const string& _testPathAppendix, const boost::filesystem::path _pathToFiller, std::function doTests) { string testPath = getTestPath(); testPath += _testPathAppendix; @@ -605,11 +602,12 @@ void executeTests(const string& _name, const string& _testPathAppendix, std::fun try { cnote << "Populating tests..."; + cout << "boost::filesystem::current_path(): " << boost::filesystem::current_path().string() << endl; json_spirit::mValue v; boost::filesystem::path p(__FILE__); boost::filesystem::path dir = p.parent_path(); - string s = asString(dev::contents(dir.string() + "/" + _name + "Filler.json")); - BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of " + dir.string() + "/" + _name + "Filler.json is empty."); + 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))); diff --git a/test/TestHelper.h b/test/TestHelper.h index 36a84ecdb..bf4cdc16e 100644 --- a/test/TestHelper.h +++ b/test/TestHelper.h @@ -24,6 +24,7 @@ #include #include +#include #include "JsonSpiritHeaders.h" #include @@ -155,7 +156,7 @@ void checkStorage(std::map _expectedStore, std::map _res void checkLog(eth::LogEntries _resultLogs, eth::LogEntries _expectedLogs); void checkCallCreates(eth::Transactions _resultCallCreates, eth::Transactions _expectedCallCreates); -void executeTests(const std::string& _name, const std::string& _testPathAppendix, std::function doTests); +void executeTests(const std::string& _name, const std::string& _testPathAppendix, const boost::filesystem::path _pathToFiller, std::function doTests); void userDefinedTest(std::string testTypeFlag, std::function doTests); RLPStream createRLPStreamFromTransactionFields(json_spirit::mObject& _tObj); eth::LastHashes lastHashes(u256 _currentBlockNumber); diff --git a/test/fork.cpp b/test/deprecated/fork.cpp similarity index 100% rename from test/fork.cpp rename to test/deprecated/fork.cpp diff --git a/test/kademlia.cpp b/test/deprecated/kademlia.cpp similarity index 100% rename from test/kademlia.cpp rename to test/deprecated/kademlia.cpp diff --git a/test/main.cpp b/test/deprecated/main.cpp similarity index 100% rename from test/main.cpp rename to test/deprecated/main.cpp diff --git a/test/txTest.cpp b/test/deprecated/txTest.cpp similarity index 100% rename from test/txTest.cpp rename to test/deprecated/txTest.cpp diff --git a/test/fuzzTesting/CMakeLists.txt b/test/fuzzTesting/CMakeLists.txt new file mode 100644 index 000000000..1aa5cff84 --- /dev/null +++ b/test/fuzzTesting/CMakeLists.txt @@ -0,0 +1,31 @@ +cmake_policy(SET CMP0015 NEW) + +file(GLOB HEADERS "*.h") +include_directories(BEFORE ${JSONCPP_INCLUDE_DIRS}) +include_directories(BEFORE ..) +include_directories(BEFORE ../..) +include_directories(${Boost_INCLUDE_DIRS}) +include_directories(${CRYPTOPP_INCLUDE_DIRS}) +include_directories(${JSON_RPC_CPP_INCLUDE_DIRS}) + +add_executable(createRandomVMTest createRandomVMTest.cpp ../libevm/vm.cpp ../TestHelper.cpp ../Stats.cpp) +add_executable(createRandomStateTest createRandomStateTest.cpp ../TestHelper.cpp ../Stats.cpp) +add_executable(checkRandomVMTest checkRandomVMTest.cpp ../libevm/vm.cpp ../TestHelper.cpp ../Stats.cpp) +add_executable(checkRandomStateTest checkRandomStateTest.cpp ../TestHelper.cpp ../Stats.cpp) + +target_link_libraries(createRandomVMTest ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES}) +target_link_libraries(createRandomVMTest ethereum) +target_link_libraries(createRandomVMTest ethcore) +target_link_libraries(createRandomVMTest testutils) +target_link_libraries(createRandomStateTest ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES}) +target_link_libraries(createRandomStateTest ethereum) +target_link_libraries(createRandomStateTest ethcore) +target_link_libraries(createRandomStateTest testutils) +target_link_libraries(checkRandomVMTest ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES}) +target_link_libraries(checkRandomVMTest ethereum) +target_link_libraries(checkRandomVMTest ethcore) +target_link_libraries(checkRandomVMTest testutils) +target_link_libraries(checkRandomStateTest ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES}) +target_link_libraries(checkRandomStateTest ethereum) +target_link_libraries(checkRandomStateTest ethcore) +target_link_libraries(checkRandomStateTest testutils) diff --git a/test/checkRandomStateTest.cpp b/test/fuzzTesting/checkRandomStateTest.cpp similarity index 99% rename from test/checkRandomStateTest.cpp rename to test/fuzzTesting/checkRandomStateTest.cpp index 49aca852f..260f9e004 100644 --- a/test/checkRandomStateTest.cpp +++ b/test/fuzzTesting/checkRandomStateTest.cpp @@ -26,7 +26,7 @@ #include #include #include "TestHelper.h" -#include "vm.h" +#include "../libevm/vm.h" #pragma GCC diagnostic ignored "-Wunused-parameter" using namespace std; diff --git a/test/checkRandomVMTest.cpp b/test/fuzzTesting/checkRandomVMTest.cpp similarity index 99% rename from test/checkRandomVMTest.cpp rename to test/fuzzTesting/checkRandomVMTest.cpp index a40922577..bb55dcffa 100644 --- a/test/checkRandomVMTest.cpp +++ b/test/fuzzTesting/checkRandomVMTest.cpp @@ -25,7 +25,8 @@ #include #include #include -#include "vm.h" +#include "../libevm/vm.h" + #pragma GCC diagnostic ignored "-Wunused-parameter" using namespace std; diff --git a/test/createRandomStateTest.cpp b/test/fuzzTesting/createRandomStateTest.cpp similarity index 99% rename from test/createRandomStateTest.cpp rename to test/fuzzTesting/createRandomStateTest.cpp index 5758598b9..6e42934bc 100644 --- a/test/createRandomStateTest.cpp +++ b/test/fuzzTesting/createRandomStateTest.cpp @@ -35,8 +35,8 @@ #include #include #include -#include "TestHelper.h" -#include "vm.h" +#include "../TestHelper.h" +#include "../libevm/vm.h" using namespace std; using namespace json_spirit; diff --git a/test/createRandomVMTest.cpp b/test/fuzzTesting/createRandomVMTest.cpp similarity index 99% rename from test/createRandomVMTest.cpp rename to test/fuzzTesting/createRandomVMTest.cpp index de81099fe..abb4e184b 100644 --- a/test/createRandomVMTest.cpp +++ b/test/fuzzTesting/createRandomVMTest.cpp @@ -35,7 +35,7 @@ #include #include #include -#include "vm.h" +#include "../libevm/vm.h" using namespace std; using namespace json_spirit; diff --git a/test/libdevcore/CMakeLists.txt b/test/libdevcore/CMakeLists.txt new file mode 100644 index 000000000..3ceda13b0 --- /dev/null +++ b/test/libdevcore/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_policy(SET CMP0015 NEW) + +aux_source_directory(. SRCS) + +add_sources(${SRCS}) diff --git a/test/rlp.cpp b/test/libdevcore/rlp.cpp similarity index 98% rename from test/rlp.cpp rename to test/libdevcore/rlp.cpp index 9062b54f4..41362d569 100644 --- a/test/rlp.cpp +++ b/test/libdevcore/rlp.cpp @@ -30,8 +30,8 @@ #include #include #include -#include "JsonSpiritHeaders.h" -#include "TestHelper.h" +#include "../JsonSpiritHeaders.h" +#include "../TestHelper.h" using namespace std; using namespace dev; diff --git a/test/libdevcrypto/CMakeLists.txt b/test/libdevcrypto/CMakeLists.txt new file mode 100644 index 000000000..3ceda13b0 --- /dev/null +++ b/test/libdevcrypto/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_policy(SET CMP0015 NEW) + +aux_source_directory(. SRCS) + +add_sources(${SRCS}) diff --git a/test/MemTrie.cpp b/test/libdevcrypto/MemTrie.cpp similarity index 100% rename from test/MemTrie.cpp rename to test/libdevcrypto/MemTrie.cpp diff --git a/test/MemTrie.h b/test/libdevcrypto/MemTrie.h similarity index 100% rename from test/MemTrie.h rename to test/libdevcrypto/MemTrie.h diff --git a/test/TrieHash.cpp b/test/libdevcrypto/TrieHash.cpp similarity index 100% rename from test/TrieHash.cpp rename to test/libdevcrypto/TrieHash.cpp diff --git a/test/TrieHash.h b/test/libdevcrypto/TrieHash.h similarity index 100% rename from test/TrieHash.h rename to test/libdevcrypto/TrieHash.h diff --git a/test/crypto.cpp b/test/libdevcrypto/crypto.cpp similarity index 100% rename from test/crypto.cpp rename to test/libdevcrypto/crypto.cpp diff --git a/test/hexPrefix.cpp b/test/libdevcrypto/hexPrefix.cpp similarity index 96% rename from test/hexPrefix.cpp rename to test/libdevcrypto/hexPrefix.cpp index da294ba5b..c72f24535 100644 --- a/test/hexPrefix.cpp +++ b/test/libdevcrypto/hexPrefix.cpp @@ -24,11 +24,11 @@ #include -#include "JsonSpiritHeaders.h" +#include "../JsonSpiritHeaders.h" #include #include #include -#include "TestHelper.h" +#include "../TestHelper.h" using namespace std; using namespace dev; diff --git a/test/libdevcrypto/trie.cpp b/test/libdevcrypto/trie.cpp new file mode 100644 index 000000000..0e7125624 --- /dev/null +++ b/test/libdevcrypto/trie.cpp @@ -0,0 +1,553 @@ +/* + 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 trie.cpp + * @author Gav Wood + * @date 2014 + * Trie test functions. + */ + +#include +#include + +#include + +#include "../JsonSpiritHeaders.h" +#include +#include +#include "TrieHash.h" +#include "MemTrie.h" +#include "../TestHelper.h" + +using namespace std; +using namespace dev; + +namespace js = json_spirit; + +namespace dev +{ +namespace test +{ + +static unsigned fac(unsigned _i) +{ + return _i > 2 ? _i * fac(_i - 1) : _i; +} + +} +} + +using dev::operator <<; + +BOOST_AUTO_TEST_SUITE(TrieTests) + +BOOST_AUTO_TEST_CASE(fat_trie) +{ + h256 r; + MemoryDB fm; + { + FatGenericTrieDB ft(&fm); + ft.init(); + ft.insert(h256("69", h256::FromHex, h256::AlignRight).ref(), h256("414243", h256::FromHex, h256::AlignRight).ref()); + for (auto i: ft) + cnote << i.first << i.second; + r = ft.root(); + } + { + FatGenericTrieDB ft(&fm); + ft.setRoot(r); + for (auto i: ft) + cnote << i.first << i.second; + } +} + +BOOST_AUTO_TEST_CASE(hex_encoded_securetrie_test) +{ + string testPath = test::getTestPath(); + + testPath += "/TrieTests"; + + cnote << "Testing Secure Trie..."; + js::mValue v; + string s = asString(contents(testPath + "/hex_encoded_securetrie_test.json")); + BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'hex_encoded_securetrie_test.json' is empty. Have you cloned the 'tests' repo branch develop?"); + js::read_string(s, v); + for (auto& i: v.get_obj()) + { + cnote << i.first; + js::mObject& o = i.second.get_obj(); + vector> ss; + for (auto i: o["in"].get_obj()) + { + ss.push_back(make_pair(i.first, i.second.get_str())); + if (!ss.back().first.find("0x")) + ss.back().first = asString(fromHex(ss.back().first.substr(2))); + if (!ss.back().second.find("0x")) + ss.back().second = asString(fromHex(ss.back().second.substr(2))); + } + for (unsigned j = 0; j < min(1000000000u, dev::test::fac((unsigned)ss.size())); ++j) + { + next_permutation(ss.begin(), ss.end()); + MemoryDB m; + GenericTrieDB t(&m); + MemoryDB hm; + HashedGenericTrieDB ht(&hm); + MemoryDB fm; + FatGenericTrieDB ft(&fm); + t.init(); + ht.init(); + ft.init(); + BOOST_REQUIRE(t.check(true)); + BOOST_REQUIRE(ht.check(true)); + BOOST_REQUIRE(ft.check(true)); + for (auto const& k: ss) + { + t.insert(k.first, k.second); + ht.insert(k.first, k.second); + ft.insert(k.first, k.second); + BOOST_REQUIRE(t.check(true)); + BOOST_REQUIRE(ht.check(true)); + BOOST_REQUIRE(ft.check(true)); + for (auto i = ft.begin(), j = t.begin(); i != ft.end() && j != t.end(); ++i, ++j) + { + BOOST_CHECK_EQUAL(i == ft.end(), j == t.end()); + BOOST_REQUIRE((*i).first.toBytes() == (*j).first.toBytes()); + BOOST_REQUIRE((*i).second.toBytes() == (*j).second.toBytes()); + } + BOOST_CHECK_EQUAL(ht.root(), ft.root()); + } + BOOST_REQUIRE(!o["root"].is_null()); + BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(ht.root().asArray())); + BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(ft.root().asArray())); + } + } +} + +BOOST_AUTO_TEST_CASE(trie_test_anyorder) +{ + string testPath = test::getTestPath(); + + testPath += "/TrieTests"; + + cnote << "Testing Trie..."; + js::mValue v; + string s = asString(contents(testPath + "/trieanyorder.json")); + BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'trieanyorder.json' is empty. Have you cloned the 'tests' repo branch develop?"); + js::read_string(s, v); + for (auto& i: v.get_obj()) + { + cnote << i.first; + js::mObject& o = i.second.get_obj(); + vector> ss; + for (auto i: o["in"].get_obj()) + { + ss.push_back(make_pair(i.first, i.second.get_str())); + if (!ss.back().first.find("0x")) + ss.back().first = asString(fromHex(ss.back().first.substr(2))); + if (!ss.back().second.find("0x")) + ss.back().second = asString(fromHex(ss.back().second.substr(2))); + } + for (unsigned j = 0; j < min(1000u, dev::test::fac((unsigned)ss.size())); ++j) + { + next_permutation(ss.begin(), ss.end()); + MemoryDB m; + GenericTrieDB t(&m); + MemoryDB hm; + HashedGenericTrieDB ht(&hm); + MemoryDB fm; + FatGenericTrieDB ft(&fm); + t.init(); + ht.init(); + ft.init(); + BOOST_REQUIRE(t.check(true)); + BOOST_REQUIRE(ht.check(true)); + BOOST_REQUIRE(ft.check(true)); + for (auto const& k: ss) + { + t.insert(k.first, k.second); + ht.insert(k.first, k.second); + ft.insert(k.first, k.second); + BOOST_REQUIRE(t.check(true)); + BOOST_REQUIRE(ht.check(true)); + BOOST_REQUIRE(ft.check(true)); + for (auto i = ft.begin(), j = t.begin(); i != ft.end() && j != t.end(); ++i, ++j) + { + BOOST_CHECK_EQUAL(i == ft.end(), j == t.end()); + BOOST_REQUIRE((*i).first.toBytes() == (*j).first.toBytes()); + BOOST_REQUIRE((*i).second.toBytes() == (*j).second.toBytes()); + } + BOOST_CHECK_EQUAL(ht.root(), ft.root()); + } + BOOST_REQUIRE(!o["root"].is_null()); + BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(t.root().asArray())); + BOOST_CHECK_EQUAL(ht.root(), ft.root()); + } + } +} + +BOOST_AUTO_TEST_CASE(trie_tests_ordered) +{ + string testPath = test::getTestPath(); + + testPath += "/TrieTests"; + + cnote << "Testing Trie..."; + js::mValue v; + string s = asString(contents(testPath + "/trietest.json")); + BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'trietest.json' is empty. Have you cloned the 'tests' repo branch develop?"); + js::read_string(s, v); + + for (auto& i: v.get_obj()) + { + cnote << i.first; + js::mObject& o = i.second.get_obj(); + vector> ss; + vector keysToBeDeleted; + for (auto& i: o["in"].get_array()) + { + vector values; + for (auto& s: i.get_array()) + { + if (s.type() == json_spirit::str_type) + values.push_back(s.get_str()); + else if (s.type() == json_spirit::null_type) + { + // mark entry for deletion + values.push_back(""); + if (!values[0].find("0x")) + values[0] = asString(fromHex(values[0].substr(2))); + keysToBeDeleted.push_back(values[0]); + } + else + BOOST_FAIL("Bad type (expected string)"); + } + + BOOST_REQUIRE(values.size() == 2); + ss.push_back(make_pair(values[0], values[1])); + if (!ss.back().first.find("0x")) + ss.back().first = asString(fromHex(ss.back().first.substr(2))); + if (!ss.back().second.find("0x")) + ss.back().second = asString(fromHex(ss.back().second.substr(2))); + } + + MemoryDB m; + GenericTrieDB t(&m); + MemoryDB hm; + HashedGenericTrieDB ht(&hm); + MemoryDB fm; + FatGenericTrieDB ft(&fm); + t.init(); + ht.init(); + ft.init(); + BOOST_REQUIRE(t.check(true)); + BOOST_REQUIRE(ht.check(true)); + BOOST_REQUIRE(ft.check(true)); + + for (auto const& k: ss) + { + if (find(keysToBeDeleted.begin(), keysToBeDeleted.end(), k.first) != keysToBeDeleted.end() && k.second.empty()) + t.remove(k.first), ht.remove(k.first), ft.remove(k.first); + else + t.insert(k.first, k.second), ht.insert(k.first, k.second), ft.insert(k.first, k.second); + BOOST_REQUIRE(t.check(true)); + BOOST_REQUIRE(ht.check(true)); + BOOST_REQUIRE(ft.check(true)); + for (auto i = ft.begin(), j = t.begin(); i != ft.end() && j != t.end(); ++i, ++j) + { + BOOST_CHECK_EQUAL(i == ft.end(), j == t.end()); + BOOST_REQUIRE((*i).first.toBytes() == (*j).first.toBytes()); + BOOST_REQUIRE((*i).second.toBytes() == (*j).second.toBytes()); + } + BOOST_CHECK_EQUAL(ht.root(), ft.root()); + } + + BOOST_REQUIRE(!o["root"].is_null()); + BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(t.root().asArray())); + } +} + +inline h256 stringMapHash256(StringMap const& _s) +{ + return hash256(_s); +} + +BOOST_AUTO_TEST_CASE(moreTrieTests) +{ + cnote << "Testing Trie more..."; +#if 0 + // More tests... + { + MemoryDB m; + GenericTrieDB t(&m); + t.init(); // initialise as empty tree. + cout << t; + cout << m; + cout << t.root() << endl; + cout << hash256(StringMap()) << endl; + + t.insert(string("tesz"), string("test")); + cout << t; + cout << m; + cout << t.root() << endl; + cout << stringMapHash256({{"test", "test"}}) << endl; + + t.insert(string("tesa"), string("testy")); + cout << t; + cout << m; + cout << t.root() << endl; + cout << stringMapHash256({{"test", "test"}, {"te", "testy"}}) << endl; + cout << t.at(string("test")) << endl; + cout << t.at(string("te")) << endl; + cout << t.at(string("t")) << endl; + + t.remove(string("te")); + cout << m; + cout << t.root() << endl; + cout << stringMapHash256({{"test", "test"}}) << endl; + + t.remove(string("test")); + cout << m; + cout << t.root() << endl; + cout << hash256(StringMap()) << endl; + } + { + MemoryDB m; + GenericTrieDB t(&m); + t.init(); // initialise as empty tree. + t.insert(string("a"), string("A")); + t.insert(string("b"), string("B")); + cout << t; + cout << m; + cout << t.root() << endl; + cout << stringMapHash256({{"b", "B"}, {"a", "A"}}) << endl; + cout << RLP(rlp256({{"b", "B"}, {"a", "A"}})) << endl; + } + { + MemTrie t; + t.insert("dog", "puppy"); + cout << hex << t.hash256() << endl; + cout << RLP(t.rlp()) << endl; + } + { + MemTrie t; + t.insert("bed", "d"); + t.insert("be", "e"); + cout << hex << t.hash256() << endl; + cout << RLP(t.rlp()) << endl; + } + { + cout << hex << stringMapHash256({{"dog", "puppy"}, {"doe", "reindeer"}}) << endl; + MemTrie t; + t.insert("dog", "puppy"); + t.insert("doe", "reindeer"); + cout << hex << t.hash256() << endl; + cout << RLP(t.rlp()) << endl; + cout << toHex(t.rlp()) << endl; + } +#endif + { + MemoryDB m; + GenericTrieDB d(&m); + d.init(); // initialise as empty tree. + MemTrie t; + StringMap s; + + auto add = [&](char const* a, char const* b) + { + d.insert(string(a), string(b)); + t.insert(a, b); + s[a] = b; + + /*cout << endl << "-------------------------------" << endl; + cout << a << " -> " << b << endl; + cout << d; + cout << m; + cout << d.root() << endl; + cout << hash256(s) << endl;*/ + + BOOST_REQUIRE(d.check(true)); + BOOST_REQUIRE_EQUAL(t.hash256(), hash256(s)); + BOOST_REQUIRE_EQUAL(d.root(), hash256(s)); + for (auto const& i: s) + { + (void)i; + BOOST_REQUIRE_EQUAL(t.at(i.first), i.second); + BOOST_REQUIRE_EQUAL(d.at(i.first), i.second); + } + }; + + auto remove = [&](char const* a) + { + s.erase(a); + t.remove(a); + d.remove(string(a)); + + /*cout << endl << "-------------------------------" << endl; + cout << "X " << a << endl; + cout << d; + cout << m; + cout << d.root() << endl; + cout << hash256(s) << endl;*/ + + BOOST_REQUIRE(d.check(true)); + BOOST_REQUIRE(t.at(a).empty()); + BOOST_REQUIRE(d.at(string(a)).empty()); + BOOST_REQUIRE_EQUAL(t.hash256(), hash256(s)); + BOOST_REQUIRE_EQUAL(d.root(), hash256(s)); + for (auto const& i: s) + { + (void)i; + BOOST_REQUIRE_EQUAL(t.at(i.first), i.second); + BOOST_REQUIRE_EQUAL(d.at(i.first), i.second); + } + }; + + add("dogglesworth", "cat"); + add("doe", "reindeer"); + remove("dogglesworth"); + add("horse", "stallion"); + add("do", "verb"); + add("doge", "coin"); + remove("horse"); + remove("do"); + remove("doge"); + remove("doe"); + } +} + +BOOST_AUTO_TEST_CASE(trieLowerBound) +{ + cnote << "Stress-testing Trie.lower_bound..."; + if (0) + { + MemoryDB dm; + EnforceRefs e(dm, true); + GenericTrieDB d(&dm); + d.init(); // initialise as empty tree. + for (int a = 0; a < 20; ++a) + { + StringMap m; + for (int i = 0; i < 50; ++i) + { + auto k = randomWord(); + auto v = toString(i); + m[k] = v; + d.insert(k, v); + } + + for (auto i: d) + { + auto it = d.lower_bound(i.first); + for (auto iit = d.begin(); iit != d.end(); ++iit) + if ((*iit).first.toString() >= i.first.toString()) + { + BOOST_REQUIRE(it == iit); + break; + } + } + for (unsigned i = 0; i < 100; ++i) + { + auto k = randomWord(); + auto it = d.lower_bound(k); + for (auto iit = d.begin(); iit != d.end(); ++iit) + if ((*iit).first.toString() >= k) + { + BOOST_REQUIRE(it == iit); + break; + } + } + + } + } +} + +BOOST_AUTO_TEST_CASE(trieStess) +{ + cnote << "Stress-testing Trie..."; + if (0) + { + MemoryDB m; + MemoryDB dm; + EnforceRefs e(dm, true); + GenericTrieDB d(&dm); + d.init(); // initialise as empty tree. + MemTrie t; + BOOST_REQUIRE(d.check(true)); + for (int a = 0; a < 20; ++a) + { + StringMap m; + for (int i = 0; i < 50; ++i) + { + auto k = randomWord(); + auto v = toString(i); + m[k] = v; + t.insert(k, v); + d.insert(k, v); + BOOST_REQUIRE_EQUAL(hash256(m), t.hash256()); + BOOST_REQUIRE_EQUAL(hash256(m), d.root()); + BOOST_REQUIRE(d.check(true)); + } + while (!m.empty()) + { + auto k = m.begin()->first; + auto v = m.begin()->second; + d.remove(k); + t.remove(k); + m.erase(k); + if (!d.check(true)) + { + // cwarn << m; + for (auto i: d) + cwarn << i.first.toString() << i.second.toString(); + + MemoryDB dm2; + EnforceRefs e2(dm2, true); + GenericTrieDB d2(&dm2); + d2.init(); // initialise as empty tree. + for (auto i: d) + d2.insert(i.first, i.second); + + cwarn << "Good:" << d2.root(); +// for (auto i: dm2.get()) +// cwarn << i.first.abridged() << ": " << RLP(i.second); + d2.debugStructure(cerr); + cwarn << "Broken:" << d.root(); // Leaves an extension -> extension (3c1... -> 742...) +// for (auto i: dm.get()) +// cwarn << i.first.abridged() << ": " << RLP(i.second); + d.debugStructure(cerr); + + d2.insert(k, v); + cwarn << "Pres:" << d2.root(); +// for (auto i: dm2.get()) +// cwarn << i.first.abridged() << ": " << RLP(i.second); + d2.debugStructure(cerr); + g_logVerbosity = 99; + d2.remove(k); + g_logVerbosity = 4; + + cwarn << "Good?" << d2.root(); + } + BOOST_REQUIRE(d.check(true)); + BOOST_REQUIRE_EQUAL(hash256(m), t.hash256()); + BOOST_REQUIRE_EQUAL(hash256(m), d.root()); + } + } + } +} + +BOOST_AUTO_TEST_SUITE_END() + + diff --git a/test/libethcore/CMakeLists.txt b/test/libethcore/CMakeLists.txt new file mode 100644 index 000000000..3ceda13b0 --- /dev/null +++ b/test/libethcore/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_policy(SET CMP0015 NEW) + +aux_source_directory(. SRCS) + +add_sources(${SRCS}) diff --git a/test/commonjs.cpp b/test/libethcore/commonjs.cpp similarity index 100% rename from test/commonjs.cpp rename to test/libethcore/commonjs.cpp diff --git a/test/dagger.cpp b/test/libethcore/dagger.cpp similarity index 97% rename from test/dagger.cpp rename to test/libethcore/dagger.cpp index cb8908d32..119780346 100644 --- a/test/dagger.cpp +++ b/test/libethcore/dagger.cpp @@ -22,12 +22,12 @@ #include #include -#include "JsonSpiritHeaders.h" +#include "../JsonSpiritHeaders.h" #include #include #include #include -#include "TestHelper.h" +#include "../TestHelper.h" using namespace std; using namespace dev; diff --git a/test/bcInvalidHeaderTestFiller.json b/test/libethereum/BlockTestsFiller/bcInvalidHeaderTestFiller.json similarity index 100% rename from test/bcInvalidHeaderTestFiller.json rename to test/libethereum/BlockTestsFiller/bcInvalidHeaderTestFiller.json diff --git a/test/bcJS_API_TestFiller.json b/test/libethereum/BlockTestsFiller/bcJS_API_TestFiller.json similarity index 100% rename from test/bcJS_API_TestFiller.json rename to test/libethereum/BlockTestsFiller/bcJS_API_TestFiller.json diff --git a/test/bcUncleHeaderValiditiyFiller.json b/test/libethereum/BlockTestsFiller/bcUncleHeaderValiditiyFiller.json similarity index 100% rename from test/bcUncleHeaderValiditiyFiller.json rename to test/libethereum/BlockTestsFiller/bcUncleHeaderValiditiyFiller.json diff --git a/test/bcUncleTestFiller.json b/test/libethereum/BlockTestsFiller/bcUncleTestFiller.json similarity index 100% rename from test/bcUncleTestFiller.json rename to test/libethereum/BlockTestsFiller/bcUncleTestFiller.json diff --git a/test/bcValidBlockTestFiller.json b/test/libethereum/BlockTestsFiller/bcValidBlockTestFiller.json similarity index 100% rename from test/bcValidBlockTestFiller.json rename to test/libethereum/BlockTestsFiller/bcValidBlockTestFiller.json diff --git a/test/libethereum/CMakeLists.txt b/test/libethereum/CMakeLists.txt new file mode 100644 index 000000000..3ceda13b0 --- /dev/null +++ b/test/libethereum/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_policy(SET CMP0015 NEW) + +aux_source_directory(. SRCS) + +add_sources(${SRCS}) diff --git a/test/ClientBase.cpp b/test/libethereum/ClientBase.cpp similarity index 99% rename from test/ClientBase.cpp rename to test/libethereum/ClientBase.cpp index 7597b6612..9ee93779e 100644 --- a/test/ClientBase.cpp +++ b/test/libethereum/ClientBase.cpp @@ -21,7 +21,7 @@ #include #include -#include "TestUtils.h" +#include "../TestUtils.h" using namespace std; using namespace dev; diff --git a/test/ManyFunctions.sol b/test/libethereum/StateTestsFiller/ManyFunctions.sol similarity index 100% rename from test/ManyFunctions.sol rename to test/libethereum/StateTestsFiller/ManyFunctions.sol diff --git a/test/ManyFunctionsGenerator.py b/test/libethereum/StateTestsFiller/ManyFunctionsGenerator.py similarity index 100% rename from test/ManyFunctionsGenerator.py rename to test/libethereum/StateTestsFiller/ManyFunctionsGenerator.py diff --git a/test/stBlockHashTestFiller.json b/test/libethereum/StateTestsFiller/stBlockHashTestFiller.json similarity index 100% rename from test/stBlockHashTestFiller.json rename to test/libethereum/StateTestsFiller/stBlockHashTestFiller.json diff --git a/test/stCallCreateCallCodeTestFiller.json b/test/libethereum/StateTestsFiller/stCallCreateCallCodeTestFiller.json similarity index 100% rename from test/stCallCreateCallCodeTestFiller.json rename to test/libethereum/StateTestsFiller/stCallCreateCallCodeTestFiller.json diff --git a/test/stExampleFiller.json b/test/libethereum/StateTestsFiller/stExampleFiller.json similarity index 100% rename from test/stExampleFiller.json rename to test/libethereum/StateTestsFiller/stExampleFiller.json diff --git a/test/stInitCodeTestFiller.json b/test/libethereum/StateTestsFiller/stInitCodeTestFiller.json similarity index 100% rename from test/stInitCodeTestFiller.json rename to test/libethereum/StateTestsFiller/stInitCodeTestFiller.json diff --git a/test/stLogTestsFiller.json b/test/libethereum/StateTestsFiller/stLogTestsFiller.json similarity index 100% rename from test/stLogTestsFiller.json rename to test/libethereum/StateTestsFiller/stLogTestsFiller.json diff --git a/test/stMemoryStressTestFiller.json b/test/libethereum/StateTestsFiller/stMemoryStressTestFiller.json similarity index 100% rename from test/stMemoryStressTestFiller.json rename to test/libethereum/StateTestsFiller/stMemoryStressTestFiller.json diff --git a/test/stMemoryTestFiller.json b/test/libethereum/StateTestsFiller/stMemoryTestFiller.json similarity index 100% rename from test/stMemoryTestFiller.json rename to test/libethereum/StateTestsFiller/stMemoryTestFiller.json diff --git a/test/stPreCompiledContractsFiller.json b/test/libethereum/StateTestsFiller/stPreCompiledContractsFiller.json similarity index 100% rename from test/stPreCompiledContractsFiller.json rename to test/libethereum/StateTestsFiller/stPreCompiledContractsFiller.json diff --git a/test/stQuadraticComplexityTestFiller.json b/test/libethereum/StateTestsFiller/stQuadraticComplexityTestFiller.json similarity index 100% rename from test/stQuadraticComplexityTestFiller.json rename to test/libethereum/StateTestsFiller/stQuadraticComplexityTestFiller.json diff --git a/test/stRecursiveCreateFiller.json b/test/libethereum/StateTestsFiller/stRecursiveCreateFiller.json similarity index 100% rename from test/stRecursiveCreateFiller.json rename to test/libethereum/StateTestsFiller/stRecursiveCreateFiller.json diff --git a/test/stRefundTestFiller.json b/test/libethereum/StateTestsFiller/stRefundTestFiller.json similarity index 100% rename from test/stRefundTestFiller.json rename to test/libethereum/StateTestsFiller/stRefundTestFiller.json diff --git a/test/stSolidityTestFiller.json b/test/libethereum/StateTestsFiller/stSolidityTestFiller.json similarity index 100% rename from test/stSolidityTestFiller.json rename to test/libethereum/StateTestsFiller/stSolidityTestFiller.json diff --git a/test/stSpecialTestFiller.json b/test/libethereum/StateTestsFiller/stSpecialTestFiller.json similarity index 100% rename from test/stSpecialTestFiller.json rename to test/libethereum/StateTestsFiller/stSpecialTestFiller.json diff --git a/test/stSystemOperationsTestFiller.json b/test/libethereum/StateTestsFiller/stSystemOperationsTestFiller.json similarity index 100% rename from test/stSystemOperationsTestFiller.json rename to test/libethereum/StateTestsFiller/stSystemOperationsTestFiller.json diff --git a/test/stTransactionTestFiller.json b/test/libethereum/StateTestsFiller/stTransactionTestFiller.json similarity index 100% rename from test/stTransactionTestFiller.json rename to test/libethereum/StateTestsFiller/stTransactionTestFiller.json diff --git a/test/tt10mbDataFieldFiller.json b/test/libethereum/TransactionTestsFiller/tt10mbDataFieldFiller.json similarity index 100% rename from test/tt10mbDataFieldFiller.json rename to test/libethereum/TransactionTestsFiller/tt10mbDataFieldFiller.json diff --git a/test/ttTransactionTestFiller.json b/test/libethereum/TransactionTestsFiller/ttTransactionTestFiller.json similarity index 100% rename from test/ttTransactionTestFiller.json rename to test/libethereum/TransactionTestsFiller/ttTransactionTestFiller.json diff --git a/test/blockchain.cpp b/test/libethereum/blockchain.cpp similarity index 96% rename from test/blockchain.cpp rename to test/libethereum/blockchain.cpp index ec8fb7539..92f3c8623 100644 --- a/test/blockchain.cpp +++ b/test/libethereum/blockchain.cpp @@ -24,7 +24,7 @@ #include #include #include -#include "TestHelper.h" +#include "../TestHelper.h" using namespace std; using namespace json_spirit; @@ -655,37 +655,37 @@ BOOST_AUTO_TEST_SUITE(BlockChainTests) BOOST_AUTO_TEST_CASE(bcForkBlockTest) { - dev::test::executeTests("bcForkBlockTest", "/BlockTests", dev::test::doBlockchainTests); + dev::test::executeTests("bcForkBlockTest", "/BlockTests",dev::test::getFolder(__FILE__) + "/BlockTestsFiller", dev::test::doBlockchainTests); } BOOST_AUTO_TEST_CASE(bcInvalidRLPTest) { - dev::test::executeTests("bcInvalidRLPTest", "/BlockTests", dev::test::doBlockchainTests); + dev::test::executeTests("bcInvalidRLPTest", "/BlockTests",dev::test::getFolder(__FILE__) + "/BlockTestsFiller", dev::test::doBlockchainTests); } BOOST_AUTO_TEST_CASE(bcJS_API_Test) { - dev::test::executeTests("bcJS_API_Test", "/BlockTests", dev::test::doBlockchainTests); + dev::test::executeTests("bcJS_API_Test", "/BlockTests",dev::test::getFolder(__FILE__) + "/BlockTestsFiller", dev::test::doBlockchainTests); } BOOST_AUTO_TEST_CASE(bcValidBlockTest) { - dev::test::executeTests("bcValidBlockTest", "/BlockTests", dev::test::doBlockchainTests); + dev::test::executeTests("bcValidBlockTest", "/BlockTests",dev::test::getFolder(__FILE__) + "/BlockTestsFiller", dev::test::doBlockchainTests); } BOOST_AUTO_TEST_CASE(bcInvalidHeaderTest) { - dev::test::executeTests("bcInvalidHeaderTest", "/BlockTests", dev::test::doBlockchainTests); + dev::test::executeTests("bcInvalidHeaderTest", "/BlockTests",dev::test::getFolder(__FILE__) + "/BlockTestsFiller", dev::test::doBlockchainTests); } BOOST_AUTO_TEST_CASE(bcUncleTest) { - dev::test::executeTests("bcUncleTest", "/BlockTests", dev::test::doBlockchainTests); + dev::test::executeTests("bcUncleTest", "/BlockTests",dev::test::getFolder(__FILE__) + "/BlockTestsFiller", dev::test::doBlockchainTests); } BOOST_AUTO_TEST_CASE(bcUncleHeaderValiditiy) { - dev::test::executeTests("bcUncleHeaderValiditiy", "/BlockTests", dev::test::doBlockchainTests); + dev::test::executeTests("bcUncleHeaderValiditiy", "/BlockTests",dev::test::getFolder(__FILE__) + "/BlockTestsFiller", dev::test::doBlockchainTests); } BOOST_AUTO_TEST_CASE(userDefinedFile) diff --git a/test/genesis.cpp b/test/libethereum/genesis.cpp similarity index 97% rename from test/genesis.cpp rename to test/libethereum/genesis.cpp index 5ac3ea2a8..4633a0617 100644 --- a/test/genesis.cpp +++ b/test/libethereum/genesis.cpp @@ -25,10 +25,10 @@ #include -#include "JsonSpiritHeaders.h" +#include "../JsonSpiritHeaders.h" #include #include -#include "TestHelper.h" +#include "../TestHelper.h" using namespace std; using namespace dev; diff --git a/test/state.cpp b/test/libethereum/state.cpp similarity index 77% rename from test/state.cpp rename to test/libethereum/state.cpp index 65f333538..e6811d972 100644 --- a/test/state.cpp +++ b/test/libethereum/state.cpp @@ -23,14 +23,14 @@ #include #include -#include "JsonSpiritHeaders.h" +#include "../JsonSpiritHeaders.h" #include #include #include #include #include #include -#include "TestHelper.h" +#include "../TestHelper.h" using namespace std; using namespace json_spirit; @@ -106,79 +106,79 @@ BOOST_AUTO_TEST_SUITE(StateTests) BOOST_AUTO_TEST_CASE(stExample) { - dev::test::executeTests("stExample", "/StateTests", dev::test::doStateTests); + dev::test::executeTests("stExample", "/StateTests",dev::test::getFolder(__FILE__) + "/StateTestsFiller", dev::test::doStateTests); } BOOST_AUTO_TEST_CASE(stSystemOperationsTest) { - dev::test::executeTests("stSystemOperationsTest", "/StateTests", dev::test::doStateTests); + dev::test::executeTests("stSystemOperationsTest", "/StateTests",dev::test::getFolder(__FILE__) + "/StateTestsFiller", dev::test::doStateTests); } BOOST_AUTO_TEST_CASE(stCallCreateCallCodeTest) { - dev::test::executeTests("stCallCreateCallCodeTest", "/StateTests", dev::test::doStateTests); + dev::test::executeTests("stCallCreateCallCodeTest", "/StateTests",dev::test::getFolder(__FILE__) + "/StateTestsFiller", dev::test::doStateTests); } BOOST_AUTO_TEST_CASE(stPreCompiledContracts) { - dev::test::executeTests("stPreCompiledContracts", "/StateTests", dev::test::doStateTests); + dev::test::executeTests("stPreCompiledContracts", "/StateTests",dev::test::getFolder(__FILE__) + "/StateTestsFiller", dev::test::doStateTests); } BOOST_AUTO_TEST_CASE(stLogTests) { - dev::test::executeTests("stLogTests", "/StateTests", dev::test::doStateTests); + dev::test::executeTests("stLogTests", "/StateTests",dev::test::getFolder(__FILE__) + "/StateTestsFiller", dev::test::doStateTests); } BOOST_AUTO_TEST_CASE(stRecursiveCreate) { - dev::test::executeTests("stRecursiveCreate", "/StateTests", dev::test::doStateTests); + dev::test::executeTests("stRecursiveCreate", "/StateTests",dev::test::getFolder(__FILE__) + "/StateTestsFiller", dev::test::doStateTests); } BOOST_AUTO_TEST_CASE(stInitCodeTest) { - dev::test::executeTests("stInitCodeTest", "/StateTests", dev::test::doStateTests); + dev::test::executeTests("stInitCodeTest", "/StateTests",dev::test::getFolder(__FILE__) + "/StateTestsFiller", dev::test::doStateTests); } BOOST_AUTO_TEST_CASE(stTransactionTest) { - dev::test::executeTests("stTransactionTest", "/StateTests", dev::test::doStateTests); + dev::test::executeTests("stTransactionTest", "/StateTests",dev::test::getFolder(__FILE__) + "/StateTestsFiller", dev::test::doStateTests); } BOOST_AUTO_TEST_CASE(stSpecialTest) { - dev::test::executeTests("stSpecialTest", "/StateTests", dev::test::doStateTests); + dev::test::executeTests("stSpecialTest", "/StateTests",dev::test::getFolder(__FILE__) + "/StateTestsFiller", dev::test::doStateTests); } BOOST_AUTO_TEST_CASE(stRefundTest) { - dev::test::executeTests("stRefundTest", "/StateTests", dev::test::doStateTests); + dev::test::executeTests("stRefundTest", "/StateTests",dev::test::getFolder(__FILE__) + "/StateTestsFiller", dev::test::doStateTests); } BOOST_AUTO_TEST_CASE(stBlockHashTest) { - dev::test::executeTests("stBlockHashTest", "/StateTests", dev::test::doStateTests); + dev::test::executeTests("stBlockHashTest", "/StateTests",dev::test::getFolder(__FILE__) + "/StateTestsFiller", dev::test::doStateTests); } BOOST_AUTO_TEST_CASE(stQuadraticComplexityTest) { if (test::Options::get().quadratic) - dev::test::executeTests("stQuadraticComplexityTest", "/StateTests", dev::test::doStateTests); + dev::test::executeTests("stQuadraticComplexityTest", "/StateTests",dev::test::getFolder(__FILE__) + "/StateTestsFiller", dev::test::doStateTests); } BOOST_AUTO_TEST_CASE(stMemoryStressTest) { if (test::Options::get().memory) - dev::test::executeTests("stMemoryStressTest", "/StateTests", dev::test::doStateTests); + dev::test::executeTests("stMemoryStressTest", "/StateTests",dev::test::getFolder(__FILE__) + "/StateTestsFiller", dev::test::doStateTests); } BOOST_AUTO_TEST_CASE(stSolidityTest) { - dev::test::executeTests("stSolidityTest", "/StateTests", dev::test::doStateTests); + dev::test::executeTests("stSolidityTest", "/StateTests",dev::test::getFolder(__FILE__) + "/StateTestsFiller", dev::test::doStateTests); } BOOST_AUTO_TEST_CASE(stMemoryTest) { - dev::test::executeTests("stMemoryTest", "/StateTests", dev::test::doStateTests); + dev::test::executeTests("stMemoryTest", "/StateTests",dev::test::getFolder(__FILE__) + "/StateTestsFiller", dev::test::doStateTests); } diff --git a/test/stateOriginal.cpp b/test/libethereum/stateOriginal.cpp similarity index 98% rename from test/stateOriginal.cpp rename to test/libethereum/stateOriginal.cpp index 7f3371484..82d6288d6 100644 --- a/test/stateOriginal.cpp +++ b/test/libethereum/stateOriginal.cpp @@ -27,7 +27,7 @@ #include #include #include -#include "TestHelper.h" +#include "../TestHelper.h" using namespace std; using namespace dev; using namespace dev::eth; diff --git a/test/transaction.cpp b/test/libethereum/transaction.cpp similarity index 96% rename from test/transaction.cpp rename to test/libethereum/transaction.cpp index 78a1ac7f7..1a4716725 100644 --- a/test/transaction.cpp +++ b/test/libethereum/transaction.cpp @@ -20,7 +20,7 @@ * Transaaction test functions. */ -#include "TestHelper.h" +#include "../TestHelper.h" using namespace std; using namespace json_spirit; @@ -137,12 +137,12 @@ BOOST_AUTO_TEST_SUITE(TransactionTests) BOOST_AUTO_TEST_CASE(ttTransactionTest) { - dev::test::executeTests("ttTransactionTest", "/TransactionTests", dev::test::doTransactionTests); + dev::test::executeTests("ttTransactionTest", "/TransactionTests",dev::test::getFolder(__FILE__) + "/TransactionTestsFiller", dev::test::doTransactionTests); } BOOST_AUTO_TEST_CASE(ttWrongRLPTransaction) { - dev::test::executeTests("ttWrongRLPTransaction", "/TransactionTests", dev::test::doTransactionTests); + dev::test::executeTests("ttWrongRLPTransaction", "/TransactionTests",dev::test::getFolder(__FILE__) + "/TransactionTestsFiller", dev::test::doTransactionTests); } BOOST_AUTO_TEST_CASE(tt10mbDataField) @@ -151,7 +151,7 @@ BOOST_AUTO_TEST_CASE(tt10mbDataField) { auto start = chrono::steady_clock::now(); - dev::test::executeTests("tt10mbDataField", "/TransactionTests", dev::test::doTransactionTests); + dev::test::executeTests("tt10mbDataField", "/TransactionTests",dev::test::getFolder(__FILE__) + "/TransactionTestsFiller", dev::test::doTransactionTests); auto end = chrono::steady_clock::now(); auto duration(chrono::duration_cast(end - start)); diff --git a/test/libevm/CMakeLists.txt b/test/libevm/CMakeLists.txt new file mode 100644 index 000000000..3ceda13b0 --- /dev/null +++ b/test/libevm/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_policy(SET CMP0015 NEW) + +aux_source_directory(. SRCS) + +add_sources(${SRCS}) diff --git a/test/PerformaceTester.sol b/test/libevm/VMTestsFiller/performanceTester.sol similarity index 100% rename from test/PerformaceTester.sol rename to test/libevm/VMTestsFiller/performanceTester.sol diff --git a/test/vmArithmeticTestFiller.json b/test/libevm/VMTestsFiller/vmArithmeticTestFiller.json similarity index 100% rename from test/vmArithmeticTestFiller.json rename to test/libevm/VMTestsFiller/vmArithmeticTestFiller.json diff --git a/test/vmBitwiseLogicOperationTestFiller.json b/test/libevm/VMTestsFiller/vmBitwiseLogicOperationTestFiller.json similarity index 100% rename from test/vmBitwiseLogicOperationTestFiller.json rename to test/libevm/VMTestsFiller/vmBitwiseLogicOperationTestFiller.json diff --git a/test/vmBlockInfoTestFiller.json b/test/libevm/VMTestsFiller/vmBlockInfoTestFiller.json similarity index 100% rename from test/vmBlockInfoTestFiller.json rename to test/libevm/VMTestsFiller/vmBlockInfoTestFiller.json diff --git a/test/vmEnvironmentalInfoTestFiller.json b/test/libevm/VMTestsFiller/vmEnvironmentalInfoTestFiller.json similarity index 100% rename from test/vmEnvironmentalInfoTestFiller.json rename to test/libevm/VMTestsFiller/vmEnvironmentalInfoTestFiller.json diff --git a/test/vmIOandFlowOperationsTestFiller.json b/test/libevm/VMTestsFiller/vmIOandFlowOperationsTestFiller.json similarity index 100% rename from test/vmIOandFlowOperationsTestFiller.json rename to test/libevm/VMTestsFiller/vmIOandFlowOperationsTestFiller.json diff --git a/test/vmLogTestFiller.json b/test/libevm/VMTestsFiller/vmLogTestFiller.json similarity index 100% rename from test/vmLogTestFiller.json rename to test/libevm/VMTestsFiller/vmLogTestFiller.json diff --git a/test/vmPerformanceTestFiller.json b/test/libevm/VMTestsFiller/vmPerformanceTestFiller.json similarity index 100% rename from test/vmPerformanceTestFiller.json rename to test/libevm/VMTestsFiller/vmPerformanceTestFiller.json diff --git a/test/vmPushDupSwapTestFiller.json b/test/libevm/VMTestsFiller/vmPushDupSwapTestFiller.json similarity index 100% rename from test/vmPushDupSwapTestFiller.json rename to test/libevm/VMTestsFiller/vmPushDupSwapTestFiller.json diff --git a/test/vmSha3TestFiller.json b/test/libevm/VMTestsFiller/vmSha3TestFiller.json similarity index 100% rename from test/vmSha3TestFiller.json rename to test/libevm/VMTestsFiller/vmSha3TestFiller.json diff --git a/test/vmSystemOperationsTestFiller.json b/test/libevm/VMTestsFiller/vmSystemOperationsTestFiller.json similarity index 100% rename from test/vmSystemOperationsTestFiller.json rename to test/libevm/VMTestsFiller/vmSystemOperationsTestFiller.json diff --git a/test/vmtestsFiller.json b/test/libevm/VMTestsFiller/vmtestsFiller.json similarity index 100% rename from test/vmtestsFiller.json rename to test/libevm/VMTestsFiller/vmtestsFiller.json diff --git a/test/vm.cpp b/test/libevm/vm.cpp similarity index 90% rename from test/vm.cpp rename to test/libevm/vm.cpp index 9e21972f1..d0eb532a7 100644 --- a/test/vm.cpp +++ b/test/libevm/vm.cpp @@ -450,76 +450,76 @@ BOOST_AUTO_TEST_SUITE(VMTests) BOOST_AUTO_TEST_CASE(vmtests) { - dev::test::executeTests("vmtests", "/VMTests", dev::test::doVMTests); + dev::test::executeTests("vmtests", "/VMTests",dev::test::getFolder(__FILE__) + "/VMTestsFiller", dev::test::doVMTests); } BOOST_AUTO_TEST_CASE(vmArithmeticTest) { - dev::test::executeTests("vmArithmeticTest", "/VMTests", dev::test::doVMTests); + dev::test::executeTests("vmArithmeticTest", "/VMTests",dev::test::getFolder(__FILE__) + "/VMTestsFiller", dev::test::doVMTests); } BOOST_AUTO_TEST_CASE(vmBitwiseLogicOperationTest) { - dev::test::executeTests("vmBitwiseLogicOperationTest", "/VMTests", dev::test::doVMTests); + dev::test::executeTests("vmBitwiseLogicOperationTest", "/VMTests",dev::test::getFolder(__FILE__) + "/VMTestsFiller", dev::test::doVMTests); } BOOST_AUTO_TEST_CASE(vmSha3Test) { - dev::test::executeTests("vmSha3Test", "/VMTests", dev::test::doVMTests); + dev::test::executeTests("vmSha3Test", "/VMTests",dev::test::getFolder(__FILE__) + "/VMTestsFiller", dev::test::doVMTests); } BOOST_AUTO_TEST_CASE(vmEnvironmentalInfoTest) { - dev::test::executeTests("vmEnvironmentalInfoTest", "/VMTests", dev::test::doVMTests); + dev::test::executeTests("vmEnvironmentalInfoTest", "/VMTests",dev::test::getFolder(__FILE__) + "/VMTestsFiller", dev::test::doVMTests); } BOOST_AUTO_TEST_CASE(vmBlockInfoTest) { - dev::test::executeTests("vmBlockInfoTest", "/VMTests", dev::test::doVMTests); + dev::test::executeTests("vmBlockInfoTest", "/VMTests",dev::test::getFolder(__FILE__) + "/VMTestsFiller", dev::test::doVMTests); } BOOST_AUTO_TEST_CASE(vmIOandFlowOperationsTest) { - dev::test::executeTests("vmIOandFlowOperationsTest", "/VMTests", dev::test::doVMTests); + dev::test::executeTests("vmIOandFlowOperationsTest", "/VMTests",dev::test::getFolder(__FILE__) + "/VMTestsFiller", dev::test::doVMTests); } BOOST_AUTO_TEST_CASE(vmPushDupSwapTest) { - dev::test::executeTests("vmPushDupSwapTest", "/VMTests", dev::test::doVMTests); + dev::test::executeTests("vmPushDupSwapTest", "/VMTests",dev::test::getFolder(__FILE__) + "/VMTestsFiller", dev::test::doVMTests); } BOOST_AUTO_TEST_CASE(vmLogTest) { - dev::test::executeTests("vmLogTest", "/VMTests", dev::test::doVMTests); + dev::test::executeTests("vmLogTest", "/VMTests",dev::test::getFolder(__FILE__) + "/VMTestsFiller", dev::test::doVMTests); } BOOST_AUTO_TEST_CASE(vmSystemOperationsTest) { - dev::test::executeTests("vmSystemOperationsTest", "/VMTests", dev::test::doVMTests); + dev::test::executeTests("vmSystemOperationsTest", "/VMTests",dev::test::getFolder(__FILE__) + "/VMTestsFiller", dev::test::doVMTests); } BOOST_AUTO_TEST_CASE(vmPerformanceTest) { if (test::Options::get().performance) - dev::test::executeTests("vmPerformanceTest", "/VMTests", dev::test::doVMTests); + dev::test::executeTests("vmPerformanceTest", "/VMTests",dev::test::getFolder(__FILE__) + "/VMTestsFiller", dev::test::doVMTests); } BOOST_AUTO_TEST_CASE(vmInputLimitsTest1) { if (test::Options::get().inputLimits) - dev::test::executeTests("vmInputLimits1", "/VMTests", dev::test::doVMTests); + dev::test::executeTests("vmInputLimits1", "/VMTests",dev::test::getFolder(__FILE__) + "/VMTestsFiller", dev::test::doVMTests); } BOOST_AUTO_TEST_CASE(vmInputLimitsTest2) { if (test::Options::get().inputLimits) - dev::test::executeTests("vmInputLimits2", "/VMTests", dev::test::doVMTests); + dev::test::executeTests("vmInputLimits2", "/VMTests",dev::test::getFolder(__FILE__) + "/VMTestsFiller", dev::test::doVMTests); } BOOST_AUTO_TEST_CASE(vmInputLimitsLightTest) { if (test::Options::get().inputLimits) - dev::test::executeTests("vmInputLimitsLight", "/VMTests", dev::test::doVMTests); + dev::test::executeTests("vmInputLimitsLight", "/VMTests",dev::test::getFolder(__FILE__) + "/VMTestsFiller", dev::test::doVMTests); } BOOST_AUTO_TEST_CASE(vmRandom) diff --git a/test/vm.h b/test/libevm/vm.h similarity index 99% rename from test/vm.h rename to test/libevm/vm.h index 1c0190b69..2bfc68d56 100644 --- a/test/vm.h +++ b/test/libevm/vm.h @@ -38,7 +38,7 @@ along with cpp-ethereum. If not, see . #include #include #include -#include "TestHelper.h" +#include "../TestHelper.h" namespace dev { namespace test { diff --git a/test/Assembly.cpp b/test/libevmcore/Assembly.cpp similarity index 100% rename from test/Assembly.cpp rename to test/libevmcore/Assembly.cpp diff --git a/test/libevmcore/CMakeLists.txt b/test/libevmcore/CMakeLists.txt new file mode 100644 index 000000000..3ceda13b0 --- /dev/null +++ b/test/libevmcore/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_policy(SET CMP0015 NEW) + +aux_source_directory(. SRCS) + +add_sources(${SRCS}) diff --git a/test/libnatspec/CMakeLists.txt b/test/libnatspec/CMakeLists.txt new file mode 100644 index 000000000..3ceda13b0 --- /dev/null +++ b/test/libnatspec/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_policy(SET CMP0015 NEW) + +aux_source_directory(. SRCS) + +add_sources(${SRCS}) diff --git a/test/natspec.cpp b/test/libnatspec/natspec.cpp similarity index 100% rename from test/natspec.cpp rename to test/libnatspec/natspec.cpp diff --git a/test/libp2p/CMakeLists.txt b/test/libp2p/CMakeLists.txt new file mode 100644 index 000000000..3ceda13b0 --- /dev/null +++ b/test/libp2p/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_policy(SET CMP0015 NEW) + +aux_source_directory(. SRCS) + +add_sources(${SRCS}) diff --git a/test/libp2p/net.cpp b/test/libp2p/net.cpp new file mode 100644 index 000000000..9a5dbb32f --- /dev/null +++ b/test/libp2p/net.cpp @@ -0,0 +1,372 @@ +/* + 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 net.cpp + * @author Alex Leverington + * @date 2014 + */ + +#include + +#include +#include +#include +#include +#include +using namespace std; +using namespace dev; +using namespace dev::p2p; +namespace ba = boost::asio; +namespace bi = ba::ip; + +struct NetFixture +{ + NetFixture() { dev::p2p::NodeIPEndpoint::test_allowLocal = true; } + ~NetFixture() { dev::p2p::NodeIPEndpoint::test_allowLocal = false; } +}; + +BOOST_FIXTURE_TEST_SUITE(net, NetFixture) + +/** + * Only used for testing. Not useful beyond tests. + */ +class TestHost: public Worker +{ +public: + TestHost(): Worker("test",0), m_io() {}; + virtual ~TestHost() { m_io.stop(); stopWorking(); } + void start() { startWorking(); } + void doWork() { m_io.run(); } + void doneWorking() { m_io.reset(); m_io.poll(); m_io.reset(); } + +protected: + ba::io_service m_io; +}; + +struct TestNodeTable: public NodeTable +{ + /// Constructor + TestNodeTable(ba::io_service& _io, KeyPair _alias, bi::address const& _addr, uint16_t _port = 30300): NodeTable(_io, _alias, NodeIPEndpoint(_addr, _port, _port)) {} + + static std::vector> createTestNodes(unsigned _count) + { + std::vector> ret; + asserts(_count < 1000); + static uint16_t s_basePort = 30500; + + ret.clear(); + for (unsigned i = 0; i < _count; i++) + { + KeyPair k = KeyPair::create(); + ret.push_back(make_pair(k,s_basePort+i)); + } + + return std::move(ret); + } + + void pingTestNodes(std::vector> const& _testNodes) + { + bi::address ourIp = bi::address::from_string("127.0.0.1"); + for (auto& n: _testNodes) + { + ping(bi::udp::endpoint(ourIp, n.second)); + this_thread::sleep_for(chrono::milliseconds(2)); + } + } + + void populateTestNodes(std::vector> const& _testNodes, size_t _count = 0) + { + if (!_count) + _count = _testNodes.size(); + + bi::address ourIp = bi::address::from_string("127.0.0.1"); + for (auto& n: _testNodes) + if (_count--) + { + // manually add node for test + { + Guard ln(x_nodes); + shared_ptr node(new NodeEntry(m_node, n.first.pub(), NodeIPEndpoint(ourIp, n.second, n.second))); + node->pending = false; + m_nodes[node->id] = node; + } + noteActiveNode(n.first.pub(), bi::udp::endpoint(ourIp, n.second)); + } + else + break; + } + + void reset() + { + Guard l(x_state); + for (auto& n: m_state) n.nodes.clear(); + } +}; + +/** + * Only used for testing. Not useful beyond tests. + */ +struct TestNodeTableHost: public TestHost +{ + TestNodeTableHost(unsigned _count = 8): m_alias(KeyPair::create()), nodeTable(new TestNodeTable(m_io, m_alias, bi::address::from_string("127.0.0.1"))), testNodes(TestNodeTable::createTestNodes(_count)) {}; + ~TestNodeTableHost() { m_io.stop(); stopWorking(); } + + void setup() { for (auto n: testNodes) nodeTables.push_back(make_shared(m_io,n.first, bi::address::from_string("127.0.0.1"),n.second)); } + + void pingAll() { for (auto& t: nodeTables) t->pingTestNodes(testNodes); } + + void populateAll(size_t _count = 0) { for (auto& t: nodeTables) t->populateTestNodes(testNodes, _count); } + + void populate(size_t _count = 0) { nodeTable->populateTestNodes(testNodes, _count); } + + KeyPair m_alias; + shared_ptr nodeTable; + std::vector> testNodes; // keypair and port + std::vector> nodeTables; +}; + +class TestUDPSocket: UDPSocketEvents, public TestHost +{ +public: + TestUDPSocket(): m_socket(new UDPSocket(m_io, *this, 30300)) {} + + void onDisconnected(UDPSocketFace*) {}; + void onReceived(UDPSocketFace*, bi::udp::endpoint const&, bytesConstRef _packet) { if (_packet.toString() == "AAAA") success = true; } + + shared_ptr> m_socket; + + bool success = false; +}; + +BOOST_AUTO_TEST_CASE(requestTimeout) +{ + using TimePoint = std::chrono::steady_clock::time_point; + using RequestTimeout = std::pair; + + std::chrono::milliseconds timeout(300); + std::list timeouts; + + NodeId nodeA(sha3("a")); + NodeId nodeB(sha3("b")); + timeouts.push_back(make_pair(nodeA, chrono::steady_clock::now())); + this_thread::sleep_for(std::chrono::milliseconds(100)); + timeouts.push_back(make_pair(nodeB, chrono::steady_clock::now())); + this_thread::sleep_for(std::chrono::milliseconds(210)); + + bool nodeAtriggered = false; + bool nodeBtriggered = false; + timeouts.remove_if([&](RequestTimeout const& t) + { + auto now = chrono::steady_clock::now(); + auto diff = now - t.second; + if (t.first == nodeA && diff < timeout) + nodeAtriggered = true; + if (t.first == nodeB && diff < timeout) + nodeBtriggered = true; + return (t.first == nodeA || t.first == nodeB); + }); + + BOOST_REQUIRE(nodeAtriggered == false); + BOOST_REQUIRE(nodeBtriggered == true); + BOOST_REQUIRE(timeouts.size() == 0); +} + +BOOST_AUTO_TEST_CASE(isIPAddressType) +{ + string wildcard = "0.0.0.0"; + BOOST_REQUIRE(bi::address::from_string(wildcard).is_unspecified()); + + string empty = ""; + BOOST_REQUIRE_THROW(bi::address::from_string(empty).is_unspecified(), std::exception); + + string publicAddress192 = "192.169.0.0"; + BOOST_REQUIRE(isPublicAddress(publicAddress192)); + BOOST_REQUIRE(!isPrivateAddress(publicAddress192)); + BOOST_REQUIRE(!isLocalHostAddress(publicAddress192)); + + string publicAddress172 = "172.32.0.0"; + BOOST_REQUIRE(isPublicAddress(publicAddress172)); + BOOST_REQUIRE(!isPrivateAddress(publicAddress172)); + BOOST_REQUIRE(!isLocalHostAddress(publicAddress172)); + + string privateAddress192 = "192.168.1.0"; + BOOST_REQUIRE(isPrivateAddress(privateAddress192)); + BOOST_REQUIRE(!isPublicAddress(privateAddress192)); + BOOST_REQUIRE(!isLocalHostAddress(privateAddress192)); + + string privateAddress172 = "172.16.0.0"; + BOOST_REQUIRE(isPrivateAddress(privateAddress172)); + BOOST_REQUIRE(!isPublicAddress(privateAddress172)); + BOOST_REQUIRE(!isLocalHostAddress(privateAddress172)); + + string privateAddress10 = "10.0.0.0"; + BOOST_REQUIRE(isPrivateAddress(privateAddress10)); + BOOST_REQUIRE(!isPublicAddress(privateAddress10)); + BOOST_REQUIRE(!isLocalHostAddress(privateAddress10)); +} + +BOOST_AUTO_TEST_CASE(v2PingNodePacket) +{ + // test old versino of pingNode packet w/new + RLPStream s; + s.appendList(3); s << "1.1.1.1" << 30303 << std::chrono::duration_cast((std::chrono::system_clock::now() + chrono::seconds(60)).time_since_epoch()).count(); + + PingNode p((bi::udp::endpoint())); + BOOST_REQUIRE_NO_THROW(p = PingNode::fromBytesConstRef(bi::udp::endpoint(), bytesConstRef(&s.out()))); + BOOST_REQUIRE(p.version == 2); +} + +BOOST_AUTO_TEST_CASE(neighboursPacketLength) +{ + KeyPair k = KeyPair::create(); + std::vector> testNodes(TestNodeTable::createTestNodes(16)); + bi::udp::endpoint to(boost::asio::ip::address::from_string("127.0.0.1"), 30000); + + // hash(32), signature(65), overhead: packet(2), type(1), nodeList(2), ts(9), + static unsigned const nlimit = (1280 - 111) / 87; + for (unsigned offset = 0; offset < testNodes.size(); offset += nlimit) + { + Neighbours out(to); + + auto limit = nlimit ? std::min(testNodes.size(), (size_t)(offset + nlimit)) : testNodes.size(); + for (auto i = offset; i < limit; i++) + { + Neighbours::Node node; + node.ipAddress = boost::asio::ip::address::from_string("200.200.200.200").to_string(); + node.udpPort = testNodes[i].second; + node.node = testNodes[i].first.pub(); + out.nodes.push_back(node); + } + + out.sign(k.sec()); + BOOST_REQUIRE_LE(out.data.size(), 1280); + } +} + +BOOST_AUTO_TEST_CASE(test_neighbours_packet) +{ + KeyPair k = KeyPair::create(); + std::vector> testNodes(TestNodeTable::createTestNodes(16)); + bi::udp::endpoint to(boost::asio::ip::address::from_string("127.0.0.1"), 30000); + + Neighbours out(to); + for (auto n: testNodes) + { + Neighbours::Node node; + node.ipAddress = boost::asio::ip::address::from_string("127.0.0.1").to_string(); + node.udpPort = n.second; + node.node = n.first.pub(); + out.nodes.push_back(node); + } + out.sign(k.sec()); + + bytesConstRef packet(out.data.data(), out.data.size()); + bytesConstRef rlpBytes(packet.cropped(h256::size + Signature::size + 1)); + Neighbours in = Neighbours::fromBytesConstRef(to, rlpBytes); + int count = 0; + for (auto n: in.nodes) + { + BOOST_REQUIRE_EQUAL(testNodes[count].second, n.udpPort); + BOOST_REQUIRE_EQUAL(testNodes[count].first.pub(), n.node); + BOOST_REQUIRE_EQUAL(sha3(testNodes[count].first.pub()), sha3(n.node)); + count++; + } +} + +BOOST_AUTO_TEST_CASE(test_findnode_neighbours) +{ + // Executing findNode should result in a list which is serialized + // into Neighbours packet. Neighbours packet should then be deserialized + // into the same list of nearest nodes. +} + +BOOST_AUTO_TEST_CASE(test_windows_template) +{ + bi::udp::endpoint ep; + PingNode p(ep); +} + +BOOST_AUTO_TEST_CASE(kademlia) +{ + // Not yet a 'real' test. + TestNodeTableHost node(8); + node.start(); + node.nodeTable->discover(); // ideally, joining with empty node table logs warning we can check for + node.setup(); + node.populate(); + clog << "NodeTable:\n" << *node.nodeTable.get() << endl; + + node.populateAll(); + clog << "NodeTable:\n" << *node.nodeTable.get() << endl; + + auto nodes = node.nodeTable->nodes(); + nodes.sort(); + + node.nodeTable->reset(); + clog << "NodeTable:\n" << *node.nodeTable.get() << endl; + + node.populate(1); + clog << "NodeTable:\n" << *node.nodeTable.get() << endl; + + node.nodeTable->discover(); + this_thread::sleep_for(chrono::milliseconds(2000)); + clog << "NodeTable:\n" << *node.nodeTable.get() << endl; + + BOOST_REQUIRE_EQUAL(node.nodeTable->count(), 8); + + auto netNodes = node.nodeTable->nodes(); + netNodes.sort(); + +} + +BOOST_AUTO_TEST_CASE(test_udp_once) +{ + UDPDatagram d(bi::udp::endpoint(boost::asio::ip::address::from_string("127.0.0.1"), 30300), bytes({65,65,65,65})); + TestUDPSocket a; a.m_socket->connect(); a.start(); + a.m_socket->send(d); + this_thread::sleep_for(chrono::seconds(1)); + BOOST_REQUIRE_EQUAL(true, a.success); +} + +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(netTypes) + +BOOST_AUTO_TEST_CASE(unspecifiedNode) +{ + Node n = UnspecifiedNode; + BOOST_REQUIRE(!n); + + Node node(Public(sha3("0")), NodeIPEndpoint(bi::address(), 0, 0)); + BOOST_REQUIRE(node); + BOOST_REQUIRE(n != node); + + Node nodeEq(Public(sha3("0")), NodeIPEndpoint(bi::address(), 0, 0)); + BOOST_REQUIRE_EQUAL(node, nodeEq); +} + +BOOST_AUTO_TEST_CASE(nodeTableReturnsUnspecifiedNode) +{ + ba::io_service io; + NodeTable t(io, KeyPair::create(), NodeIPEndpoint(bi::address::from_string("127.0.0.1"), 30303, 30303)); + if (Node n = t.node(NodeId())) + BOOST_REQUIRE(false); + else + BOOST_REQUIRE(n == UnspecifiedNode); +} + +BOOST_AUTO_TEST_SUITE_END() + diff --git a/test/peer.cpp b/test/libp2p/peer.cpp similarity index 100% rename from test/peer.cpp rename to test/libp2p/peer.cpp diff --git a/test/rlpx.cpp b/test/libp2p/rlpx.cpp similarity index 100% rename from test/rlpx.cpp rename to test/libp2p/rlpx.cpp diff --git a/test/libsolidity/CMakeLists.txt b/test/libsolidity/CMakeLists.txt new file mode 100644 index 000000000..3ceda13b0 --- /dev/null +++ b/test/libsolidity/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_policy(SET CMP0015 NEW) + +aux_source_directory(. SRCS) + +add_sources(${SRCS}) diff --git a/test/SolidityABIJSON.cpp b/test/libsolidity/SolidityABIJSON.cpp similarity index 99% rename from test/SolidityABIJSON.cpp rename to test/libsolidity/SolidityABIJSON.cpp index bbe5fd8c4..b0633cca1 100644 --- a/test/SolidityABIJSON.cpp +++ b/test/libsolidity/SolidityABIJSON.cpp @@ -21,7 +21,7 @@ */ #if ETH_SOLIDITY -#include "TestHelper.h" +#include "../TestHelper.h" #include #include #include diff --git a/test/SolidityCompiler.cpp b/test/libsolidity/SolidityCompiler.cpp similarity index 100% rename from test/SolidityCompiler.cpp rename to test/libsolidity/SolidityCompiler.cpp diff --git a/test/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp similarity index 99% rename from test/SolidityEndToEndTest.cpp rename to test/libsolidity/SolidityEndToEndTest.cpp index 3764949d9..c345f5204 100644 --- a/test/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include using namespace std; diff --git a/test/SolidityExpressionCompiler.cpp b/test/libsolidity/SolidityExpressionCompiler.cpp similarity index 99% rename from test/SolidityExpressionCompiler.cpp rename to test/libsolidity/SolidityExpressionCompiler.cpp index b748d887d..505cac991 100644 --- a/test/SolidityExpressionCompiler.cpp +++ b/test/libsolidity/SolidityExpressionCompiler.cpp @@ -31,7 +31,7 @@ #include #include #include -#include "TestHelper.h" +#include "../TestHelper.h" using namespace std; diff --git a/test/SolidityInterface.cpp b/test/libsolidity/SolidityInterface.cpp similarity index 99% rename from test/SolidityInterface.cpp rename to test/libsolidity/SolidityInterface.cpp index c836f0fa7..ab6cb9029 100644 --- a/test/SolidityInterface.cpp +++ b/test/libsolidity/SolidityInterface.cpp @@ -22,7 +22,7 @@ #if ETH_SOLIDITY -#include "TestHelper.h" +#include "../TestHelper.h" #include #include diff --git a/test/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp similarity index 99% rename from test/SolidityNameAndTypeResolution.cpp rename to test/libsolidity/SolidityNameAndTypeResolution.cpp index c1a274b0c..917ea0007 100644 --- a/test/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -31,7 +31,7 @@ #include #include #include -#include "TestHelper.h" +#include "../TestHelper.h" using namespace std; diff --git a/test/SolidityNatspecJSON.cpp b/test/libsolidity/SolidityNatspecJSON.cpp similarity index 99% rename from test/SolidityNatspecJSON.cpp rename to test/libsolidity/SolidityNatspecJSON.cpp index 28d657357..99adcf199 100644 --- a/test/SolidityNatspecJSON.cpp +++ b/test/libsolidity/SolidityNatspecJSON.cpp @@ -22,7 +22,7 @@ #if ETH_SOLIDITY -#include "TestHelper.h" +#include "../TestHelper.h" #include #include #include diff --git a/test/SolidityOptimizer.cpp b/test/libsolidity/SolidityOptimizer.cpp similarity index 99% rename from test/SolidityOptimizer.cpp rename to test/libsolidity/SolidityOptimizer.cpp index f57380acd..8ab1de8f1 100644 --- a/test/SolidityOptimizer.cpp +++ b/test/libsolidity/SolidityOptimizer.cpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/test/SolidityParser.cpp b/test/libsolidity/SolidityParser.cpp similarity index 99% rename from test/SolidityParser.cpp rename to test/libsolidity/SolidityParser.cpp index 7cd8efce1..7baa12921 100644 --- a/test/SolidityParser.cpp +++ b/test/libsolidity/SolidityParser.cpp @@ -28,7 +28,7 @@ #include #include #include -#include "TestHelper.h" +#include "../TestHelper.h" using namespace std; diff --git a/test/SolidityScanner.cpp b/test/libsolidity/SolidityScanner.cpp similarity index 100% rename from test/SolidityScanner.cpp rename to test/libsolidity/SolidityScanner.cpp diff --git a/test/SolidityTypes.cpp b/test/libsolidity/SolidityTypes.cpp similarity index 100% rename from test/SolidityTypes.cpp rename to test/libsolidity/SolidityTypes.cpp diff --git a/test/solidityExecutionFramework.h b/test/libsolidity/solidityExecutionFramework.h similarity index 99% rename from test/solidityExecutionFramework.h rename to test/libsolidity/solidityExecutionFramework.h index 2134d424d..f76465f23 100644 --- a/test/solidityExecutionFramework.h +++ b/test/libsolidity/solidityExecutionFramework.h @@ -24,7 +24,7 @@ #include #include -#include "TestHelper.h" +#include "../TestHelper.h" #include #include #include diff --git a/test/AccountHolder.cpp b/test/libweb3jsonrpc/AccountHolder.cpp similarity index 100% rename from test/AccountHolder.cpp rename to test/libweb3jsonrpc/AccountHolder.cpp diff --git a/test/libweb3jsonrpc/CMakeLists.txt b/test/libweb3jsonrpc/CMakeLists.txt new file mode 100644 index 000000000..3ceda13b0 --- /dev/null +++ b/test/libweb3jsonrpc/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_policy(SET CMP0015 NEW) + +aux_source_directory(. SRCS) + +add_sources(${SRCS}) diff --git a/test/jsonrpc.cpp b/test/libweb3jsonrpc/jsonrpc.cpp similarity index 99% rename from test/jsonrpc.cpp rename to test/libweb3jsonrpc/jsonrpc.cpp index eaa9edc45..f3e702653 100644 --- a/test/jsonrpc.cpp +++ b/test/libweb3jsonrpc/jsonrpc.cpp @@ -34,8 +34,8 @@ #include #include #include -#include "JsonSpiritHeaders.h" -#include "TestHelper.h" +#include "../JsonSpiritHeaders.h" +#include "../TestHelper.h" #include "webthreestubclient.h" BOOST_AUTO_TEST_SUITE(jsonrpc) diff --git a/test/libweb3jsonrpc/webthreestubclient.h b/test/libweb3jsonrpc/webthreestubclient.h new file mode 100644 index 000000000..fd71bfb5d --- /dev/null +++ b/test/libweb3jsonrpc/webthreestubclient.h @@ -0,0 +1,596 @@ +/** + * This file is generated by jsonrpcstub, DO NOT CHANGE IT MANUALLY! + */ + +#ifndef JSONRPC_CPP_STUB_WEBTHREESTUBCLIENT_H_ +#define JSONRPC_CPP_STUB_WEBTHREESTUBCLIENT_H_ + +#include + +class WebThreeStubClient : public jsonrpc::Client +{ + public: + WebThreeStubClient(jsonrpc::IClientConnector &conn, jsonrpc::clientVersion_t type = jsonrpc::JSONRPC_CLIENT_V2) : jsonrpc::Client(conn, type) {} + + std::string web3_sha3(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("web3_sha3",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string web3_clientVersion() throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p = Json::nullValue; + Json::Value result = this->CallMethod("web3_clientVersion",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string net_version() throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p = Json::nullValue; + Json::Value result = this->CallMethod("net_version",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string net_peerCount() throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p = Json::nullValue; + Json::Value result = this->CallMethod("net_peerCount",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + bool net_listening() throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p = Json::nullValue; + Json::Value result = this->CallMethod("net_listening",p); + if (result.isBool()) + return result.asBool(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_protocolVersion() throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p = Json::nullValue; + Json::Value result = this->CallMethod("eth_protocolVersion",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_hashrate() throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p = Json::nullValue; + Json::Value result = this->CallMethod("eth_hashrate",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_coinbase() throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p = Json::nullValue; + Json::Value result = this->CallMethod("eth_coinbase",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + bool eth_mining() throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p = Json::nullValue; + Json::Value result = this->CallMethod("eth_mining",p); + if (result.isBool()) + return result.asBool(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_gasPrice() throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p = Json::nullValue; + Json::Value result = this->CallMethod("eth_gasPrice",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + Json::Value eth_accounts() throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p = Json::nullValue; + Json::Value result = this->CallMethod("eth_accounts",p); + if (result.isArray()) + return result; + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_blockNumber() throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p = Json::nullValue; + Json::Value result = this->CallMethod("eth_blockNumber",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_getBalance(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + p.append(param2); + Json::Value result = this->CallMethod("eth_getBalance",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_getStorageAt(const std::string& param1, const std::string& param2, const std::string& param3) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + p.append(param2); + p.append(param3); + Json::Value result = this->CallMethod("eth_getStorageAt",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_getTransactionCount(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + p.append(param2); + Json::Value result = this->CallMethod("eth_getTransactionCount",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_getBlockTransactionCountByHash(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_getBlockTransactionCountByHash",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_getBlockTransactionCountByNumber(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_getBlockTransactionCountByNumber",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_getUncleCountByBlockHash(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_getUncleCountByBlockHash",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_getUncleCountByBlockNumber(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_getUncleCountByBlockNumber",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_getCode(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + p.append(param2); + Json::Value result = this->CallMethod("eth_getCode",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_sendTransaction(const Json::Value& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_sendTransaction",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_call(const Json::Value& param1, const std::string& param2) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + p.append(param2); + Json::Value result = this->CallMethod("eth_call",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + bool eth_flush() throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p = Json::nullValue; + Json::Value result = this->CallMethod("eth_flush",p); + if (result.isBool()) + return result.asBool(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + Json::Value eth_getBlockByHash(const std::string& param1, bool param2) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + p.append(param2); + Json::Value result = this->CallMethod("eth_getBlockByHash",p); + if (result.isObject()) + return result; + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + Json::Value eth_getBlockByNumber(const std::string& param1, bool param2) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + p.append(param2); + Json::Value result = this->CallMethod("eth_getBlockByNumber",p); + if (result.isObject()) + return result; + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + Json::Value eth_getTransactionByHash(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_getTransactionByHash",p); + if (result.isObject()) + return result; + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + Json::Value eth_getTransactionByBlockHashAndIndex(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + p.append(param2); + Json::Value result = this->CallMethod("eth_getTransactionByBlockHashAndIndex",p); + if (result.isObject()) + return result; + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + Json::Value eth_getTransactionByBlockNumberAndIndex(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + p.append(param2); + Json::Value result = this->CallMethod("eth_getTransactionByBlockNumberAndIndex",p); + if (result.isObject()) + return result; + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + Json::Value eth_getUncleByBlockHashAndIndex(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + p.append(param2); + Json::Value result = this->CallMethod("eth_getUncleByBlockHashAndIndex",p); + if (result.isObject()) + return result; + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + Json::Value eth_getUncleByBlockNumberAndIndex(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + p.append(param2); + Json::Value result = this->CallMethod("eth_getUncleByBlockNumberAndIndex",p); + if (result.isObject()) + return result; + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + Json::Value eth_getCompilers() throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p = Json::nullValue; + Json::Value result = this->CallMethod("eth_getCompilers",p); + if (result.isArray()) + return result; + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_compileLLL(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_compileLLL",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_compileSerpent(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_compileSerpent",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_compileSolidity(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_compileSolidity",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_newFilter(const Json::Value& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_newFilter",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_newBlockFilter(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_newBlockFilter",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + bool eth_uninstallFilter(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_uninstallFilter",p); + if (result.isBool()) + return result.asBool(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + Json::Value eth_getFilterChanges(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_getFilterChanges",p); + if (result.isArray()) + return result; + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + Json::Value eth_getFilterLogs(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_getFilterLogs",p); + if (result.isArray()) + return result; + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + Json::Value eth_getLogs(const Json::Value& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_getLogs",p); + if (result.isArray()) + return result; + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + Json::Value eth_getWork() throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p = Json::nullValue; + Json::Value result = this->CallMethod("eth_getWork",p); + if (result.isArray()) + return result; + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + bool eth_submitWork(const std::string& param1, const std::string& param2, const std::string& param3) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + p.append(param2); + p.append(param3); + Json::Value result = this->CallMethod("eth_submitWork",p); + if (result.isBool()) + return result.asBool(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_register(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_register",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + bool eth_unregister(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_unregister",p); + if (result.isBool()) + return result.asBool(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + Json::Value eth_fetchQueuedTransactions(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_fetchQueuedTransactions",p); + if (result.isArray()) + return result; + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + bool db_put(const std::string& param1, const std::string& param2, const std::string& param3) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + p.append(param2); + p.append(param3); + Json::Value result = this->CallMethod("db_put",p); + if (result.isBool()) + return result.asBool(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string db_get(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + p.append(param2); + Json::Value result = this->CallMethod("db_get",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + bool shh_post(const Json::Value& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("shh_post",p); + if (result.isBool()) + return result.asBool(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string shh_newIdentity() throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p = Json::nullValue; + Json::Value result = this->CallMethod("shh_newIdentity",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + bool shh_hasIdentity(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("shh_hasIdentity",p); + if (result.isBool()) + return result.asBool(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string shh_newGroup(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + p.append(param2); + Json::Value result = this->CallMethod("shh_newGroup",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string shh_addToGroup(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + p.append(param2); + Json::Value result = this->CallMethod("shh_addToGroup",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string shh_newFilter(const Json::Value& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("shh_newFilter",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + bool shh_uninstallFilter(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("shh_uninstallFilter",p); + if (result.isBool()) + return result.asBool(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + Json::Value shh_getFilterChanges(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("shh_getFilterChanges",p); + if (result.isArray()) + return result; + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + Json::Value shh_getMessages(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("shh_getMessages",p); + if (result.isArray()) + return result; + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } +}; + +#endif //JSONRPC_CPP_STUB_WEBTHREESTUBCLIENT_H_ diff --git a/test/libwhisper/CMakeLists.txt b/test/libwhisper/CMakeLists.txt new file mode 100644 index 000000000..3ceda13b0 --- /dev/null +++ b/test/libwhisper/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_policy(SET CMP0015 NEW) + +aux_source_directory(. SRCS) + +add_sources(${SRCS}) diff --git a/test/whisperTopic.cpp b/test/libwhisper/whisperTopic.cpp similarity index 100% rename from test/whisperTopic.cpp rename to test/libwhisper/whisperTopic.cpp diff --git a/test/randomTestFiller.json b/test/randomTestFiller.json deleted file mode 100644 index 0712cc40f..000000000 --- a/test/randomTestFiller.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "randomVMtest": { - "env" : { - "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", - "currentNumber" : "0", - "currentGasLimit" : "1000000", - "currentDifficulty" : "256", - "currentTimestamp" : 1, - "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" - }, - "pre" : { - "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", - "nonce" : "0", - "code" : "random", - "storage": {} - } - }, - "exec" : { - "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", - "value" : "1000000000000000000", - "data" : "", - "gasPrice" : "100000000000000", - "gas" : "10000" - } - } -}