aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaweł Bylica <pawel.bylica@imapp.pl>2014-12-19 20:58:22 +0800
committerPaweł Bylica <pawel.bylica@imapp.pl>2014-12-19 20:58:22 +0800
commitc6d2c2392bd3f36f4539d990f60f9136e158d136 (patch)
treec1b6875165493b33752d9c283a00643b031c60e7
parent180b0fa9e3aab595048d171ff4556a769f85dd1e (generated by cgit (git 2.34.1) at 2024-10-01 0
-rw-r--r--CMakeLists.txt45
-rw-r--r--SolidityABIJSON.cpp (renamed from solidityJSONInterfaceTest.cpp)55
-rw-r--r--SolidityCompiler.cpp (renamed from solidityCompiler.cpp)27
-rw-r--r--SolidityEndToEndTest.cpp (renamed from solidityEndToEndTest.cpp)259
-rw-r--r--SolidityExpressionCompiler.cpp (renamed from solidityExpressionCompiler.cpp)12
-rw-r--r--SolidityNameAndTypeResolution.cpp (renamed from solidityNameAndTypeResolution.cpp)45
-rw-r--r--SolidityNatspecJSON.cpp (renamed from solidityNatspecJSON.cpp)31
-rw-r--r--SolidityOptimizer.cpp (renamed from solidityOptimizerTest.cpp)21
-rw-r--r--SolidityParser.cpp (renamed from solidityParser.cpp)78
-rw-r--r--SolidityScanner.cpp (renamed from solidityScanner.cpp)54
-rw-r--r--TestHelper.cpp18
-rw-r--r--crypto.cpp9
-rw-r--r--genesis.cpp11
-rw-r--r--hexPrefix.cpp2
-rw-r--r--jsonrpc.cpp17
-rw-r--r--solidityExecutionFramework.h4
-rw-r--r--stInitCodeTestFiller.json302
-rw-r--r--stRecursiveCreateFiller.json (renamed from recursiveCreateFiller.json)0
-rw-r--r--stRefundTestFiller.json308
-rw-r--r--stTransactionTestFiller.json191
-rw-r--r--state.cpp22
-rw-r--r--trie.cpp3
-rw-r--r--vm.cpp50
-rw-r--r--vm.h6
-rw-r--r--webthreestubclient.h775
-rw-r--r--whisperTopic.cpp5
26 files changed, 1783 insertions, 567 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3336b428..7cedc117 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,52 +3,29 @@ cmake_policy(SET CMP0015 NEW)
aux_source_directory(. SRC_LIST)
list(REMOVE_ITEM SRC_LIST "./createRandomTest.cpp")
+include_directories(${Boost_INCLUDE_DIRS})
+include_directories(${CRYPTOPP_INCLUDE_DIRS})
+include_directories(${JSONCPP_INCLUDE_DIRS})
+include_directories(${JSON_RPC_CPP_INCLUDE_DIRS})
include_directories(..)
-link_directories(../libevm)
file(GLOB HEADERS "*.h")
add_executable(testeth ${SRC_LIST} ${HEADERS})
add_executable(createRandomTest createRandomTest.cpp vm.cpp TestHelper.cpp)
+target_link_libraries(testeth ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES})
+target_link_libraries(testeth ${CURL_LIBRARIES})
target_link_libraries(testeth ethereum)
target_link_libraries(testeth ethcore)
target_link_libraries(testeth secp256k1)
-target_link_libraries(testeth gmp)
target_link_libraries(testeth solidity)
-target_link_libraries(testeth ${CRYPTOPP_LS})
target_link_libraries(testeth webthree)
-if(JSONRPC_LS)
-target_link_libraries(testeth web3jsonrpc)
-endif()
-if (EVMJIT)
- target_link_libraries(testeth evmjit-cpp)
+
+if (JSONRPC)
+ target_link_libraries(testeth web3jsonrpc)
+ target_link_libraries(testeth ${JSON_RPC_CPP_CLIENT_LIBRARIES})
endif()
+target_link_libraries(createRandomTest ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES})
target_link_libraries(createRandomTest ethereum)
target_link_libraries(createRandomTest ethcore)
-target_link_libraries(createRandomTest boost_chrono)
-target_link_libraries(createRandomTest boost_unit_test_framework)
-if (EVMJIT)
- target_link_libraries(createRandomTest evmjit-cpp)
-endif()
-
-if ("${TARGET_PLATFORM}" STREQUAL "w64")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++")
- target_link_libraries(testeth boost_system-mt-s)
- target_link_libraries(testeth boost_filesystem-mt-s)
- target_link_libraries(testeth boost_thread_win32-mt-s)
- target_link_libraries(testeth gcc)
- target_link_libraries(testeth gdi32)
- target_link_libraries(testeth ws2_32)
- target_link_libraries(testeth mswsock)
- target_link_libraries(testeth shlwapi)
- target_link_libraries(testeth iphlpapi)
- set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS)
-elseif (UNIX)
- find_package(Boost 1.53 REQUIRED COMPONENTS unit_test_framework)
-else ()
- target_link_libraries(testeth boost_system)
- target_link_libraries(testeth boost_filesystem)
- find_package(Threads REQUIRED)
- target_link_libraries(testeth ${CMAKE_THREAD_LIBS_INIT})
-endif ()
diff --git a/solidityJSONInterfaceTest.cpp b/SolidityABIJSON.cpp
index 487508bb..62ab0458 100644
--- a/solidityJSONInterfaceTest.cpp
+++ b/SolidityABIJSON.cpp
@@ -22,7 +22,7 @@
#include <boost/test/unit_test.hpp>
#include <libsolidity/CompilerStack.h>
-#include <jsonrpc/json/json.h>
+#include <jsoncpp/json/json.h>
#include <libdevcore/Exceptions.h>
namespace dev
@@ -76,6 +76,7 @@ BOOST_AUTO_TEST_CASE(basic_test)
char const* interface = R"([
{
"name": "f",
+ "const": false,
"inputs": [
{
"name": "a",
@@ -114,6 +115,7 @@ BOOST_AUTO_TEST_CASE(multiple_methods)
char const* interface = R"([
{
"name": "f",
+ "const": false,
"inputs": [
{
"name": "a",
@@ -129,6 +131,7 @@ BOOST_AUTO_TEST_CASE(multiple_methods)
},
{
"name": "g",
+ "const": false,
"inputs": [
{
"name": "b",
@@ -156,6 +159,7 @@ BOOST_AUTO_TEST_CASE(multiple_params)
char const* interface = R"([
{
"name": "f",
+ "const": false,
"inputs": [
{
"name": "a",
@@ -189,6 +193,7 @@ BOOST_AUTO_TEST_CASE(multiple_methods_order)
char const* interface = R"([
{
"name": "c",
+ "const": false,
"inputs": [
{
"name": "b",
@@ -204,6 +209,7 @@ BOOST_AUTO_TEST_CASE(multiple_methods_order)
},
{
"name": "f",
+ "const": false,
"inputs": [
{
"name": "a",
@@ -222,6 +228,53 @@ BOOST_AUTO_TEST_CASE(multiple_methods_order)
checkInterface(sourceCode, interface);
}
+BOOST_AUTO_TEST_CASE(const_function)
+{
+ char const* sourceCode = "contract test {\n"
+ " function foo(uint a, uint b) returns(uint d) { return a + b; }\n"
+ " function boo(uint32 a) const returns(uint b) { return a * 4; }\n"
+ "}\n";
+
+ char const* interface = R"([
+ {
+ "name": "boo",
+ "const": true,
+ "inputs": [{
+ "name": "a",
+ "type": "uint32"
+ }],
+ "outputs": [
+ {
+ "name": "b",
+ "type": "uint256"
+ }
+ ]
+ },
+ {
+ "name": "foo",
+ "const": false,
+ "inputs": [
+ {
+ "name": "a",
+ "type": "uint256"
+ },
+ {
+ "name": "b",
+ "type": "uint256"
+ }
+ ],
+ "outputs": [
+ {
+ "name": "d",
+ "type": "uint256"
+ }
+ ]
+ }
+ ])";
+
+ checkInterface(sourceCode, interface);
+}
+
BOOST_AUTO_TEST_SUITE_END()
}
diff --git a/solidityCompiler.cpp b/SolidityCompiler.cpp
index 004740b5..385a3e57 100644
--- a/solidityCompiler.cpp
+++ b/SolidityCompiler.cpp
@@ -54,9 +54,18 @@ bytes compileContract(const string& _sourceCode)
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
{
BOOST_REQUIRE_NO_THROW(resolver.resolveNamesAndTypes(*contract));
-
+ }
+ for (ASTPointer<ASTNode> const& node: sourceUnit->getNodes())
+ if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
+ {
+ BOOST_REQUIRE_NO_THROW(resolver.checkTypeRequirements(*contract));
+ }
+ for (ASTPointer<ASTNode> const& node: sourceUnit->getNodes())
+ if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
+ {
Compiler compiler;
- compiler.compileContract(*contract, {});
+ compiler.compileContract(*contract, {}, map<ContractDefinition const*, bytes const*>{});
+
// debug
//compiler.streamAssembly(cout);
return compiler.getAssembledBytecode();
@@ -87,7 +96,7 @@ BOOST_AUTO_TEST_CASE(smoke_test)
"}\n";
bytes code = compileContract(sourceCode);
- unsigned boilerplateSize = 42;
+ unsigned boilerplateSize = 40;
bytes expectation({byte(Instruction::JUMPDEST),
byte(Instruction::PUSH1), 0x0, // initialize local variable x
byte(Instruction::PUSH1), 0x2,
@@ -107,8 +116,8 @@ BOOST_AUTO_TEST_CASE(different_argument_numbers)
"}\n";
bytes code = compileContract(sourceCode);
- unsigned shift = 70;
- unsigned boilerplateSize = 83;
+ unsigned shift = 68;
+ unsigned boilerplateSize = 81;
bytes expectation({byte(Instruction::JUMPDEST),
byte(Instruction::PUSH1), 0x0, // initialize return variable d
byte(Instruction::DUP3),
@@ -158,8 +167,8 @@ BOOST_AUTO_TEST_CASE(ifStatement)
"}\n";
bytes code = compileContract(sourceCode);
- unsigned shift = 29;
- unsigned boilerplateSize = 42;
+ unsigned shift = 27;
+ unsigned boilerplateSize = 40;
bytes expectation({byte(Instruction::JUMPDEST),
byte(Instruction::PUSH1), 0x0,
byte(Instruction::DUP1),
@@ -200,8 +209,8 @@ BOOST_AUTO_TEST_CASE(loops)
"}\n";
bytes code = compileContract(sourceCode);
- unsigned shift = 29;
- unsigned boilerplateSize = 42;
+ unsigned shift = 27;
+ unsigned boilerplateSize = 40;
bytes expectation({byte(Instruction::JUMPDEST),
byte(Instruction::JUMPDEST),
byte(Instruction::PUSH1), 0x1,
diff --git a/solidityEndToEndTest.cpp b/SolidityEndToEndTest.cpp
index 3c77492a..9559e370 100644
--- a/solidityEndToEndTest.cpp
+++ b/SolidityEndToEndTest.cpp
@@ -36,7 +36,7 @@ namespace solidity
namespace test
{
-BOOST_FIXTURE_TEST_SUITE(SolidityCompilerEndToEndTest, ExecutionFramework)
+BOOST_FIXTURE_TEST_SUITE(SolidityEndToEndTest, ExecutionFramework)
BOOST_AUTO_TEST_CASE(smoke_test)
{
@@ -176,6 +176,80 @@ BOOST_AUTO_TEST_CASE(nested_loops)
testSolidityAgainstCppOnRange(0, nested_loops_cpp, 0, 12);
}
+BOOST_AUTO_TEST_CASE(for_loop)
+{
+ char const* sourceCode = "contract test {\n"
+ " function f(uint n) returns(uint nfac) {\n"
+ " nfac = 1;\n"
+ " for (var i = 2; i <= n; i++)\n"
+ " nfac *= i;\n"
+ " }\n"
+ "}\n";
+ compileAndRun(sourceCode);
+
+ auto for_loop_cpp = [](u256 const& n) -> u256
+ {
+ u256 nfac = 1;
+ for (auto i = 2; i <= n; i++)
+ nfac *= i;
+ return nfac;
+ };
+
+ testSolidityAgainstCppOnRange(0, for_loop_cpp, 0, 5);
+}
+
+BOOST_AUTO_TEST_CASE(for_loop_empty)
+{
+ char const* sourceCode = "contract test {\n"
+ " function f() returns(uint ret) {\n"
+ " ret = 1;\n"
+ " for (;;)\n"
+ " {\n"
+ " ret += 1;\n"
+ " if (ret >= 10) break;\n"
+ " }\n"
+ " }\n"
+ "}\n";
+ compileAndRun(sourceCode);
+
+ auto for_loop_empty_cpp = []() -> u256
+ {
+ u256 ret = 1;
+ for (;;)
+ {
+ ret += 1;
+ if (ret >= 10) break;
+ }
+ return ret;
+ };
+
+ testSolidityAgainstCpp(0, for_loop_empty_cpp);
+}
+
+BOOST_AUTO_TEST_CASE(for_loop_simple_init_expr)
+{
+ char const* sourceCode = "contract test {\n"
+ " function f(uint n) returns(uint nfac) {\n"
+ " nfac = 1;\n"
+ " uint256 i;\n"
+ " for (i = 2; i <= n; i++)\n"
+ " nfac *= i;\n"
+ " }\n"
+ "}\n";
+ compileAndRun(sourceCode);
+
+ auto for_loop_simple_init_expr_cpp = [](u256 const& n) -> u256
+ {
+ u256 nfac = 1;
+ u256 i;
+ for (i = 2; i <= n; i++)
+ nfac *= i;
+ return nfac;
+ };
+
+ testSolidityAgainstCppOnRange(0, for_loop_simple_init_expr_cpp, 0, 5);
+}
+
BOOST_AUTO_TEST_CASE(calling_other_functions)
{
// note that the index of a function is its index in the sorted sequence of functions
@@ -363,6 +437,48 @@ BOOST_AUTO_TEST_CASE(small_signed_types)
testSolidityAgainstCpp(0, small_signed_types_cpp);
}
+BOOST_AUTO_TEST_CASE(strings)
+{
+ char const* sourceCode = "contract test {\n"
+ " function fixed() returns(string32 ret) {\n"
+ " return \"abc\\x00\\xff__\";\n"
+ " }\n"
+ " function pipeThrough(string2 small, bool one) returns(string16 large, bool oneRet) {\n"
+ " oneRet = one;\n"
+ " large = small;\n"
+ " }\n"
+ "}\n";
+ compileAndRun(sourceCode);
+ bytes expectation(32, 0);
+ expectation[0] = byte('a');
+ expectation[1] = byte('b');
+ expectation[2] = byte('c');
+ expectation[3] = byte(0);
+ expectation[4] = byte(0xff);
+ expectation[5] = byte('_');
+ expectation[6] = byte('_');
+ BOOST_CHECK(callContractFunction(0, bytes()) == expectation);
+ expectation = bytes(17, 0);
+ expectation[0] = 0;
+ expectation[1] = 2;
+ expectation[16] = 1;
+ BOOST_CHECK(callContractFunction(1, bytes({0x00, 0x02, 0x01})) == expectation);
+}
+
+BOOST_AUTO_TEST_CASE(empty_string_on_stack)
+{
+ char const* sourceCode = "contract test {\n"
+ " function run(string0 empty, uint8 inp) returns(uint16 a, string0 b, string4 c) {\n"
+ " var x = \"abc\";\n"
+ " var y = \"\";\n"
+ " var z = inp;\n"
+ " a = z; b = y; c = x;"
+ " }\n"
+ "}\n";
+ compileAndRun(sourceCode);
+ BOOST_CHECK(callContractFunction(0, bytes(1, 0x02)) == bytes({0x00, 0x02, 0x61/*'a'*/, 0x62/*'b'*/, 0x63/*'c'*/, 0x00}));
+}
+
BOOST_AUTO_TEST_CASE(state_smoke_test)
{
char const* sourceCode = "contract test {\n"
@@ -388,6 +504,41 @@ BOOST_AUTO_TEST_CASE(state_smoke_test)
BOOST_CHECK(callContractFunction(0, bytes(1, 0x00)) == toBigEndian(u256(0x3)));
}
+BOOST_AUTO_TEST_CASE(compound_assign)
+{
+ char const* sourceCode = "contract test {\n"
+ " uint value1;\n"
+ " uint value2;\n"
+ " function f(uint x, uint y) returns (uint w) {\n"
+ " uint value3 = y;"
+ " value1 += x;\n"
+ " value3 *= x;"
+ " value2 *= value3 + value1;\n"
+ " return value2 += 7;"
+ " }\n"
+ "}\n";
+ compileAndRun(sourceCode);
+
+ u256 value1;
+ u256 value2;
+ auto f = [&](u256 const& _x, u256 const& _y) -> u256
+ {
+ u256 value3 = _y;
+ value1 += _x;
+ value3 *= _x;
+ value2 *= value3 + value1;
+ return value2 += 7;
+ };
+ testSolidityAgainstCpp(0, f, u256(0), u256(6));
+ testSolidityAgainstCpp(0, f, u256(1), u256(3));
+ testSolidityAgainstCpp(0, f, u256(2), u256(25));
+ testSolidityAgainstCpp(0, f, u256(3), u256(69));
+ testSolidityAgainstCpp(0, f, u256(4), u256(84));
+ testSolidityAgainstCpp(0, f, u256(5), u256(2));
+ testSolidityAgainstCpp(0, f, u256(6), u256(51));
+ testSolidityAgainstCpp(0, f, u256(7), u256(48));
+}
+
BOOST_AUTO_TEST_CASE(simple_mapping)
{
char const* sourceCode = "contract test {\n"
@@ -400,22 +551,23 @@ BOOST_AUTO_TEST_CASE(simple_mapping)
" }\n"
"}";
compileAndRun(sourceCode);
-
- BOOST_CHECK(callContractFunction(0, bytes({0x00})) == bytes({0x00}));
- BOOST_CHECK(callContractFunction(0, bytes({0x01})) == bytes({0x00}));
- BOOST_CHECK(callContractFunction(0, bytes({0xa7})) == bytes({0x00}));
+
+ // msvc seems to have problems with initializer-list, when there is only 1 param in the list
+ BOOST_CHECK(callContractFunction(0, bytes(1, 0x00)) == bytes(1, 0x00));
+ BOOST_CHECK(callContractFunction(0, bytes(1, 0x01)) == bytes(1, 0x00));
+ BOOST_CHECK(callContractFunction(0, bytes(1, 0xa7)) == bytes(1, 0x00));
callContractFunction(1, bytes({0x01, 0xa1}));
- BOOST_CHECK(callContractFunction(0, bytes({0x00})) == bytes({0x00}));
- BOOST_CHECK(callContractFunction(0, bytes({0x01})) == bytes({0xa1}));
- BOOST_CHECK(callContractFunction(0, bytes({0xa7})) == bytes({0x00}));
+ BOOST_CHECK(callContractFunction(0, bytes(1, 0x00)) == bytes(1, 0x00));
+ BOOST_CHECK(callContractFunction(0, bytes(1, 0x01)) == bytes(1, 0xa1));
+ BOOST_CHECK(callContractFunction(0, bytes(1, 0xa7)) == bytes(1, 0x00));
callContractFunction(1, bytes({0x00, 0xef}));
- BOOST_CHECK(callContractFunction(0, bytes({0x00})) == bytes({0xef}));
- BOOST_CHECK(callContractFunction(0, bytes({0x01})) == bytes({0xa1}));
- BOOST_CHECK(callContractFunction(0, bytes({0xa7})) == bytes({0x00}));
+ BOOST_CHECK(callContractFunction(0, bytes(1, 0x00)) == bytes(1, 0xef));
+ BOOST_CHECK(callContractFunction(0, bytes(1, 0x01)) == bytes(1, 0xa1));
+ BOOST_CHECK(callContractFunction(0, bytes(1, 0xa7)) == bytes(1, 0x00));
callContractFunction(1, bytes({0x01, 0x05}));
- BOOST_CHECK(callContractFunction(0, bytes({0x00})) == bytes({0xef}));
- BOOST_CHECK(callContractFunction(0, bytes({0x01})) == bytes({0x05}));
- BOOST_CHECK(callContractFunction(0, bytes({0xa7})) == bytes({0x00}));
+ BOOST_CHECK(callContractFunction(0, bytes(1, 0x00)) == bytes(1, 0xef));
+ BOOST_CHECK(callContractFunction(0, bytes(1, 0x01)) == bytes(1, 0x05));
+ BOOST_CHECK(callContractFunction(0, bytes(1, 0xa7)) == bytes(1, 0x00));
}
BOOST_AUTO_TEST_CASE(mapping_state)
@@ -583,9 +735,9 @@ BOOST_AUTO_TEST_CASE(structs)
" }\n"
"}\n";
compileAndRun(sourceCode);
- BOOST_CHECK(callContractFunction(0) == bytes({0x00}));
+ BOOST_CHECK(callContractFunction(0) == bytes(1, 0x00));
BOOST_CHECK(callContractFunction(1) == bytes());
- BOOST_CHECK(callContractFunction(0) == bytes({0x01}));
+ BOOST_CHECK(callContractFunction(0) == bytes(1, 0x01));
}
BOOST_AUTO_TEST_CASE(struct_reference)
@@ -611,9 +763,9 @@ BOOST_AUTO_TEST_CASE(struct_reference)
" }\n"
"}\n";
compileAndRun(sourceCode);
- BOOST_CHECK(callContractFunction(0) == bytes({0x00}));
+ BOOST_CHECK(callContractFunction(0) == bytes(1, 0x00));
BOOST_CHECK(callContractFunction(1) == bytes());
- BOOST_CHECK(callContractFunction(0) == bytes({0x01}));
+ BOOST_CHECK(callContractFunction(0) == bytes(1, 0x01));
}
BOOST_AUTO_TEST_CASE(constructor)
@@ -941,6 +1093,77 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls_with_local_vars)
BOOST_REQUIRE(callContractFunction(0, a, b) == toBigEndian(a * b + 9));
}
+BOOST_AUTO_TEST_CASE(strings_in_calls)
+{
+ char const* sourceCode = R"(
+ contract Helper {
+ function invoke(string3 x, bool stop) returns (string4 ret) {
+ return x;
+ }
+ }
+ contract Main {
+ Helper h;
+ function callHelper(string2 x, bool stop) returns (string5 ret) {
+ return h.invoke(x, stop);
+ }
+ function getHelper() returns (address addr) {
+ return address(h);
+ }
+ function setHelper(address addr) {
+ h = Helper(addr);
+ }
+ })";
+ compileAndRun(sourceCode, 0, "Helper");
+ u160 const helperAddress = m_contractAddress;
+ compileAndRun(sourceCode, 0, "Main");
+ BOOST_REQUIRE(callContractFunction(2, helperAddress) == bytes());
+ BOOST_REQUIRE(callContractFunction(1, helperAddress) == toBigEndian(helperAddress));
+ BOOST_CHECK(callContractFunction(0, bytes({0, 'a', 1})) == bytes({0, 'a', 0, 0, 0}));
+}
+
+BOOST_AUTO_TEST_CASE(constructor_arguments)
+{
+ char const* sourceCode = R"(
+ contract Helper {
+ string3 name;
+ bool flag;
+ function Helper(string3 x, bool f) {
+ name = x;
+ flag = f;
+ }
+ function getName() returns (string3 ret) { return name; }
+ function getFlag() returns (bool ret) { return flag; }
+ }
+ contract Main {
+ Helper h;
+ function Main() {
+ h = new Helper("abc", true);
+ }
+ function getFlag() returns (bool ret) { return h.getFlag(); }
+ function getName() returns (string3 ret) { return h.getName(); }
+ })";
+ compileAndRun(sourceCode, 0, "Main");
+ BOOST_REQUIRE(callContractFunction(0) == bytes({byte(0x01)}));
+ BOOST_REQUIRE(callContractFunction(1) == bytes({'a', 'b', 'c'}));
+}
+
+BOOST_AUTO_TEST_CASE(functions_called_by_constructor)
+{
+ char const* sourceCode = R"(
+ contract Test {
+ string3 name;
+ bool flag;
+ function Test() {
+ setName("abc");
+ }
+ function getName() returns (string3 ret) { return name; }
+ private:
+ function setName(string3 _name) { name = _name; }
+ })";
+ compileAndRun(sourceCode);
+ BOOST_REQUIRE(callContractFunction(0) == bytes({'a', 'b', 'c'}));
+}
+
BOOST_AUTO_TEST_SUITE_END()
}
diff --git a/solidityExpressionCompiler.cpp b/SolidityExpressionCompiler.cpp
index 486b46eb..9c375418 100644
--- a/solidityExpressionCompiler.cpp
+++ b/SolidityExpressionCompiler.cpp
@@ -76,8 +76,11 @@ Declaration const& resolveDeclaration(vector<string> const& _namespacedName,
NameAndTypeResolver const& _resolver)
{
Declaration const* declaration = nullptr;
+ // bracers are required, cause msvc couldnt handle this macro in for statement
for (string const& namePart: _namespacedName)
+ {
BOOST_REQUIRE(declaration = _resolver.resolveName(namePart, declaration));
+ }
BOOST_REQUIRE(declaration);
return *declaration;
}
@@ -94,6 +97,15 @@ bytes compileFirstExpression(const string& _sourceCode, vector<vector<string>> _
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
{
BOOST_REQUIRE_NO_THROW(resolver.resolveNamesAndTypes(*contract));
+ }
+ for (ASTPointer<ASTNode> const& node: sourceUnit->getNodes())
+ if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
+ {
+ BOOST_REQUIRE_NO_THROW(resolver.checkTypeRequirements(*contract));
+ }
+ for (ASTPointer<ASTNode> const& node: sourceUnit->getNodes())
+ if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
+ {
FirstExpressionExtractor extractor(*contract);
BOOST_REQUIRE(extractor.getExpression() != nullptr);
diff --git a/solidityNameAndTypeResolution.cpp b/SolidityNameAndTypeResolution.cpp
index 78397229..25bff71f 100644
--- a/solidityNameAndTypeResolution.cpp
+++ b/SolidityNameAndTypeResolution.cpp
@@ -47,6 +47,9 @@ void parseTextAndResolveNames(std::string const& _source)
for (ASTPointer<ASTNode> const& node: sourceUnit->getNodes())
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
resolver.resolveNamesAndTypes(*contract);
+ for (ASTPointer<ASTNode> const& node: sourceUnit->getNodes())
+ if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
+ resolver.checkTypeRequirements(*contract);
}
}
@@ -226,6 +229,14 @@ BOOST_AUTO_TEST_CASE(type_inference_explicit_conversion)
BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text));
}
+BOOST_AUTO_TEST_CASE(large_string_literal)
+{
+ char const* text = "contract test {\n"
+ " function f() { var x = \"123456789012345678901234567890123\"; }"
+ "}\n";
+ BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
+}
+
BOOST_AUTO_TEST_CASE(balance)
{
char const* text = "contract test {\n"
@@ -276,6 +287,40 @@ BOOST_AUTO_TEST_CASE(assignment_to_struct)
BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
}
+BOOST_AUTO_TEST_CASE(returns_in_constructor)
+{
+ char const* text = "contract test {\n"
+ " function test() returns (uint a) {\n"
+ " }\n"
+ "}\n";
+ BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
+}
+
+BOOST_AUTO_TEST_CASE(forward_function_reference)
+{
+ char const* text = "contract First {\n"
+ " function fun() returns (bool ret) {\n"
+ " return Second(1).fun(1, true, 3) > 0;\n"
+ " }\n"
+ "}\n"
+ "contract Second {\n"
+ " function fun(uint a, bool b, uint c) returns (uint ret) {\n"
+ " if (First(2).fun() == true) return 1;\n"
+ " }\n"
+ "}\n";
+ BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text));
+}
+
+BOOST_AUTO_TEST_CASE(comparison_bitop_precedence)
+{
+ char const* text = "contract First {\n"
+ " function fun() returns (bool ret) {\n"
+ " return 1 & 2 == 8 & 9 && 1 ^ 2 < 4 | 6;\n"
+ " }\n"
+ "}\n";
+ BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text));
+}
+
BOOST_AUTO_TEST_SUITE_END()
}
diff --git a/solidityNatspecJSON.cpp b/SolidityNatspecJSON.cpp
index 641bb82a..5b48a67c 100644
--- a/solidityNatspecJSON.cpp
+++ b/SolidityNatspecJSON.cpp
@@ -21,9 +21,9 @@
*/
#include <boost/test/unit_test.hpp>
+#include <jsoncpp/json/json.h>
#include <libsolidity/CompilerStack.h>
#include <libsolidity/Exceptions.h>
-#include <jsonrpc/json/json.h>
#include <libdevcore/Exceptions.h>
namespace dev
@@ -394,6 +394,35 @@ BOOST_AUTO_TEST_CASE(dev_multiline_return)
checkNatspec(sourceCode, natspec, false);
}
+BOOST_AUTO_TEST_CASE(dev_multiline_comment)
+{
+ char const* sourceCode = "contract test {\n"
+ " /**\n"
+ " * @dev Multiplies a number by 7 and adds second parameter\n"
+ " * @param a Documentation for the first parameter starts here.\n"
+ " * Since it's a really complicated parameter we need 2 lines\n"
+ " * @param second Documentation for the second parameter\n"
+ " * @return The result of the multiplication\n"
+ " * and cookies with nutella\n"
+ " */"
+ " function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }\n"
+ "}\n";
+
+ char const* natspec = "{"
+ "\"methods\":{"
+ " \"mul\":{ \n"
+ " \"details\": \"Multiplies a number by 7 and adds second parameter\",\n"
+ " \"params\": {\n"
+ " \"a\": \"Documentation for the first parameter starts here. Since it's a really complicated parameter we need 2 lines\",\n"
+ " \"second\": \"Documentation for the second parameter\"\n"
+ " },\n"
+ " \"return\": \"The result of the multiplication and cookies with nutella\"\n"
+ " }\n"
+ "}}";
+
+ checkNatspec(sourceCode, natspec, false);
+}
+
BOOST_AUTO_TEST_CASE(dev_contract_no_doc)
{
char const* sourceCode = "contract test {\n"
diff --git a/solidityOptimizerTest.cpp b/SolidityOptimizer.cpp
index b689fe54..ef5c6f9b 100644
--- a/solidityOptimizerTest.cpp
+++ b/SolidityOptimizer.cpp
@@ -48,7 +48,7 @@ public:
m_optimize = true;
bytes optimizedBytecode = compileAndRun(_sourceCode, _value, _contractName);
int sizeDiff = nonOptimizedBytecode.size() - optimizedBytecode.size();
- BOOST_CHECK_MESSAGE(sizeDiff >= (int)_expectedSizeDecrease, "Bytecode did only shrink by "
+ BOOST_CHECK_MESSAGE(sizeDiff == int(_expectedSizeDecrease), "Bytecode did only shrink by "
+ boost::lexical_cast<string>(sizeDiff) + " bytes, expected: "
+ boost::lexical_cast<string>(_expectedSizeDecrease));
m_optimizedContract = m_contractAddress;
@@ -71,7 +71,7 @@ protected:
Address m_nonOptimizedContract;
};
-BOOST_FIXTURE_TEST_SUITE(SolidityOptimizerTest, OptimizerTestFramework)
+BOOST_FIXTURE_TEST_SUITE(SolidityOptimizer, OptimizerTestFramework)
BOOST_AUTO_TEST_CASE(smoke_test)
{
@@ -106,7 +106,7 @@ BOOST_AUTO_TEST_CASE(invariants)
return (((a + (1 - 1)) ^ 0) | 0) & (uint(0) - 1);
}
})";
- compileBothVersions(19, sourceCode);
+ compileBothVersions(28, sourceCode);
compareVersions(0, u256(0x12334664));
}
@@ -124,6 +124,21 @@ BOOST_AUTO_TEST_CASE(unused_expressions)
compareVersions(0);
}
+BOOST_AUTO_TEST_CASE(constant_folding_both_sides)
+{
+ // if constants involving the same associative and commutative operator are applied from both
+ // sides, the operator should be applied only once, because the expression compiler
+ // (even in non-optimized mode) pushes literals as late as possible
+ char const* sourceCode = R"(
+ contract test {
+ function f(uint x) returns (uint y) {
+ return 98 ^ (7 * ((1 | (x | 1000)) * 40) ^ 102);
+ }
+ })";
+ compileBothVersions(31, sourceCode);
+ compareVersions(0);
+}
+
BOOST_AUTO_TEST_SUITE_END()
}
diff --git a/solidityParser.cpp b/SolidityParser.cpp
index a9e2d531..c14c0512 100644
--- a/solidityParser.cpp
+++ b/SolidityParser.cpp
@@ -49,6 +49,23 @@ ASTPointer<ContractDefinition> parseText(std::string const& _source)
BOOST_FAIL("No contract found in source.");
return ASTPointer<ContractDefinition>();
}
+
+ASTPointer<ContractDefinition> parseTextExplainError(std::string const& _source)
+{
+ try
+ {
+ return parseText(_source);
+ }
+ catch (Exception const& exception)
+ {
+ // LTODO: Print the error in a kind of a better way?
+ // In absence of CompilerStack we can't use SourceReferenceFormatter
+ cout << "Exception while parsing: " << diagnostic_information(exception);
+ // rethrow to signal test failure
+ throw exception;
+ }
+}
+
}
@@ -111,7 +128,7 @@ BOOST_AUTO_TEST_CASE(function_natspec_documentation)
BOOST_REQUIRE_NO_THROW(contract = parseText(text));
auto functions = contract->getDefinedFunctions();
BOOST_REQUIRE_NO_THROW(function = functions.at(0));
- BOOST_CHECK_EQUAL(*function->getDocumentation(), " This is a test function");
+ BOOST_CHECK_EQUAL(*function->getDocumentation(), "This is a test function");
}
BOOST_AUTO_TEST_CASE(function_normal_comments)
@@ -149,17 +166,17 @@ BOOST_AUTO_TEST_CASE(multiple_functions_natspec_documentation)
auto functions = contract->getDefinedFunctions();
BOOST_REQUIRE_NO_THROW(function = functions.at(0));
- BOOST_CHECK_EQUAL(*function->getDocumentation(), " This is test function 1");
+ BOOST_CHECK_EQUAL(*function->getDocumentation(), "This is test function 1");
BOOST_REQUIRE_NO_THROW(function = functions.at(1));
- BOOST_CHECK_EQUAL(*function->getDocumentation(), " This is test function 2");
+ BOOST_CHECK_EQUAL(*function->getDocumentation(), "This is test function 2");
BOOST_REQUIRE_NO_THROW(function = functions.at(2));
BOOST_CHECK_MESSAGE(function->getDocumentation() == nullptr,
"Should not have gotten natspec comment for functionName3()");
BOOST_REQUIRE_NO_THROW(function = functions.at(3));
- BOOST_CHECK_EQUAL(*function->getDocumentation(), " This is test function 4");
+ BOOST_CHECK_EQUAL(*function->getDocumentation(), "This is test function 4");
}
BOOST_AUTO_TEST_CASE(multiline_function_documentation)
@@ -177,7 +194,7 @@ BOOST_AUTO_TEST_CASE(multiline_function_documentation)
BOOST_REQUIRE_NO_THROW(function = functions.at(0));
BOOST_CHECK_EQUAL(*function->getDocumentation(),
- " This is a test function\n"
+ "This is a test function\n"
" and it has 2 lines");
}
@@ -203,11 +220,11 @@ BOOST_AUTO_TEST_CASE(natspec_comment_in_function_body)
auto functions = contract->getDefinedFunctions();
BOOST_REQUIRE_NO_THROW(function = functions.at(0));
- BOOST_CHECK_EQUAL(*function->getDocumentation(), " fun1 description");
+ BOOST_CHECK_EQUAL(*function->getDocumentation(), "fun1 description");
BOOST_REQUIRE_NO_THROW(function = functions.at(1));
BOOST_CHECK_EQUAL(*function->getDocumentation(),
- " This is a test function\n"
+ "This is a test function\n"
" and it has 2 lines");
}
@@ -357,6 +374,53 @@ BOOST_AUTO_TEST_CASE(while_loop)
BOOST_CHECK_NO_THROW(parseText(text));
}
+BOOST_AUTO_TEST_CASE(for_loop_vardef_initexpr)
+{
+ char const* text = "contract test {\n"
+ " function fun(uint256 a) {\n"
+ " for (uint256 i = 0; i < 10; i++)\n"
+ " { uint256 x = i; break; continue; }\n"
+ " }\n"
+ "}\n";
+ BOOST_CHECK_NO_THROW(parseTextExplainError(text));
+}
+
+BOOST_AUTO_TEST_CASE(for_loop_simple_initexpr)
+{
+ char const* text = "contract test {\n"
+ " function fun(uint256 a) {\n"
+ " uint256 i =0;\n"
+ " for (i = 0; i < 10; i++)\n"
+ " { uint256 x = i; break; continue; }\n"
+ " }\n"
+ "}\n";
+ BOOST_CHECK_NO_THROW(parseTextExplainError(text));
+}
+
+BOOST_AUTO_TEST_CASE(for_loop_simple_noexpr)
+{
+ char const* text = "contract test {\n"
+ " function fun(uint256 a) {\n"
+ " uint256 i =0;\n"
+ " for (;;)\n"
+ " { uint256 x = i; break; continue; }\n"
+ " }\n"
+ "}\n";
+ BOOST_CHECK_NO_THROW(parseTextExplainError(text));
+}
+
+BOOST_AUTO_TEST_CASE(for_loop_single_stmt_body)
+{
+ char const* text = "contract test {\n"
+ " function fun(uint256 a) {\n"
+ " uint256 i =0;\n"
+ " for (i = 0; i < 10; i++)\n"
+ " continue;\n"
+ " }\n"
+ "}\n";
+ BOOST_CHECK_NO_THROW(parseTextExplainError(text));
+}
+
BOOST_AUTO_TEST_CASE(if_statement)
{
char const* text = "contract test {\n"
diff --git a/solidityScanner.cpp b/SolidityScanner.cpp
index 573affe6..355ea9e2 100644
--- a/solidityScanner.cpp
+++ b/SolidityScanner.cpp
@@ -157,7 +157,14 @@ BOOST_AUTO_TEST_CASE(documentation_comments_parsed_begin)
{
Scanner scanner(CharStream("/// Send $(value / 1000) chocolates to the user"));
BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::EOS);
- BOOST_CHECK_EQUAL(scanner.getCurrentCommentLiteral(), " Send $(value / 1000) chocolates to the user");
+ BOOST_CHECK_EQUAL(scanner.getCurrentCommentLiteral(), "Send $(value / 1000) chocolates to the user");
+}
+
+BOOST_AUTO_TEST_CASE(multiline_documentation_comments_parsed_begin)
+{
+ Scanner scanner(CharStream("/** Send $(value / 1000) chocolates to the user*/"));
+ BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::EOS);
+ BOOST_CHECK_EQUAL(scanner.getCurrentCommentLiteral(), "Send $(value / 1000) chocolates to the user");
}
BOOST_AUTO_TEST_CASE(documentation_comments_parsed)
@@ -167,7 +174,43 @@ BOOST_AUTO_TEST_CASE(documentation_comments_parsed)
BOOST_CHECK_EQUAL(scanner.next(), Token::IDENTIFIER);
BOOST_CHECK_EQUAL(scanner.next(), Token::IDENTIFIER);
BOOST_CHECK_EQUAL(scanner.next(), Token::EOS);
- BOOST_CHECK_EQUAL(scanner.getCurrentCommentLiteral(), " Send $(value / 1000) chocolates to the user");
+ BOOST_CHECK_EQUAL(scanner.getCurrentCommentLiteral(), "Send $(value / 1000) chocolates to the user");
+}
+
+BOOST_AUTO_TEST_CASE(multiline_documentation_comments_parsed)
+{
+ Scanner scanner(CharStream("some other tokens /**\n"
+ "* Send $(value / 1000) chocolates to the user\n"
+ "*/"));
+ BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::IDENTIFIER);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::IDENTIFIER);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::IDENTIFIER);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::EOS);
+ BOOST_CHECK_EQUAL(scanner.getCurrentCommentLiteral(), "Send $(value / 1000) chocolates to the user");
+}
+
+BOOST_AUTO_TEST_CASE(multiline_documentation_no_stars)
+{
+ Scanner scanner(CharStream("some other tokens /**\n"
+ " Send $(value / 1000) chocolates to the user\n"
+ "*/"));
+ BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::IDENTIFIER);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::IDENTIFIER);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::IDENTIFIER);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::EOS);
+ BOOST_CHECK_EQUAL(scanner.getCurrentCommentLiteral(), "Send $(value / 1000) chocolates to the user");
+}
+
+BOOST_AUTO_TEST_CASE(multiline_documentation_whitespace_hell)
+{
+ Scanner scanner(CharStream("some other tokens /** \t \r \n"
+ "\t \r * Send $(value / 1000) chocolates to the user\n"
+ "*/"));
+ BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::IDENTIFIER);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::IDENTIFIER);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::IDENTIFIER);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::EOS);
+ BOOST_CHECK_EQUAL(scanner.getCurrentCommentLiteral(), "Send $(value / 1000) chocolates to the user");
}
BOOST_AUTO_TEST_CASE(comment_before_eos)
@@ -184,6 +227,13 @@ BOOST_AUTO_TEST_CASE(documentation_comment_before_eos)
BOOST_CHECK_EQUAL(scanner.getCurrentCommentLiteral(), "");
}
+BOOST_AUTO_TEST_CASE(empty_multiline_documentation_comment_before_eos)
+{
+ Scanner scanner(CharStream("/***/"));
+ BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::EOS);
+ BOOST_CHECK_EQUAL(scanner.getCurrentCommentLiteral(), "");
+}
+
BOOST_AUTO_TEST_CASE(comments_mixed_in_sequence)
{
Scanner scanner(CharStream("hello_world ///documentation comment \n"
diff --git a/TestHelper.cpp b/TestHelper.cpp
index 6f7bf31d..ea848c7c 100644
--- a/TestHelper.cpp
+++ b/TestHelper.cpp
@@ -110,9 +110,6 @@ void ImportTest::importState(json_spirit::mObject& _o, State& _state)
Address address = Address(i.first);
- for (auto const& j: o["storage"].get_obj())
- _state.setStorage(address, toInt(j.first), toInt(j.second));
-
bytes code = importCode(o);
if (code.size())
@@ -123,6 +120,9 @@ void ImportTest::importState(json_spirit::mObject& _o, State& _state)
else
_state.m_cache[address] = Account(toInt(o["balance"]), Account::NormalCreation);
+ for (auto const& j: o["storage"].get_obj())
+ _state.setStorage(address, toInt(j.first), toInt(j.second));
+
for(int i=0; i<toInt(o["nonce"]); ++i)
_state.noteSending(address);
@@ -330,12 +330,12 @@ void checkStorage(map<u256, u256> _expectedStore, map<u256, u256> _resultStore,
BOOST_CHECK_MESSAGE(expectedStoreValue == resultStoreValue, _expectedAddr << ": store[" << expectedStoreKey << "] = " << resultStoreValue << ", expected " << expectedStoreValue);
}
}
-
- for (auto&& resultStorePair : _resultStore)
- {
- if (!_expectedStore.count(resultStorePair.first))
- BOOST_ERROR("unexpected result store key " << resultStorePair.first);
- }
+ BOOST_CHECK_EQUAL(_resultStore.size(), _expectedStore.size());
+ for (auto&& resultStorePair: _resultStore)
+ {
+ if (!_expectedStore.count(resultStorePair.first))
+ BOOST_ERROR(_expectedAddr << ": unexpected store key " << resultStorePair.first);
+ }
}
void checkLog(LogEntries _resultLogs, LogEntries _expectedLogs)
diff --git a/crypto.cpp b/crypto.cpp
index 466015ad..291893f5 100644
--- a/crypto.cpp
+++ b/crypto.cpp
@@ -44,6 +44,15 @@ static CryptoPP::OID s_curveOID(CryptoPP::ASN1::secp256k1());
static CryptoPP::DL_GroupParameters_EC<CryptoPP::ECP> s_params(s_curveOID);
static CryptoPP::DL_GroupParameters_EC<CryptoPP::ECP>::EllipticCurve s_curve(s_params.GetCurve());
+BOOST_AUTO_TEST_CASE(emptySHA3Types)
+{
+ h256 emptyListSHA3(fromHex("1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"));
+ BOOST_REQUIRE_EQUAL(emptyListSHA3, EmptyListSHA3);
+
+ h256 emptySHA3(fromHex("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"));
+ BOOST_REQUIRE_EQUAL(emptySHA3, EmptySHA3);
+}
+
BOOST_AUTO_TEST_CASE(cryptopp_patch)
{
KeyPair k = KeyPair::create();
diff --git a/genesis.cpp b/genesis.cpp
index 2cd9221a..8cdb8402 100644
--- a/genesis.cpp
+++ b/genesis.cpp
@@ -14,7 +14,7 @@
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
+/** @file genesis.cpp
* @author Gav Wood <i@gavwood.com>
* @date 2014
* Trie test functions.
@@ -36,6 +36,15 @@ namespace js = json_spirit;
BOOST_AUTO_TEST_SUITE(BasicTests)
+BOOST_AUTO_TEST_CASE(emptySHA3Types)
+{
+ h256 emptyListSHA3(fromHex("1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"));
+ BOOST_REQUIRE_EQUAL(emptyListSHA3, EmptyListSHA3);
+
+ h256 emptySHA3(fromHex("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"));
+ BOOST_REQUIRE_EQUAL(emptySHA3, EmptySHA3);
+}
+
BOOST_AUTO_TEST_CASE(genesis_tests)
{
string testPath = test::getTestPath();
diff --git a/hexPrefix.cpp b/hexPrefix.cpp
index 1f02bac9..551983db 100644
--- a/hexPrefix.cpp
+++ b/hexPrefix.cpp
@@ -14,7 +14,7 @@
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 main.cpp
+/** @file hexPrefix.cpp
* @author Gav Wood <i@gavwood.com>
* @date 2014
* Main test functions.
diff --git a/jsonrpc.cpp b/jsonrpc.cpp
index 20ffc6d5..37377407 100644
--- a/jsonrpc.cpp
+++ b/jsonrpc.cpp
@@ -29,8 +29,9 @@
#include <libwebthree/WebThree.h>
#include <libweb3jsonrpc/WebThreeStubServer.h>
#include <libweb3jsonrpc/CorsHttpServer.h>
-#include <jsonrpc/connectors/httpserver.h>
-#include <jsonrpc/connectors/httpclient.h>
+#include <json/json.h>
+#include <jsonrpccpp/server/connectors/httpserver.h>
+#include <jsonrpccpp/client/connectors/httpclient.h>
#include <set>
#include "JsonSpiritHeaders.h"
#include "TestHelper.h"
@@ -43,7 +44,7 @@ using namespace dev;
using namespace dev::eth;
namespace js = json_spirit;
-WebThreeDirect *web3;
+WebThreeDirect* web3;
unique_ptr<WebThreeStubServer> jsonrpcServer;
unique_ptr<WebThreeStubClient> jsonrpcClient;
@@ -61,11 +62,12 @@ struct Setup
web3->setIdealPeerCount(5);
web3->ethereum()->setForceMining(true);
- jsonrpcServer = unique_ptr<WebThreeStubServer>(new WebThreeStubServer(new jsonrpc::CorsHttpServer(8080), *web3, {}));
+ auto server = new jsonrpc::HttpServer(8080);
+ jsonrpcServer = unique_ptr<WebThreeStubServer>(new WebThreeStubServer(*server, *web3, {}));
jsonrpcServer->setIdentities({});
jsonrpcServer->StartListening();
-
- jsonrpcClient = unique_ptr<WebThreeStubClient>(new WebThreeStubClient(new jsonrpc::HttpClient("http://localhost:8080")));
+ auto client = new jsonrpc::HttpClient("http://localhost:8080");
+ jsonrpcClient = unique_ptr<WebThreeStubClient>(new WebThreeStubClient(*client));
}
};
@@ -300,8 +302,11 @@ BOOST_AUTO_TEST_CASE(contract_storage)
Json::Value storage = jsonrpcClient->eth_storageAt(contractAddress);
BOOST_CHECK_EQUAL(storage.getMemberNames().size(), 1);
+ // bracers are required, cause msvc couldnt handle this macro in for statement
for (auto name: storage.getMemberNames())
+ {
BOOST_CHECK_EQUAL(storage[name].asString(), "0x03");
+ }
}
BOOST_AUTO_TEST_SUITE_END()
diff --git a/solidityExecutionFramework.h b/solidityExecutionFramework.h
index 9d40e8a4..91ee7ad6 100644
--- a/solidityExecutionFramework.h
+++ b/solidityExecutionFramework.h
@@ -117,7 +117,7 @@ private:
void sendMessage(bytes const& _data, bool _isCreation, u256 const& _value = 0)
{
m_state.addBalance(m_sender, _value); // just in case
- eth::Executive executive(m_state);
+ eth::Executive executive(m_state, 0);
eth::Transaction t = _isCreation ? eth::Transaction(_value, m_gasPrice, m_gas, _data, 0, KeyPair::create().sec())
: eth::Transaction(_value, m_gasPrice, m_gas, m_contractAddress, _data, 0, KeyPair::create().sec());
bytes transactionRLP = t.rlp();
@@ -137,7 +137,7 @@ private:
else
{
BOOST_REQUIRE(m_state.addressHasCode(m_contractAddress));
- BOOST_REQUIRE(!executive.call(m_contractAddress, m_sender, _value, m_gasPrice, &_data, m_gas, m_sender));
+ BOOST_REQUIRE(!executive.call(m_contractAddress, m_contractAddress, m_sender, _value, m_gasPrice, &_data, m_gas, m_sender));
}
BOOST_REQUIRE(executive.go());
m_state.noteSending(m_sender);
diff --git a/stInitCodeTestFiller.json b/stInitCodeTestFiller.json
new file mode 100644
index 00000000..76d8f795
--- /dev/null
+++ b/stInitCodeTestFiller.json
@@ -0,0 +1,302 @@
+{
+ "TransactionContractCreation" : {
+ "env" : {
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
+ "currentDifficulty" : "45678256",
+ "currentGasLimit" : "1000000",
+ "currentNumber" : "0",
+ "currentTimestamp" : 1,
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "pre" :
+ {
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "100000",
+ "code" : "",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" :
+ {
+ "data" : "0x600a80600c6000396000f200600160008035811a8100",
+ "gasLimit" : "599",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "",
+ "value" : "1"
+ }
+ },
+
+
+ "NotEnoughCashContractCreation" : {
+ "env" : {
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
+ "currentDifficulty" : "45678256",
+ "currentGasLimit" : "1000000",
+ "currentNumber" : "0",
+ "currentTimestamp" : 1,
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "pre" :
+ {
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "2",
+ "code" : "",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" :
+ {
+ "data" : "0x600a80600c6000396000f200600160008035811a8100",
+ "gasLimit" : "599",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "",
+ "value" : "1"
+ }
+ },
+
+ "OutOfGasContractCreation" : {
+ "env" : {
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
+ "currentDifficulty" : "45678256",
+ "currentGasLimit" : "1000000",
+ "currentNumber" : "0",
+ "currentTimestamp" : 1,
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "pre" :
+ {
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "10000",
+ "code" : "",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" :
+ {
+ "data" : "0x600a80600c6000396000f200600160008035811a8100",
+ "gasLimit" : "590",
+ "gasPrice" : "3",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "",
+ "value" : "1"
+ }
+ },
+
+ "TransactionSuicideInitCode" : {
+ "env" : {
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
+ "currentDifficulty" : "45678256",
+ "currentGasLimit" : "1000000",
+ "currentNumber" : "0",
+ "currentTimestamp" : 1,
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "pre" :
+ {
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "10000",
+ "code" : "",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" :
+ {
+ "data" : "0x600a80600c6000396000fff2ffff600160008035811a81",
+ "gasLimit" : "1000",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "",
+ "value" : "1"
+ }
+ },
+
+ "TransactionStopInitCode" : {
+ "env" : {
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
+ "currentDifficulty" : "45678256",
+ "currentGasLimit" : "1000000",
+ "currentNumber" : "0",
+ "currentTimestamp" : 1,
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "pre" :
+ {
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "10000",
+ "code" : "",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" :
+ {
+ "data" : "0x600a80600c600039600000f20000600160008035811a81",
+ "gasLimit" : "1000",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "",
+ "value" : "1"
+ }
+ },
+
+ "TransactionCreateSuicideContract" : {
+ "env" : {
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
+ "currentDifficulty" : "45678256",
+ "currentGasLimit" : "1000000",
+ "currentNumber" : "0",
+ "currentTimestamp" : 1,
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "pre" :
+ {
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "10000",
+ "code" : "",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" :
+ {
+ "data" : "0x600a80600c6000396000f200ff600160008035811a81",
+ "gasLimit" : "1000",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "",
+ "value" : "1"
+ }
+ },
+
+ "CallTheContractToCreateEmptyContract" : {
+ "env" : {
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
+ "currentDifficulty" : "45678256",
+ "currentGasLimit" : "1000000",
+ "currentNumber" : "0",
+ "currentTimestamp" : 1,
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "pre" :
+ {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87": {
+ "balance": "0",
+ "nonce": 0,
+ "code": "{(CREATE 0 0 32)}",
+ "storage": {}
+ },
+
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "100000",
+ "code" : "",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" :
+ {
+ "data" : "0x00",
+ "gasLimit" : "10000",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "1"
+ }
+ },
+
+ "CallRecursiveContract" : {
+ "env" : {
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
+ "currentDifficulty" : "45678256",
+ "currentGasLimit" : "1000000",
+ "currentNumber" : "0",
+ "currentTimestamp" : 1,
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "pre" :
+ {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87": {
+ "balance": "0",
+ "nonce": 0,
+ "code": "{[[ 2 ]](ADDRESS)(CODECOPY 0 0 32)(CREATE 0 0 32)}",
+ "storage": {}
+ },
+
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "100000",
+ "code" : "",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" :
+ {
+ "data" : "0x00",
+ "gasLimit" : "10000",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "1"
+ }
+ },
+
+ "CallTheContractToCreateContractWithInitCode" : {
+ "env" : {
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
+ "currentDifficulty" : "45678256",
+ "currentGasLimit" : "1000000",
+ "currentNumber" : "0",
+ "currentTimestamp" : 1,
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "pre" :
+ {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87": {
+ "balance": "10000",
+ "nonce": 0,
+ "code": "{[[ 2 ]](ADDRESS)(CODECOPY 0 0 32)(CREATE 0 0 32)}",
+ "storage": {}
+ },
+
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "100000",
+ "code" : "",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" :
+ {
+ "data" : "0x00",
+ "gasLimit" : "10000",
+ "gasPrice" : "1",
+ "nonce" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "1"
+ }
+ }
+}
diff --git a/recursiveCreateFiller.json b/stRecursiveCreateFiller.json
index 0d18fb7a..0d18fb7a 100644
--- a/recursiveCreateFiller.json
+++ b/stRecursiveCreateFiller.json
diff --git a/stRefundTestFiller.json b/stRefundTestFiller.json
new file mode 100644
index 00000000..6b2b2fc1
--- /dev/null
+++ b/stRefundTestFiller.json
@@ -0,0 +1,308 @@
+{
+ "refund_getEtherBack" : {
+ "env" : {
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
+ "currentNumber" : "0",
+ "currentGasLimit" : "1000000",
+ "currentDifficulty" : "256",
+ "currentTimestamp" : 1,
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
+ },
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1000000000000000000",
+ "nonce" : 0,
+ "code" : "{ [[ 1 ]] 0 }",
+ "storage" : {
+ "0x01" : "0x01"
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000",
+ "nonce" : 0,
+ "code" : "",
+ "storage": {}
+ }
+ },
+ "transaction" : {
+ "nonce" : "0",
+ "gasPrice" : "1",
+ "gasLimit" : "850",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "10",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "data" : ""
+ }
+ },
+
+ "refund_changeNonZeroStorage" : {
+ "env" : {
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
+ "currentNumber" : "0",
+ "currentGasLimit" : "1000000",
+ "currentDifficulty" : "256",
+ "currentTimestamp" : 1,
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
+ },
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1000000000000000000",
+ "nonce" : 0,
+ "code" : "{ [[ 1 ]] 23 }",
+ "storage" : {
+ "0x01" : "0x01"
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000",
+ "nonce" : 0,
+ "code" : "",
+ "storage": {}
+ }
+ },
+ "transaction" : {
+ "nonce" : "0",
+ "gasPrice" : "1",
+ "gasLimit" : "850",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "10",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "data" : ""
+ }
+ },
+
+ "refund_OOG" : {
+ "env" : {
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
+ "currentNumber" : "0",
+ "currentGasLimit" : "1000000",
+ "currentDifficulty" : "256",
+ "currentTimestamp" : 1,
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
+ },
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1000000000000000000",
+ "nonce" : 0,
+ "code" : "{ [[ 1 ]] 0 }",
+ "storage" : {
+ "0x01" : "0x01"
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "500",
+ "nonce" : 0,
+ "code" : "",
+ "storage": {}
+ }
+ },
+ "transaction" : {
+ "nonce" : "0",
+ "gasPrice" : "1",
+ "gasLimit" : "500",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "data" : ""
+ }
+ },
+
+ "refund_NoOOG_1" : {
+ "env" : {
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
+ "currentNumber" : "0",
+ "currentGasLimit" : "1000000",
+ "currentDifficulty" : "256",
+ "currentTimestamp" : 1,
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
+ },
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1000000000000000000",
+ "nonce" : 0,
+ "code" : "{ [[ 1 ]] 0 }",
+ "storage" : {
+ "0x01" : "0x01"
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "502",
+ "nonce" : 0,
+ "code" : "",
+ "storage": {}
+ }
+ },
+ "transaction" : {
+ "nonce" : "0",
+ "gasPrice" : "1",
+ "gasLimit" : "502",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "data" : ""
+ }
+ },
+
+ "refund50_1" : {
+ "env" : {
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
+ "currentNumber" : "0",
+ "currentGasLimit" : "1000000",
+ "currentDifficulty" : "256",
+ "currentTimestamp" : 1,
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
+ },
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1000000000000000000",
+ "nonce" : 0,
+ "code" : "{ [[ 1 ]] 0 [[ 2 ]] 0 [[ 3 ]] 0 [[ 4 ]] 0 [[ 5 ]] 0 }",
+ "storage" : {
+ "0x01" : "0x01",
+ "0x02" : "0x01",
+ "0x03" : "0x01",
+ "0x04" : "0x01",
+ "0x05" : "0x01"
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "10000",
+ "nonce" : 0,
+ "code" : "",
+ "storage": {}
+ }
+ },
+ "transaction" : {
+ "nonce" : "0",
+ "gasPrice" : "1",
+ "gasLimit" : "10000",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "data" : ""
+ }
+ },
+
+ "refund50_2" : {
+ "env" : {
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
+ "currentNumber" : "0",
+ "currentGasLimit" : "1000000",
+ "currentDifficulty" : "256",
+ "currentTimestamp" : 1,
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
+ },
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1000000000000000000",
+ "nonce" : 0,
+ "code" : "{ [[ 10 ]] 1 [[ 11 ]] 1 [[ 1 ]] 0 [[ 2 ]] 0 [[ 3 ]] 0 [[ 4 ]] 0 [[ 5 ]] 0 }",
+ "storage" : {
+ "0x01" : "0x01",
+ "0x02" : "0x01",
+ "0x03" : "0x01",
+ "0x04" : "0x01",
+ "0x05" : "0x01"
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "10000",
+ "nonce" : 0,
+ "code" : "",
+ "storage": {}
+ }
+ },
+ "transaction" : {
+ "nonce" : "0",
+ "gasPrice" : "1",
+ "gasLimit" : "10000",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "data" : ""
+ }
+ },
+
+ "refund500" : {
+ "env" : {
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
+ "currentNumber" : "0",
+ "currentGasLimit" : "1000000",
+ "currentDifficulty" : "256",
+ "currentTimestamp" : 1,
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
+ },
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1000000000000000000",
+ "nonce" : 0,
+ "code" : "{ @@1 @@2 [[ 10 ]] (EXP 2 0xff) [[ 11 ]] (BALANCE (ADDRESS)) [[ 1 ]] 0 [[ 2 ]] 0 [[ 3 ]] 0 [[ 4 ]] 0 [[ 5 ]] 0 [[ 6 ]] 0 }",
+ "storage" : {
+ "0x01" : "0x01",
+ "0x02" : "0x01",
+ "0x03" : "0x01",
+ "0x04" : "0x01",
+ "0x05" : "0x01",
+ "0x06" : "0x01"
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "10000",
+ "nonce" : 0,
+ "code" : "",
+ "storage": {}
+ }
+ },
+ "transaction" : {
+ "nonce" : "0",
+ "gasPrice" : "1",
+ "gasLimit" : "10000",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "data" : ""
+ }
+ },
+
+ "refund600" : {
+ "env" : {
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
+ "currentNumber" : "0",
+ "currentGasLimit" : "1000000",
+ "currentDifficulty" : "256",
+ "currentTimestamp" : 1,
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
+ },
+ "pre" : {
+ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
+ "balance" : "1000000000000000000",
+ "nonce" : 0,
+ "code" : "{ @@1 @@2 [[ 10 ]] (EXP 2 0xffff) [[ 11 ]] (BALANCE (ADDRESS)) [[ 1 ]] 0 [[ 2 ]] 0 [[ 3 ]] 0 [[ 4 ]] 0 [[ 5 ]] 0 [[ 6 ]] 0 }",
+ "storage" : {
+ "0x01" : "0x01",
+ "0x02" : "0x01",
+ "0x03" : "0x01",
+ "0x04" : "0x01",
+ "0x05" : "0x01",
+ "0x06" : "0x01"
+ }
+ },
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "10000",
+ "nonce" : 0,
+ "code" : "",
+ "storage": {}
+ }
+ },
+ "transaction" : {
+ "nonce" : "0",
+ "gasPrice" : "1",
+ "gasLimit" : "10000",
+ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
+ "value" : "0",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "data" : ""
+ }
+ }
+
+}
diff --git a/stTransactionTestFiller.json b/stTransactionTestFiller.json
new file mode 100644
index 00000000..260e7953
--- /dev/null
+++ b/stTransactionTestFiller.json
@@ -0,0 +1,191 @@
+{
+ "EmptyTransaction" : {
+ "env" : {
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
+ "currentDifficulty" : "45678256",
+ "currentGasLimit" : "1000000",
+ "currentNumber" : "0",
+ "currentTimestamp" : 1,
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "pre" :
+ {
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "100000",
+ "code" : "",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" :
+ {
+ "data" : "",
+ "gasLimit" : "",
+ "gasPrice" : "",
+ "nonce" : "",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "",
+ "value" : ""
+ }
+ },
+
+ "TransactionSendingToEmpty" : {
+ "env" : {
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
+ "currentDifficulty" : "45678256",
+ "currentGasLimit" : "1000000",
+ "currentNumber" : "0",
+ "currentTimestamp" : 1,
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "pre" :
+ {
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "100000",
+ "code" : "",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" :
+ {
+ "data" : "",
+ "gasLimit" : "500",
+ "gasPrice" : "1",
+ "nonce" : "",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "",
+ "value" : ""
+ }
+ },
+
+
+ "TransactionSendingToZero" : {
+ "env" : {
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
+ "currentDifficulty" : "45678256",
+ "currentGasLimit" : "1000000",
+ "currentNumber" : "0",
+ "currentTimestamp" : 1,
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "pre" :
+ {
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "100000",
+ "code" : "",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" :
+ {
+ "data" : "",
+ "gasLimit" : "5000",
+ "gasPrice" : "1",
+ "nonce" : "",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "0000000000000000000000000000000000000000",
+ "value" : "1"
+ }
+ },
+
+
+ "TransactionToItself" : {
+ "env" : {
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
+ "currentDifficulty" : "45678256",
+ "currentGasLimit" : "1000000",
+ "currentNumber" : "0",
+ "currentTimestamp" : 1,
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "pre" :
+ {
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "100000",
+ "code" : "",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" :
+ {
+ "data" : "",
+ "gasLimit" : "5000",
+ "gasPrice" : "1",
+ "nonce" : "",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "a94f5374fce5edbc8e2a8697c15331677e6ebf0b",
+ "value" : "1"
+ }
+ },
+
+
+ "TransactionToItselfNotEnoughFounds" : {
+ "env" : {
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
+ "currentDifficulty" : "45678256",
+ "currentGasLimit" : "1000000",
+ "currentNumber" : "0",
+ "currentTimestamp" : 1,
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "pre" :
+ {
+ "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1101",
+ "code" : "",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" :
+ {
+ "data" : "",
+ "gasLimit" : "600",
+ "gasPrice" : "1",
+ "nonce" : "",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "a94f5374fce5edbc8e2a8697c15331677e6ebf0b",
+ "value" : "502"
+ }
+ },
+
+
+ "TransactionFromCoinbaseNotEnoughFounds" : {
+ "env" : {
+ "currentCoinbase" : "a94f5374fce5edbc8e2a8697c15331677e6ebf0b",
+ "currentDifficulty" : "45678256",
+ "currentGasLimit" : "1100",
+ "currentNumber" : "0",
+ "currentTimestamp" : 1,
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "pre" :
+ {
+ "b94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
+ "balance" : "1000",
+ "code" : "",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "transaction" :
+ {
+ "data" : "",
+ "gasLimit" : "600",
+ "gasPrice" : "1",
+ "nonce" : "",
+ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ "to" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b",
+ "value" : "502"
+ }
+ }
+}
diff --git a/state.cpp b/state.cpp
index 961f0f13..b1ad8d44 100644
--- a/state.cpp
+++ b/state.cpp
@@ -47,7 +47,7 @@ void doStateTests(json_spirit::mValue& v, bool _fillin)
for (auto& i: v.get_obj())
{
- cnote << i.first;
+ cerr << i.first << endl;
mObject& o = i.second.get_obj();
BOOST_REQUIRE(o.count("env") > 0);
@@ -132,11 +132,31 @@ BOOST_AUTO_TEST_CASE(stLogTests)
dev::test::executeTests("stLogTests", "/StateTests", dev::test::doStateTests);
}
+BOOST_AUTO_TEST_CASE(stRecursiveCreate)
+{
+ dev::test::executeTests("stRecursiveCreate", "/StateTests", dev::test::doStateTests);
+}
+
+BOOST_AUTO_TEST_CASE(stInitCodeTest)
+{
+ dev::test::executeTests("stInitCodeTest", "/StateTests", dev::test::doStateTests);
+}
+
+BOOST_AUTO_TEST_CASE(stTransactionTest)
+{
+ dev::test::executeTests("stTransactionTest", "/StateTests", dev::test::doStateTests);
+}
+
BOOST_AUTO_TEST_CASE(stSpecialTest)
{
dev::test::executeTests("stSpecialTest", "/StateTests", dev::test::doStateTests);
}
+BOOST_AUTO_TEST_CASE(stRefundTest)
+{
+ dev::test::executeTests("stRefundTest", "/StateTests", dev::test::doStateTests);
+}
+
BOOST_AUTO_TEST_CASE(stCreateTest)
{
for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i)
diff --git a/trie.cpp b/trie.cpp
index 3f072a6d..0cf87c21 100644
--- a/trie.cpp
+++ b/trie.cpp
@@ -54,7 +54,6 @@ BOOST_AUTO_TEST_CASE(trie_tests)
{
string testPath = test::getTestPath();
-
testPath += "/TrieTests";
cnote << "Testing Trie...";
@@ -245,6 +244,7 @@ BOOST_AUTO_TEST_CASE(moreTrieTests)
BOOST_AUTO_TEST_CASE(trieLowerBound)
{
cnote << "Stress-testing Trie.lower_bound...";
+ if (0)
{
MemoryDB dm;
EnforceRefs e(dm, true);
@@ -290,6 +290,7 @@ BOOST_AUTO_TEST_CASE(trieLowerBound)
BOOST_AUTO_TEST_CASE(trieStess)
{
cnote << "Stress-testing Trie...";
+ if (0)
{
MemoryDB m;
MemoryDB dm;
diff --git a/vm.cpp b/vm.cpp
index 075b3f2a..5b53bc37 100644
--- a/vm.cpp
+++ b/vm.cpp
@@ -35,18 +35,18 @@ using namespace dev::test;
FakeExtVM::FakeExtVM(eth::BlockInfo const& _previousBlock, eth::BlockInfo const& _currentBlock, unsigned _depth): /// TODO: XXX: remove the default argument & fix.
ExtVMFace(Address(), Address(), Address(), 0, 1, bytesConstRef(), bytes(), _previousBlock, _currentBlock, _depth) {}
-h160 FakeExtVM::create(u256 _endowment, u256* _gas, bytesConstRef _init, OnOpFunc const&)
+h160 FakeExtVM::create(u256 _endowment, u256& io_gas, bytesConstRef _init, OnOpFunc const&)
{
Address na = right160(sha3(rlpList(myAddress, get<1>(addresses[myAddress]))));
- Transaction t(_endowment, gasPrice, *_gas, _init.toBytes());
+ Transaction t(_endowment, gasPrice, io_gas, _init.toBytes());
callcreates.push_back(t);
return na;
}
-bool FakeExtVM::call(Address _receiveAddress, u256 _value, bytesConstRef _data, u256* _gas, bytesRef _out, OnOpFunc const&, Address _myAddressOverride, Address _codeAddressOverride)
+bool FakeExtVM::call(Address _receiveAddress, u256 _value, bytesConstRef _data, u256& io_gas, bytesRef _out, OnOpFunc const&, Address _myAddressOverride, Address _codeAddressOverride)
{
- Transaction t(_value, gasPrice, *_gas, _receiveAddress, _data.toVector());
+ Transaction t(_value, gasPrice, io_gas, _receiveAddress, _data.toVector());
callcreates.push_back(t);
(void)_out;
(void)_myAddressOverride;
@@ -263,12 +263,44 @@ eth::OnOpFunc FakeExtVM::simpleTrace()
dev::LogOutputStream<eth::VMTraceChannel, false>(true) << o.str();
dev::LogOutputStream<eth::VMTraceChannel, false>(false) << " | " << std::dec << ext.depth << " | " << ext.myAddress << " | #" << steps << " | " << std::hex << std::setw(4) << std::setfill('0') << vm.curPC() << " : " << instructionInfo(inst).name << " | " << std::dec << vm.gas() << " | -" << std::dec << gasCost << " | " << newMemSize << "x32" << " ]";
+ /*creates json stack trace*/
if (eth::VMTraceChannel::verbosity <= g_logVerbosity)
{
- std::ofstream f;
- f.open("./vmtrace.log", std::ofstream::app);
- f << o.str();
- f << " | " << std::dec << ext.depth << " | " << ext.myAddress << " | #" << steps << " | " << std::hex << std::setw(4) << std::setfill('0') << vm.curPC() << " : " << instructionInfo(inst).name << " | " << std::dec << vm.gas() << " | -" << std::dec << gasCost << " | " << newMemSize << "x32";
+ Object o_step;
+
+ /*add the stack*/
+ Array a_stack;
+ for (auto i: vm.stack())
+ a_stack.push_back((string)i);
+
+ o_step.push_back(Pair( "stack", a_stack ));
+
+ /*add the memory*/
+ Array a_mem;
+ for(auto i: vm.memory())
+ a_mem.push_back(i);
+
+ o_step.push_back(Pair("memory", a_mem));
+
+ /*add the storage*/
+ Object storage;
+ for (auto const& i: std::get<2>(ext.addresses.find(ext.myAddress)->second))
+ storage.push_back(Pair( (string)i.first , (string)i.second));
+
+ /*add all the other details*/
+ o_step.push_back(Pair("storage", storage));
+ o_step.push_back(Pair("depth", to_string(ext.depth)));
+ o_step.push_back(Pair("gas", (string)vm.gas()));
+ o_step.push_back(Pair("address", "0x" + toString(ext.myAddress )));
+ o_step.push_back(Pair("step", steps ));
+ o_step.push_back(Pair("pc", (int)vm.curPC()));
+ o_step.push_back(Pair("opcode", instructionInfo(inst).name ));
+
+ /*append the JSON object to the log file*/
+ Value v(o_step);
+ ofstream os( "./stackTrace.json", ofstream::app);
+ os << write_string(v, true) << ",";
+ os.close();
}
};
}
@@ -314,7 +346,7 @@ void doVMTests(json_spirit::mValue& v, bool _fillin)
}
catch (VMException const& _e)
{
- cnote << "VM did throw an exception: " << diagnostic_information(_e);
+ cnote << "Safe VM Exception";
vmExceptionOccured = true;
}
catch (Exception const& _e)
diff --git a/vm.h b/vm.h
index 3d4b88d5..0a5b5fb4 100644
--- a/vm.h
+++ b/vm.h
@@ -26,7 +26,7 @@ along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
#include <fstream>
#include <cstdint>
#include <boost/test/unit_test.hpp>
-#include "JsonSpiritHeaders.h"
+#include <json_spirit/json_spirit.h>
#include <libdevcore/Log.h>
#include <libdevcore/CommonIO.h>
#include <libevmcore/Instruction.h>
@@ -55,8 +55,8 @@ public:
virtual u256 txCount(Address _a) override { return std::get<1>(addresses[_a]); }
virtual void suicide(Address _a) override { std::get<0>(addresses[_a]) += std::get<0>(addresses[myAddress]); addresses.erase(myAddress); }
virtual bytes const& codeAt(Address _a) override { return std::get<3>(addresses[_a]); }
- virtual h160 create(u256 _endowment, u256* _gas, bytesConstRef _init, eth::OnOpFunc const&) override;
- virtual bool call(Address _receiveAddress, u256 _value, bytesConstRef _data, u256* _gas, bytesRef _out, eth::OnOpFunc const&, Address, Address) override;
+ virtual h160 create(u256 _endowment, u256& io_gas, bytesConstRef _init, eth::OnOpFunc const&) override;
+ virtual bool call(Address _receiveAddress, u256 _value, bytesConstRef _data, u256& io_gas, bytesRef _out, eth::OnOpFunc const&, Address, Address) override;
void setTransaction(Address _caller, u256 _value, u256 _gasPrice, bytes const& _data);
void setContract(Address _myAddress, u256 _myBalance, u256 _myNonce, std::map<u256, u256> const& _storage, bytes const& _code);
void set(Address _a, u256 _myBalance, u256 _myNonce, std::map<u256, u256> const& _storage, bytes const& _code);
diff --git a/webthreestubclient.h b/webthreestubclient.h
index f5fee4c0..9b36c364 100644
--- a/webthreestubclient.h
+++ b/webthreestubclient.h
@@ -1,639 +1,500 @@
/**
- * THIS FILE IS GENERATED BY jsonrpcstub, DO NOT CHANGE IT!!!!!
+ * This file is generated by jsonrpcstub, DO NOT CHANGE IT MANUALLY!
*/
-#ifndef _WEBTHREESTUBCLIENT_H_
-#define _WEBTHREESTUBCLIENT_H_
+#ifndef JSONRPC_CPP_STUB_WEBTHREESTUBCLIENT_H_
+#define JSONRPC_CPP_STUB_WEBTHREESTUBCLIENT_H_
-#include <jsonrpc/rpc.h>
+#include <jsonrpccpp/client.h>
-class WebThreeStubClient
+class WebThreeStubClient : public jsonrpc::Client
{
public:
- WebThreeStubClient(jsonrpc::AbstractClientConnector* conn)
- {
- this->client = new jsonrpc::Client(conn);
- }
- ~WebThreeStubClient()
- {
- delete this->client;
- }
+ WebThreeStubClient(jsonrpc::IClientConnector &conn) : jsonrpc::Client(conn) {}
- std::string db_get(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException)
+ std::string eth_coinbase() throw (jsonrpc::JsonRpcException)
{
Json::Value p;
- p.append(param1);
-p.append(param2);
-
- Json::Value result = this->client->CallMethod("db_get",p);
- if (result.isString())
- return result.asString();
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ 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());
}
-
- std::string db_getString(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException)
+ bool eth_setCoinbase(const std::string& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
-p.append(param2);
-
- Json::Value result = this->client->CallMethod("db_getString",p);
- if (result.isString())
- return result.asString();
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ Json::Value result = this->CallMethod("eth_setCoinbase",p);
+ if (result.isBool())
+ return result.asBool();
+ 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)
+ bool eth_listening() throw (jsonrpc::JsonRpcException)
{
Json::Value p;
- p.append(param1);
-p.append(param2);
-p.append(param3);
-
- Json::Value result = this->client->CallMethod("db_put",p);
- if (result.isBool())
- return result.asBool();
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ p = Json::nullValue;
+ Json::Value result = this->CallMethod("eth_listening",p);
+ if (result.isBool())
+ return result.asBool();
+ else
+ throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
-
- bool db_putString(const std::string& param1, const std::string& param2, const std::string& param3) throw (jsonrpc::JsonRpcException)
+ bool eth_setListening(const bool& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
-p.append(param2);
-p.append(param3);
-
- Json::Value result = this->client->CallMethod("db_putString",p);
- if (result.isBool())
- return result.asBool();
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ Json::Value result = this->CallMethod("eth_setListening",p);
+ if (result.isBool())
+ return result.asBool();
+ else
+ throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
-
- Json::Value eth_accounts() throw (jsonrpc::JsonRpcException)
+ bool eth_mining() throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p = Json::nullValue;
- Json::Value result = this->client->CallMethod("eth_accounts",p);
- if (result.isArray())
- return result;
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ 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_balanceAt(const std::string& param1) throw (jsonrpc::JsonRpcException)
+ bool eth_setMining(const bool& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
-
- Json::Value result = this->client->CallMethod("eth_balanceAt",p);
- if (result.isString())
- return result.asString();
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ Json::Value result = this->CallMethod("eth_setMining",p);
+ if (result.isBool())
+ return result.asBool();
+ else
+ throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
-
- Json::Value eth_blockByHash(const std::string& param1) throw (jsonrpc::JsonRpcException)
+ std::string eth_gasPrice() throw (jsonrpc::JsonRpcException)
{
Json::Value p;
- p.append(param1);
-
- Json::Value result = this->client->CallMethod("eth_blockByHash",p);
- if (result.isObject())
- return result;
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ 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_blockByNumber(const int& param1) throw (jsonrpc::JsonRpcException)
+ Json::Value eth_accounts() throw (jsonrpc::JsonRpcException)
{
Json::Value p;
- p.append(param1);
-
- Json::Value result = this->client->CallMethod("eth_blockByNumber",p);
- if (result.isObject())
- return result;
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ 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_call(const Json::Value& param1) throw (jsonrpc::JsonRpcException)
+ int eth_peerCount() throw (jsonrpc::JsonRpcException)
{
Json::Value p;
- p.append(param1);
-
- Json::Value result = this->client->CallMethod("eth_call",p);
- if (result.isString())
- return result.asString();
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ p = Json::nullValue;
+ Json::Value result = this->CallMethod("eth_peerCount",p);
+ if (result.isInt())
+ return result.asInt();
+ else
+ throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
-
- bool eth_changed(const int& param1) throw (jsonrpc::JsonRpcException)
+ int eth_defaultBlock() throw (jsonrpc::JsonRpcException)
{
Json::Value p;
- p.append(param1);
-
- Json::Value result = this->client->CallMethod("eth_changed",p);
- if (result.isBool())
- return result.asBool();
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ p = Json::nullValue;
+ Json::Value result = this->CallMethod("eth_defaultBlock",p);
+ if (result.isInt())
+ return result.asInt();
+ else
+ throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
-
- std::string eth_codeAt(const std::string& param1) throw (jsonrpc::JsonRpcException)
+ bool eth_setDefaultBlock(const int& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
-
- Json::Value result = this->client->CallMethod("eth_codeAt",p);
- if (result.isString())
- return result.asString();
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ Json::Value result = this->CallMethod("eth_setDefaultBlock",p);
+ if (result.isBool())
+ return result.asBool();
+ else
+ throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
-
- std::string eth_coinbase() throw (jsonrpc::JsonRpcException)
+ int eth_number() throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p = Json::nullValue;
- Json::Value result = this->client->CallMethod("eth_coinbase",p);
- if (result.isString())
- return result.asString();
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ Json::Value result = this->CallMethod("eth_number",p);
+ if (result.isInt())
+ return result.asInt();
+ else
+ throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
-
- Json::Value eth_compilers() throw (jsonrpc::JsonRpcException)
+ std::string eth_balanceAt(const std::string& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
- p = Json::nullValue;
- Json::Value result = this->client->CallMethod("eth_compilers",p);
- if (result.isArray())
- return result;
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ p.append(param1);
+ Json::Value result = this->CallMethod("eth_balanceAt",p);
+ if (result.isString())
+ return result.asString();
+ else
+ throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
-
- double eth_countAt(const std::string& param1) throw (jsonrpc::JsonRpcException)
+ std::string eth_stateAt(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
-
- Json::Value result = this->client->CallMethod("eth_countAt",p);
- if (result.isDouble())
- return result.asDouble();
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ p.append(param2);
+ Json::Value result = this->CallMethod("eth_stateAt",p);
+ if (result.isString())
+ return result.asString();
+ else
+ throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
-
- int eth_defaultBlock() throw (jsonrpc::JsonRpcException)
+ Json::Value eth_storageAt(const std::string& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
- p = Json::nullValue;
- Json::Value result = this->client->CallMethod("eth_defaultBlock",p);
- if (result.isInt())
- return result.asInt();
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ p.append(param1);
+ Json::Value result = this->CallMethod("eth_storageAt",p);
+ if (result.isObject())
+ return result;
+ else
+ throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
-
- Json::Value eth_filterLogs(const int& param1) throw (jsonrpc::JsonRpcException)
+ double eth_countAt(const std::string& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
-
- Json::Value result = this->client->CallMethod("eth_filterLogs",p);
- if (result.isArray())
- return result;
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ Json::Value result = this->CallMethod("eth_countAt",p);
+ if (result.isDouble())
+ return result.asDouble();
+ else
+ throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
-
- std::string eth_gasPrice() throw (jsonrpc::JsonRpcException)
+ std::string eth_codeAt(const std::string& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
- p = Json::nullValue;
- Json::Value result = this->client->CallMethod("eth_gasPrice",p);
- if (result.isString())
- return result.asString();
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ p.append(param1);
+ Json::Value result = this->CallMethod("eth_codeAt",p);
+ if (result.isString())
+ return result.asString();
+ else
+ throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
-
- bool eth_listening() throw (jsonrpc::JsonRpcException)
+ std::string eth_transact(const Json::Value& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
- p = Json::nullValue;
- Json::Value result = this->client->CallMethod("eth_listening",p);
- if (result.isBool())
- return result.asBool();
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ p.append(param1);
+ Json::Value result = this->CallMethod("eth_transact",p);
+ if (result.isString())
+ return result.asString();
+ else
+ throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
-
- std::string eth_lll(const std::string& param1) throw (jsonrpc::JsonRpcException)
+ std::string eth_call(const Json::Value& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
-
- Json::Value result = this->client->CallMethod("eth_lll",p);
- if (result.isString())
- return result.asString();
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ 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());
}
-
- Json::Value eth_logs(const Json::Value& param1) throw (jsonrpc::JsonRpcException)
+ Json::Value eth_blockByHash(const std::string& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
-
- Json::Value result = this->client->CallMethod("eth_logs",p);
- if (result.isArray())
- return result;
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ Json::Value result = this->CallMethod("eth_blockByHash",p);
+ if (result.isObject())
+ return result;
+ else
+ throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
-
- bool eth_mining() throw (jsonrpc::JsonRpcException)
+ Json::Value eth_blockByNumber(const int& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
- p = Json::nullValue;
- Json::Value result = this->client->CallMethod("eth_mining",p);
- if (result.isBool())
- return result.asBool();
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ p.append(param1);
+ Json::Value result = this->CallMethod("eth_blockByNumber",p);
+ if (result.isObject())
+ return result;
+ else
+ throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
-
- int eth_newFilter(const Json::Value& param1) throw (jsonrpc::JsonRpcException)
+ Json::Value eth_transactionByHash(const std::string& param1, const int& param2) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
-
- Json::Value result = this->client->CallMethod("eth_newFilter",p);
- if (result.isInt())
- return result.asInt();
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ p.append(param2);
+ Json::Value result = this->CallMethod("eth_transactionByHash",p);
+ if (result.isObject())
+ return result;
+ else
+ throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
-
- int eth_newFilterString(const std::string& param1) throw (jsonrpc::JsonRpcException)
+ Json::Value eth_transactionByNumber(const int& param1, const int& param2) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
-
- Json::Value result = this->client->CallMethod("eth_newFilterString",p);
- if (result.isInt())
- return result.asInt();
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ p.append(param2);
+ Json::Value result = this->CallMethod("eth_transactionByNumber",p);
+ if (result.isObject())
+ return result;
+ else
+ throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
-
- int eth_number() throw (jsonrpc::JsonRpcException)
+ Json::Value eth_uncleByHash(const std::string& param1, const int& param2) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
- p = Json::nullValue;
- Json::Value result = this->client->CallMethod("eth_number",p);
- if (result.isInt())
- return result.asInt();
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ p.append(param1);
+ p.append(param2);
+ Json::Value result = this->CallMethod("eth_uncleByHash",p);
+ if (result.isObject())
+ return result;
+ else
+ throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
-
- int eth_peerCount() throw (jsonrpc::JsonRpcException)
+ Json::Value eth_uncleByNumber(const int& param1, const int& param2) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
- p = Json::nullValue;
- Json::Value result = this->client->CallMethod("eth_peerCount",p);
- if (result.isInt())
- return result.asInt();
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ p.append(param1);
+ p.append(param2);
+ Json::Value result = this->CallMethod("eth_uncleByNumber",p);
+ if (result.isObject())
+ return result;
+ else
+ throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
-
- std::string eth_serpent(const std::string& param1) throw (jsonrpc::JsonRpcException)
+ Json::Value eth_compilers() throw (jsonrpc::JsonRpcException)
{
Json::Value p;
- p.append(param1);
-
- Json::Value result = this->client->CallMethod("eth_serpent",p);
- if (result.isString())
- return result.asString();
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ p = Json::nullValue;
+ Json::Value result = this->CallMethod("eth_compilers",p);
+ if (result.isArray())
+ return result;
+ else
+ throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
-
- bool eth_setCoinbase(const std::string& param1) throw (jsonrpc::JsonRpcException)
+ std::string eth_lll(const std::string& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
-
- Json::Value result = this->client->CallMethod("eth_setCoinbase",p);
- if (result.isBool())
- return result.asBool();
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ Json::Value result = this->CallMethod("eth_lll",p);
+ if (result.isString())
+ return result.asString();
+ else
+ throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
-
- bool eth_setDefaultBlock(const int& param1) throw (jsonrpc::JsonRpcException)
+ std::string eth_solidity(const std::string& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
-
- Json::Value result = this->client->CallMethod("eth_setDefaultBlock",p);
- if (result.isBool())
- return result.asBool();
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ Json::Value result = this->CallMethod("eth_solidity",p);
+ if (result.isString())
+ return result.asString();
+ else
+ throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
-
- bool eth_setListening(const bool& param1) throw (jsonrpc::JsonRpcException)
+ std::string eth_serpent(const std::string& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
-
- Json::Value result = this->client->CallMethod("eth_setListening",p);
- if (result.isBool())
- return result.asBool();
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ Json::Value result = this->CallMethod("eth_serpent",p);
+ if (result.isString())
+ return result.asString();
+ else
+ throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
-
- bool eth_setMining(const bool& param1) throw (jsonrpc::JsonRpcException)
+ int eth_newFilter(const Json::Value& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
-
- Json::Value result = this->client->CallMethod("eth_setMining",p);
- if (result.isBool())
- return result.asBool();
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ Json::Value result = this->CallMethod("eth_newFilter",p);
+ if (result.isInt())
+ return result.asInt();
+ else
+ throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
-
- std::string eth_solidity(const std::string& param1) throw (jsonrpc::JsonRpcException)
+ int eth_newFilterString(const std::string& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
-
- Json::Value result = this->client->CallMethod("eth_solidity",p);
- if (result.isString())
- return result.asString();
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ Json::Value result = this->CallMethod("eth_newFilterString",p);
+ if (result.isInt())
+ return result.asInt();
+ else
+ throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
-
- std::string eth_stateAt(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException)
+ bool eth_uninstallFilter(const int& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
-p.append(param2);
-
- Json::Value result = this->client->CallMethod("eth_stateAt",p);
- if (result.isString())
- return result.asString();
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ 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_storageAt(const std::string& param1) throw (jsonrpc::JsonRpcException)
+ bool eth_changed(const int& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
-
- Json::Value result = this->client->CallMethod("eth_storageAt",p);
- if (result.isObject())
- return result;
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ Json::Value result = this->CallMethod("eth_changed",p);
+ if (result.isBool())
+ return result.asBool();
+ else
+ throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
-
- std::string eth_transact(const Json::Value& param1) throw (jsonrpc::JsonRpcException)
+ Json::Value eth_filterLogs(const int& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
-
- Json::Value result = this->client->CallMethod("eth_transact",p);
- if (result.isString())
- return result.asString();
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ Json::Value result = this->CallMethod("eth_filterLogs",p);
+ if (result.isArray())
+ return result;
+ else
+ throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
-
- Json::Value eth_transactionByHash(const std::string& param1, const int& param2) throw (jsonrpc::JsonRpcException)
+ Json::Value eth_logs(const Json::Value& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
-p.append(param2);
-
- Json::Value result = this->client->CallMethod("eth_transactionByHash",p);
- if (result.isObject())
- return result;
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ Json::Value result = this->CallMethod("eth_logs",p);
+ if (result.isArray())
+ return result;
+ else
+ throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
-
- Json::Value eth_transactionByNumber(const int& param1, const int& param2) throw (jsonrpc::JsonRpcException)
+ 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);
-
- Json::Value result = this->client->CallMethod("eth_transactionByNumber",p);
- if (result.isObject())
- return result;
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ 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());
}
-
- Json::Value eth_uncleByHash(const std::string& param1, const int& param2) throw (jsonrpc::JsonRpcException)
+ 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->client->CallMethod("eth_uncleByHash",p);
- if (result.isObject())
- return result;
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ 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());
}
-
- Json::Value eth_uncleByNumber(const int& param1, const int& param2) throw (jsonrpc::JsonRpcException)
+ bool db_putString(const std::string& param1, const std::string& param2, const std::string& param3) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
-p.append(param2);
-
- Json::Value result = this->client->CallMethod("eth_uncleByNumber",p);
- if (result.isObject())
- return result;
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ p.append(param2);
+ p.append(param3);
+ Json::Value result = this->CallMethod("db_putString",p);
+ if (result.isBool())
+ return result.asBool();
+ else
+ throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
-
- bool eth_uninstallFilter(const int& param1) throw (jsonrpc::JsonRpcException)
+ std::string db_getString(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
-
- Json::Value result = this->client->CallMethod("eth_uninstallFilter",p);
- if (result.isBool())
- return result.asBool();
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ p.append(param2);
+ Json::Value result = this->CallMethod("db_getString",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)
+ bool shh_post(const Json::Value& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
-p.append(param2);
-
- Json::Value result = this->client->CallMethod("shh_addToGroup",p);
- if (result.isString())
- return result.asString();
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ 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());
}
-
- Json::Value shh_changed(const int& param1) throw (jsonrpc::JsonRpcException)
+ std::string shh_newIdentity() throw (jsonrpc::JsonRpcException)
{
Json::Value p;
- p.append(param1);
-
- Json::Value result = this->client->CallMethod("shh_changed",p);
- if (result.isArray())
- return result;
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ 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_haveIdentity(const std::string& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
-
- Json::Value result = this->client->CallMethod("shh_haveIdentity",p);
- if (result.isBool())
- return result.asBool();
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ Json::Value result = this->CallMethod("shh_haveIdentity",p);
+ if (result.isBool())
+ return result.asBool();
+ else
+ throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
-
- int shh_newFilter(const Json::Value& param1) throw (jsonrpc::JsonRpcException)
+ std::string shh_newGroup(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
-
- Json::Value result = this->client->CallMethod("shh_newFilter",p);
- if (result.isInt())
- return result.asInt();
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ 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_newGroup(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException)
+ 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->client->CallMethod("shh_newGroup",p);
- if (result.isString())
- return result.asString();
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ 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_newIdentity() throw (jsonrpc::JsonRpcException)
+ int shh_newFilter(const Json::Value& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
- p = Json::nullValue;
- Json::Value result = this->client->CallMethod("shh_newIdentity",p);
- if (result.isString())
- return result.asString();
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ p.append(param1);
+ Json::Value result = this->CallMethod("shh_newFilter",p);
+ if (result.isInt())
+ return result.asInt();
+ else
+ throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
-
- bool shh_post(const Json::Value& param1) throw (jsonrpc::JsonRpcException)
+ bool shh_uninstallFilter(const int& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
-
- Json::Value result = this->client->CallMethod("shh_post",p);
- if (result.isBool())
- return result.asBool();
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ 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());
}
-
- bool shh_uninstallFilter(const int& param1) throw (jsonrpc::JsonRpcException)
+ Json::Value shh_changed(const int& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
-
- Json::Value result = this->client->CallMethod("shh_uninstallFilter",p);
- if (result.isBool())
- return result.asBool();
- else
- throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
-
+ Json::Value result = this->CallMethod("shh_changed",p);
+ if (result.isArray())
+ return result;
+ else
+ throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
-
- private:
- jsonrpc::Client* client;
};
-#endif //_WEBTHREESTUBCLIENT_H_
+
+#endif //JSONRPC_CPP_WEBTHREESTUBCLIENT_H_
diff --git a/whisperTopic.cpp b/whisperTopic.cpp
index c5e59332..79adf3d6 100644
--- a/whisperTopic.cpp
+++ b/whisperTopic.cpp
@@ -33,7 +33,8 @@ BOOST_AUTO_TEST_SUITE(whisper)
BOOST_AUTO_TEST_CASE(topic)
{
cnote << "Testing Whisper...";
-// g_logVerbosity = 0;
+ auto oldLogVerbosity = g_logVerbosity;
+ g_logVerbosity = 0;
bool started = false;
unsigned result = 0;
@@ -81,7 +82,7 @@ BOOST_AUTO_TEST_CASE(topic)
}
listener.join();
-// g_logVerbosity = 0;
+ g_logVerbosity = oldLogVerbosity;
BOOST_REQUIRE_EQUAL(result, 1 + 9 + 25 + 49 + 81);
}