Browse Source

Restructure test folders

cl-refactor
CJentzsch 10 years ago
parent
commit
338e5bd088
  1. 0
      libdevcrypto/trie.cpp
  2. 0
      libp2p/net.cpp
  3. 6
      libtestutils/Common.cpp
  4. 1
      libtestutils/Common.h
  5. 89
      test/CMakeLists.txt
  6. 10
      test/TestHelper.cpp
  7. 3
      test/TestHelper.h
  8. 0
      test/deprecated/fork.cpp
  9. 0
      test/deprecated/kademlia.cpp
  10. 0
      test/deprecated/main.cpp
  11. 0
      test/deprecated/txTest.cpp
  12. 31
      test/fuzzTesting/CMakeLists.txt
  13. 2
      test/fuzzTesting/checkRandomStateTest.cpp
  14. 3
      test/fuzzTesting/checkRandomVMTest.cpp
  15. 4
      test/fuzzTesting/createRandomStateTest.cpp
  16. 2
      test/fuzzTesting/createRandomVMTest.cpp
  17. 5
      test/libdevcore/CMakeLists.txt
  18. 4
      test/libdevcore/rlp.cpp
  19. 5
      test/libdevcrypto/CMakeLists.txt
  20. 0
      test/libdevcrypto/MemTrie.cpp
  21. 0
      test/libdevcrypto/MemTrie.h
  22. 0
      test/libdevcrypto/TrieHash.cpp
  23. 0
      test/libdevcrypto/TrieHash.h
  24. 0
      test/libdevcrypto/crypto.cpp
  25. 4
      test/libdevcrypto/hexPrefix.cpp
  26. 553
      test/libdevcrypto/trie.cpp
  27. 5
      test/libethcore/CMakeLists.txt
  28. 0
      test/libethcore/commonjs.cpp
  29. 4
      test/libethcore/dagger.cpp
  30. 0
      test/libethereum/BlockTestsFiller/bcInvalidHeaderTestFiller.json
  31. 0
      test/libethereum/BlockTestsFiller/bcJS_API_TestFiller.json
  32. 0
      test/libethereum/BlockTestsFiller/bcUncleHeaderValiditiyFiller.json
  33. 0
      test/libethereum/BlockTestsFiller/bcUncleTestFiller.json
  34. 0
      test/libethereum/BlockTestsFiller/bcValidBlockTestFiller.json
  35. 5
      test/libethereum/CMakeLists.txt
  36. 2
      test/libethereum/ClientBase.cpp
  37. 0
      test/libethereum/StateTestsFiller/ManyFunctions.sol
  38. 0
      test/libethereum/StateTestsFiller/ManyFunctionsGenerator.py
  39. 0
      test/libethereum/StateTestsFiller/stBlockHashTestFiller.json
  40. 0
      test/libethereum/StateTestsFiller/stCallCreateCallCodeTestFiller.json
  41. 0
      test/libethereum/StateTestsFiller/stExampleFiller.json
  42. 0
      test/libethereum/StateTestsFiller/stInitCodeTestFiller.json
  43. 0
      test/libethereum/StateTestsFiller/stLogTestsFiller.json
  44. 0
      test/libethereum/StateTestsFiller/stMemoryStressTestFiller.json
  45. 0
      test/libethereum/StateTestsFiller/stMemoryTestFiller.json
  46. 0
      test/libethereum/StateTestsFiller/stPreCompiledContractsFiller.json
  47. 0
      test/libethereum/StateTestsFiller/stQuadraticComplexityTestFiller.json
  48. 0
      test/libethereum/StateTestsFiller/stRecursiveCreateFiller.json
  49. 0
      test/libethereum/StateTestsFiller/stRefundTestFiller.json
  50. 0
      test/libethereum/StateTestsFiller/stSolidityTestFiller.json
  51. 0
      test/libethereum/StateTestsFiller/stSpecialTestFiller.json
  52. 0
      test/libethereum/StateTestsFiller/stSystemOperationsTestFiller.json
  53. 0
      test/libethereum/StateTestsFiller/stTransactionTestFiller.json
  54. 0
      test/libethereum/TransactionTestsFiller/tt10mbDataFieldFiller.json
  55. 0
      test/libethereum/TransactionTestsFiller/ttTransactionTestFiller.json
  56. 16
      test/libethereum/blockchain.cpp
  57. 4
      test/libethereum/genesis.cpp
  58. 34
      test/libethereum/state.cpp
  59. 2
      test/libethereum/stateOriginal.cpp
  60. 8
      test/libethereum/transaction.cpp
  61. 5
      test/libevm/CMakeLists.txt
  62. 0
      test/libevm/VMTestsFiller/performanceTester.sol
  63. 0
      test/libevm/VMTestsFiller/vmArithmeticTestFiller.json
  64. 0
      test/libevm/VMTestsFiller/vmBitwiseLogicOperationTestFiller.json
  65. 0
      test/libevm/VMTestsFiller/vmBlockInfoTestFiller.json
  66. 0
      test/libevm/VMTestsFiller/vmEnvironmentalInfoTestFiller.json
  67. 0
      test/libevm/VMTestsFiller/vmIOandFlowOperationsTestFiller.json
  68. 0
      test/libevm/VMTestsFiller/vmLogTestFiller.json
  69. 0
      test/libevm/VMTestsFiller/vmPerformanceTestFiller.json
  70. 0
      test/libevm/VMTestsFiller/vmPushDupSwapTestFiller.json
  71. 0
      test/libevm/VMTestsFiller/vmSha3TestFiller.json
  72. 0
      test/libevm/VMTestsFiller/vmSystemOperationsTestFiller.json
  73. 0
      test/libevm/VMTestsFiller/vmtestsFiller.json
  74. 28
      test/libevm/vm.cpp
  75. 2
      test/libevm/vm.h
  76. 0
      test/libevmcore/Assembly.cpp
  77. 5
      test/libevmcore/CMakeLists.txt
  78. 5
      test/libnatspec/CMakeLists.txt
  79. 0
      test/libnatspec/natspec.cpp
  80. 5
      test/libp2p/CMakeLists.txt
  81. 372
      test/libp2p/net.cpp
  82. 0
      test/libp2p/peer.cpp
  83. 0
      test/libp2p/rlpx.cpp
  84. 5
      test/libsolidity/CMakeLists.txt
  85. 2
      test/libsolidity/SolidityABIJSON.cpp
  86. 0
      test/libsolidity/SolidityCompiler.cpp
  87. 2
      test/libsolidity/SolidityEndToEndTest.cpp
  88. 2
      test/libsolidity/SolidityExpressionCompiler.cpp
  89. 2
      test/libsolidity/SolidityInterface.cpp
  90. 2
      test/libsolidity/SolidityNameAndTypeResolution.cpp
  91. 2
      test/libsolidity/SolidityNatspecJSON.cpp
  92. 2
      test/libsolidity/SolidityOptimizer.cpp
  93. 2
      test/libsolidity/SolidityParser.cpp
  94. 0
      test/libsolidity/SolidityScanner.cpp
  95. 0
      test/libsolidity/SolidityTypes.cpp
  96. 2
      test/libsolidity/solidityExecutionFramework.h
  97. 0
      test/libweb3jsonrpc/AccountHolder.cpp
  98. 5
      test/libweb3jsonrpc/CMakeLists.txt
  99. 4
      test/libweb3jsonrpc/jsonrpc.cpp
  100. 596
      test/libweb3jsonrpc/webthreestubclient.h

0
test/trie.cpp → libdevcrypto/trie.cpp

0
test/net.cpp → libp2p/net.cpp

6
libtestutils/Common.cpp

@ -20,6 +20,7 @@
*/
#include <random>
#include <boost/filesystem.hpp>
#include <libdevcore/CommonData.h>
#include <libdevcore/CommonIO.h>
#include <libdevcrypto/FileSystem.h>
@ -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;

1
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();
}

89
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)

10
test/TestHelper.cpp

@ -23,9 +23,6 @@
#include <thread>
#include <chrono>
#include <boost/filesystem/path.hpp>
#include <libethereum/Client.h>
#include <liblll/Compiler.h>
#include <libevm/VMFactory.h>
@ -592,7 +589,7 @@ void userDefinedTest(string testTypeFlag, std::function<void(json_spirit::mValue
}
}
void executeTests(const string& _name, const string& _testPathAppendix, std::function<void(json_spirit::mValue&, bool)> doTests)
void executeTests(const string& _name, const string& _testPathAppendix, const boost::filesystem::path _pathToFiller, std::function<void(json_spirit::mValue&, bool)> 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)));

3
test/TestHelper.h

@ -24,6 +24,7 @@
#include <functional>
#include <boost/test/unit_test.hpp>
#include <boost/filesystem.hpp>
#include "JsonSpiritHeaders.h"
#include <libethereum/State.h>
@ -155,7 +156,7 @@ void checkStorage(std::map<u256, u256> _expectedStore, std::map<u256, u256> _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<void(json_spirit::mValue&, bool)> doTests);
void executeTests(const std::string& _name, const std::string& _testPathAppendix, const boost::filesystem::path _pathToFiller, std::function<void(json_spirit::mValue&, bool)> doTests);
void userDefinedTest(std::string testTypeFlag, std::function<void(json_spirit::mValue&, bool)> doTests);
RLPStream createRLPStreamFromTransactionFields(json_spirit::mObject& _tObj);
eth::LastHashes lastHashes(u256 _currentBlockNumber);

0
test/fork.cpp → test/deprecated/fork.cpp

0
test/kademlia.cpp → test/deprecated/kademlia.cpp

0
test/main.cpp → test/deprecated/main.cpp

0
test/txTest.cpp → test/deprecated/txTest.cpp

31
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)

2
test/checkRandomStateTest.cpp → test/fuzzTesting/checkRandomStateTest.cpp

@ -26,7 +26,7 @@
#include <libdevcore/Log.h>
#include <libevm/VMFactory.h>
#include "TestHelper.h"
#include "vm.h"
#include "../libevm/vm.h"
#pragma GCC diagnostic ignored "-Wunused-parameter"
using namespace std;

3
test/checkRandomVMTest.cpp → test/fuzzTesting/checkRandomVMTest.cpp

@ -25,7 +25,8 @@
#include <libdevcore/Exceptions.h>
#include <libdevcore/Log.h>
#include <libevm/VMFactory.h>
#include "vm.h"
#include "../libevm/vm.h"
#pragma GCC diagnostic ignored "-Wunused-parameter"
using namespace std;

4
test/createRandomStateTest.cpp → test/fuzzTesting/createRandomStateTest.cpp

@ -35,8 +35,8 @@
#include <libdevcore/CommonData.h>
#include <libevmcore/Instruction.h>
#include <libevm/VMFactory.h>
#include "TestHelper.h"
#include "vm.h"
#include "../TestHelper.h"
#include "../libevm/vm.h"
using namespace std;
using namespace json_spirit;

2
test/createRandomVMTest.cpp → test/fuzzTesting/createRandomVMTest.cpp

@ -35,7 +35,7 @@
#include <libdevcore/CommonData.h>
#include <libevmcore/Instruction.h>
#include <libevm/VMFactory.h>
#include "vm.h"
#include "../libevm/vm.h"
using namespace std;
using namespace json_spirit;

5
test/libdevcore/CMakeLists.txt

@ -0,0 +1,5 @@
cmake_policy(SET CMP0015 NEW)
aux_source_directory(. SRCS)
add_sources(${SRCS})

4
test/rlp.cpp → test/libdevcore/rlp.cpp

@ -30,8 +30,8 @@
#include <libdevcore/Common.h>
#include <libdevcore/CommonIO.h>
#include <algorithm>
#include "JsonSpiritHeaders.h"
#include "TestHelper.h"
#include "../JsonSpiritHeaders.h"
#include "../TestHelper.h"
using namespace std;
using namespace dev;

5
test/libdevcrypto/CMakeLists.txt

@ -0,0 +1,5 @@
cmake_policy(SET CMP0015 NEW)
aux_source_directory(. SRCS)
add_sources(${SRCS})

0
test/MemTrie.cpp → test/libdevcrypto/MemTrie.cpp

0
test/MemTrie.h → test/libdevcrypto/MemTrie.h

0
test/TrieHash.cpp → test/libdevcrypto/TrieHash.cpp

0
test/TrieHash.h → test/libdevcrypto/TrieHash.h

0
test/crypto.cpp → test/libdevcrypto/crypto.cpp

4
test/hexPrefix.cpp → test/libdevcrypto/hexPrefix.cpp

@ -24,11 +24,11 @@
#include <boost/test/unit_test.hpp>
#include "JsonSpiritHeaders.h"
#include "../JsonSpiritHeaders.h"
#include <libdevcore/Log.h>
#include <libdevcore/CommonIO.h>
#include <libdevcrypto/TrieCommon.h>
#include "TestHelper.h"
#include "../TestHelper.h"
using namespace std;
using namespace dev;

553
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 <http://www.gnu.org/licenses/>.
*/
/** @file trie.cpp
* @author Gav Wood <i@gavwood.com>
* @date 2014
* Trie test functions.
*/
#include <fstream>
#include <random>
#include <boost/test/unit_test.hpp>
#include "../JsonSpiritHeaders.h"
#include <libdevcore/CommonIO.h>
#include <libdevcrypto/TrieDB.h>
#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<MemoryDB> 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<MemoryDB> 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<pair<string, string>> 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<MemoryDB> t(&m);
MemoryDB hm;
HashedGenericTrieDB<MemoryDB> ht(&hm);
MemoryDB fm;
FatGenericTrieDB<MemoryDB> 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<pair<string, string>> 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<MemoryDB> t(&m);
MemoryDB hm;
HashedGenericTrieDB<MemoryDB> ht(&hm);
MemoryDB fm;
FatGenericTrieDB<MemoryDB> 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<pair<string, string>> ss;
vector<string> keysToBeDeleted;
for (auto& i: o["in"].get_array())
{
vector<string> 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<MemoryDB> t(&m);
MemoryDB hm;
HashedGenericTrieDB<MemoryDB> ht(&hm);
MemoryDB fm;
FatGenericTrieDB<MemoryDB> 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<MemoryDB> 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<MemoryDB> 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<MemoryDB> 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<MemoryDB> 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<MemoryDB> 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<MemoryDB> 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()

5
test/libethcore/CMakeLists.txt

@ -0,0 +1,5 @@
cmake_policy(SET CMP0015 NEW)
aux_source_directory(. SRCS)
add_sources(${SRCS})

0
test/commonjs.cpp → test/libethcore/commonjs.cpp

4
test/dagger.cpp → test/libethcore/dagger.cpp

@ -22,12 +22,12 @@
#include <fstream>
#include <random>
#include "JsonSpiritHeaders.h"
#include "../JsonSpiritHeaders.h"
#include <libdevcore/CommonIO.h>
#include <libethcore/ProofOfWork.h>
#include <libethcore/EthashAux.h>
#include <boost/test/unit_test.hpp>
#include "TestHelper.h"
#include "../TestHelper.h"
using namespace std;
using namespace dev;

0
test/bcInvalidHeaderTestFiller.json → test/libethereum/BlockTestsFiller/bcInvalidHeaderTestFiller.json

0
test/bcJS_API_TestFiller.json → test/libethereum/BlockTestsFiller/bcJS_API_TestFiller.json

0
test/bcUncleHeaderValiditiyFiller.json → test/libethereum/BlockTestsFiller/bcUncleHeaderValiditiyFiller.json

0
test/bcUncleTestFiller.json → test/libethereum/BlockTestsFiller/bcUncleTestFiller.json

0
test/bcValidBlockTestFiller.json → test/libethereum/BlockTestsFiller/bcValidBlockTestFiller.json

5
test/libethereum/CMakeLists.txt

@ -0,0 +1,5 @@
cmake_policy(SET CMP0015 NEW)
aux_source_directory(. SRCS)
add_sources(${SRCS})

2
test/ClientBase.cpp → test/libethereum/ClientBase.cpp

@ -21,7 +21,7 @@
#include <boost/test/unit_test.hpp>
#include <libdevcore/CommonJS.h>
#include "TestUtils.h"
#include "../TestUtils.h"
using namespace std;
using namespace dev;

0
test/ManyFunctions.sol → test/libethereum/StateTestsFiller/ManyFunctions.sol

0
test/ManyFunctionsGenerator.py → test/libethereum/StateTestsFiller/ManyFunctionsGenerator.py

0
test/stBlockHashTestFiller.json → test/libethereum/StateTestsFiller/stBlockHashTestFiller.json

0
test/stCallCreateCallCodeTestFiller.json → test/libethereum/StateTestsFiller/stCallCreateCallCodeTestFiller.json

0
test/stExampleFiller.json → test/libethereum/StateTestsFiller/stExampleFiller.json

0
test/stInitCodeTestFiller.json → test/libethereum/StateTestsFiller/stInitCodeTestFiller.json

0
test/stLogTestsFiller.json → test/libethereum/StateTestsFiller/stLogTestsFiller.json

0
test/stMemoryStressTestFiller.json → test/libethereum/StateTestsFiller/stMemoryStressTestFiller.json

0
test/stMemoryTestFiller.json → test/libethereum/StateTestsFiller/stMemoryTestFiller.json

0
test/stPreCompiledContractsFiller.json → test/libethereum/StateTestsFiller/stPreCompiledContractsFiller.json

0
test/stQuadraticComplexityTestFiller.json → test/libethereum/StateTestsFiller/stQuadraticComplexityTestFiller.json

0
test/stRecursiveCreateFiller.json → test/libethereum/StateTestsFiller/stRecursiveCreateFiller.json

0
test/stRefundTestFiller.json → test/libethereum/StateTestsFiller/stRefundTestFiller.json

0
test/stSolidityTestFiller.json → test/libethereum/StateTestsFiller/stSolidityTestFiller.json

0
test/stSpecialTestFiller.json → test/libethereum/StateTestsFiller/stSpecialTestFiller.json

0
test/stSystemOperationsTestFiller.json → test/libethereum/StateTestsFiller/stSystemOperationsTestFiller.json

0
test/stTransactionTestFiller.json → test/libethereum/StateTestsFiller/stTransactionTestFiller.json

0
test/tt10mbDataFieldFiller.json → test/libethereum/TransactionTestsFiller/tt10mbDataFieldFiller.json

0
test/ttTransactionTestFiller.json → test/libethereum/TransactionTestsFiller/ttTransactionTestFiller.json

16
test/blockchain.cpp → test/libethereum/blockchain.cpp

@ -24,7 +24,7 @@
#include <libdevcrypto/FileSystem.h>
#include <libdevcore/TransientDirectory.h>
#include <libethereum/CanonBlockChain.h>
#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)

4
test/genesis.cpp → test/libethereum/genesis.cpp

@ -25,10 +25,10 @@
#include <boost/test/unit_test.hpp>
#include "JsonSpiritHeaders.h"
#include "../JsonSpiritHeaders.h"
#include <libdevcore/CommonIO.h>
#include <libethereum/CanonBlockChain.h>
#include "TestHelper.h"
#include "../TestHelper.h"
using namespace std;
using namespace dev;

34
test/state.cpp → test/libethereum/state.cpp

@ -23,14 +23,14 @@
#include <boost/filesystem/operations.hpp>
#include <boost/test/unit_test.hpp>
#include "JsonSpiritHeaders.h"
#include "../JsonSpiritHeaders.h"
#include <libdevcore/CommonIO.h>
#include <libethereum/CanonBlockChain.h>
#include <libethereum/State.h>
#include <libethereum/ExtVM.h>
#include <libethereum/Defaults.h>
#include <libevm/VM.h>
#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);
}

2
test/stateOriginal.cpp → test/libethereum/stateOriginal.cpp

@ -27,7 +27,7 @@
#include <libethereum/State.h>
#include <libethereum/Farm.h>
#include <libethereum/Defaults.h>
#include "TestHelper.h"
#include "../TestHelper.h"
using namespace std;
using namespace dev;
using namespace dev::eth;

8
test/transaction.cpp → 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<chrono::milliseconds>(end - start));

5
test/libevm/CMakeLists.txt

@ -0,0 +1,5 @@
cmake_policy(SET CMP0015 NEW)
aux_source_directory(. SRCS)
add_sources(${SRCS})

0
test/PerformaceTester.sol → test/libevm/VMTestsFiller/performanceTester.sol

0
test/vmArithmeticTestFiller.json → test/libevm/VMTestsFiller/vmArithmeticTestFiller.json

0
test/vmBitwiseLogicOperationTestFiller.json → test/libevm/VMTestsFiller/vmBitwiseLogicOperationTestFiller.json

0
test/vmBlockInfoTestFiller.json → test/libevm/VMTestsFiller/vmBlockInfoTestFiller.json

0
test/vmEnvironmentalInfoTestFiller.json → test/libevm/VMTestsFiller/vmEnvironmentalInfoTestFiller.json

0
test/vmIOandFlowOperationsTestFiller.json → test/libevm/VMTestsFiller/vmIOandFlowOperationsTestFiller.json

0
test/vmLogTestFiller.json → test/libevm/VMTestsFiller/vmLogTestFiller.json

0
test/vmPerformanceTestFiller.json → test/libevm/VMTestsFiller/vmPerformanceTestFiller.json

0
test/vmPushDupSwapTestFiller.json → test/libevm/VMTestsFiller/vmPushDupSwapTestFiller.json

0
test/vmSha3TestFiller.json → test/libevm/VMTestsFiller/vmSha3TestFiller.json

0
test/vmSystemOperationsTestFiller.json → test/libevm/VMTestsFiller/vmSystemOperationsTestFiller.json

0
test/vmtestsFiller.json → test/libevm/VMTestsFiller/vmtestsFiller.json

28
test/vm.cpp → 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)

2
test/vm.h → test/libevm/vm.h

@ -38,7 +38,7 @@ along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
#include <libethereum/Transaction.h>
#include <libethereum/ExtVM.h>
#include <libethereum/State.h>
#include "TestHelper.h"
#include "../TestHelper.h"
namespace dev { namespace test {

0
test/Assembly.cpp → test/libevmcore/Assembly.cpp

5
test/libevmcore/CMakeLists.txt

@ -0,0 +1,5 @@
cmake_policy(SET CMP0015 NEW)
aux_source_directory(. SRCS)
add_sources(${SRCS})

5
test/libnatspec/CMakeLists.txt

@ -0,0 +1,5 @@
cmake_policy(SET CMP0015 NEW)
aux_source_directory(. SRCS)
add_sources(${SRCS})

0
test/natspec.cpp → test/libnatspec/natspec.cpp

5
test/libp2p/CMakeLists.txt

@ -0,0 +1,5 @@
cmake_policy(SET CMP0015 NEW)
aux_source_directory(. SRCS)
add_sources(${SRCS})

372
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 <http://www.gnu.org/licenses/>.
*/
/** @file net.cpp
* @author Alex Leverington <nessence@gmail.com>
* @date 2014
*/
#include <boost/test/unit_test.hpp>
#include <libdevcore/Worker.h>
#include <libdevcore/Assertions.h>
#include <libdevcrypto/Common.h>
#include <libp2p/UDP.h>
#include <libp2p/NodeTable.h>
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<std::pair<KeyPair,unsigned>> createTestNodes(unsigned _count)
{
std::vector<std::pair<KeyPair,unsigned>> 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<std::pair<KeyPair,unsigned>> 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<std::pair<KeyPair,unsigned>> 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<NodeEntry> 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<TestNodeTable>(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<TestNodeTable> nodeTable;
std::vector<std::pair<KeyPair,unsigned>> testNodes; // keypair and port
std::vector<shared_ptr<TestNodeTable>> nodeTables;
};
class TestUDPSocket: UDPSocketEvents, public TestHost
{
public:
TestUDPSocket(): m_socket(new UDPSocket<TestUDPSocket, 1024>(m_io, *this, 30300)) {}
void onDisconnected(UDPSocketFace*) {};
void onReceived(UDPSocketFace*, bi::udp::endpoint const&, bytesConstRef _packet) { if (_packet.toString() == "AAAA") success = true; }
shared_ptr<UDPSocket<TestUDPSocket, 1024>> m_socket;
bool success = false;
};
BOOST_AUTO_TEST_CASE(requestTimeout)
{
using TimePoint = std::chrono::steady_clock::time_point;
using RequestTimeout = std::pair<NodeId, TimePoint>;
std::chrono::milliseconds timeout(300);
std::list<RequestTimeout> 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::seconds>((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<std::pair<KeyPair,unsigned>> 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<std::pair<KeyPair,unsigned>> 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()

0
test/peer.cpp → test/libp2p/peer.cpp

0
test/rlpx.cpp → test/libp2p/rlpx.cpp

5
test/libsolidity/CMakeLists.txt

@ -0,0 +1,5 @@
cmake_policy(SET CMP0015 NEW)
aux_source_directory(. SRCS)
add_sources(${SRCS})

2
test/SolidityABIJSON.cpp → test/libsolidity/SolidityABIJSON.cpp

@ -21,7 +21,7 @@
*/
#if ETH_SOLIDITY
#include "TestHelper.h"
#include "../TestHelper.h"
#include <libsolidity/CompilerStack.h>
#include <json/json.h>
#include <libdevcore/Exceptions.h>

0
test/SolidityCompiler.cpp → test/libsolidity/SolidityCompiler.cpp

2
test/SolidityEndToEndTest.cpp → test/libsolidity/SolidityEndToEndTest.cpp

@ -27,7 +27,7 @@
#include <tuple>
#include <boost/test/unit_test.hpp>
#include <libdevcrypto/SHA3.h>
#include <test/solidityExecutionFramework.h>
#include <test/libsolidity/solidityExecutionFramework.h>
using namespace std;

2
test/SolidityExpressionCompiler.cpp → test/libsolidity/SolidityExpressionCompiler.cpp

@ -31,7 +31,7 @@
#include <libsolidity/CompilerContext.h>
#include <libsolidity/ExpressionCompiler.h>
#include <libsolidity/AST.h>
#include "TestHelper.h"
#include "../TestHelper.h"
using namespace std;

2
test/SolidityInterface.cpp → test/libsolidity/SolidityInterface.cpp

@ -22,7 +22,7 @@
#if ETH_SOLIDITY
#include "TestHelper.h"
#include "../TestHelper.h"
#include <libsolidity/CompilerStack.h>
#include <libsolidity/AST.h>

2
test/SolidityNameAndTypeResolution.cpp → test/libsolidity/SolidityNameAndTypeResolution.cpp

@ -31,7 +31,7 @@
#include <libsolidity/NameAndTypeResolver.h>
#include <libsolidity/Exceptions.h>
#include <libsolidity/GlobalContext.h>
#include "TestHelper.h"
#include "../TestHelper.h"
using namespace std;

2
test/SolidityNatspecJSON.cpp → test/libsolidity/SolidityNatspecJSON.cpp

@ -22,7 +22,7 @@
#if ETH_SOLIDITY
#include "TestHelper.h"
#include "../TestHelper.h"
#include <json/json.h>
#include <libsolidity/CompilerStack.h>
#include <libsolidity/Exceptions.h>

2
test/SolidityOptimizer.cpp → test/libsolidity/SolidityOptimizer.cpp

@ -26,7 +26,7 @@
#include <tuple>
#include <boost/test/unit_test.hpp>
#include <boost/lexical_cast.hpp>
#include <test/solidityExecutionFramework.h>
#include <test/libsolidity/solidityExecutionFramework.h>
#include <libevmcore/CommonSubexpressionEliminator.h>
#include <libevmcore/ControlFlowGraph.h>
#include <libevmcore/Assembly.h>

2
test/SolidityParser.cpp → test/libsolidity/SolidityParser.cpp

@ -28,7 +28,7 @@
#include <libsolidity/Scanner.h>
#include <libsolidity/Parser.h>
#include <libsolidity/Exceptions.h>
#include "TestHelper.h"
#include "../TestHelper.h"
using namespace std;

0
test/SolidityScanner.cpp → test/libsolidity/SolidityScanner.cpp

0
test/SolidityTypes.cpp → test/libsolidity/SolidityTypes.cpp

2
test/solidityExecutionFramework.h → test/libsolidity/solidityExecutionFramework.h

@ -24,7 +24,7 @@
#include <string>
#include <tuple>
#include "TestHelper.h"
#include "../TestHelper.h"
#include <libethereum/State.h>
#include <libethereum/Executive.h>
#include <libsolidity/CompilerStack.h>

0
test/AccountHolder.cpp → test/libweb3jsonrpc/AccountHolder.cpp

5
test/libweb3jsonrpc/CMakeLists.txt

@ -0,0 +1,5 @@
cmake_policy(SET CMP0015 NEW)
aux_source_directory(. SRCS)
add_sources(${SRCS})

4
test/jsonrpc.cpp → test/libweb3jsonrpc/jsonrpc.cpp

@ -34,8 +34,8 @@
#include <jsonrpccpp/server/connectors/httpserver.h>
#include <jsonrpccpp/client/connectors/httpclient.h>
#include <set>
#include "JsonSpiritHeaders.h"
#include "TestHelper.h"
#include "../JsonSpiritHeaders.h"
#include "../TestHelper.h"
#include "webthreestubclient.h"
BOOST_AUTO_TEST_SUITE(jsonrpc)

596
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 <jsonrpccpp/client.h>
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_

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save