aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaweł Bylica <pawel.bylica@imapp.pl>2014-12-19 02:08:04 +0800
committerPaweł Bylica <pawel.bylica@imapp.pl>2014-12-19 02:08:04 +0800
commit35d8b94e73c3754f498339425eca3c32c31fcd14 (patch)
tree2d01232a552596b6026db590886787fa5f0aed6e
parentf59119769239a4ad14a37d8d48bf22996b1de1fb (diff)
parentf4cdc4a9fa7afac2b693d97fbbdb3a03d2e5e34f (diff)
downloaddexon-solidity-35d8b94e73c3754f498339425eca3c32c31fcd14.tar.gz
dexon-solidity-35d8b94e73c3754f498339425eca3c32c31fcd14.tar.zst
dexon-solidity-35d8b94e73c3754f498339425eca3c32c31fcd14.zip
Merge branch 'develop' into develop-evmcc
Conflicts: CMakeLists.txt alethzero/CMakeLists.txt eth/CMakeLists.txt exp/CMakeLists.txt libethereum/CMakeLists.txt neth/CMakeLists.txt test/CMakeLists.txt test/TestHelper.cpp windows/Eth.vcxproj windows/Ethereum.sln windows/LibEthereum.vcxproj windows/LibEthereum.vcxproj.filters windows/TestEthereum.vcxproj windows/TestEthereum.vcxproj.filters windows/bootstrap.sh
-rw-r--r--CMakeLists.txt42
-rw-r--r--crypto.cpp9
-rw-r--r--genesis.cpp11
-rw-r--r--hexPrefix.cpp2
-rw-r--r--jsonrpc.cpp15
-rw-r--r--solidityCompiler.cpp13
-rw-r--r--solidityEndToEndTest.cpp154
-rw-r--r--solidityExpressionCompiler.cpp12
-rw-r--r--solidityJSONInterfaceTest.cpp2
-rw-r--r--solidityNameAndTypeResolution.cpp27
-rw-r--r--solidityNatspecJSON.cpp2
-rw-r--r--solidityParser.cpp64
-rw-r--r--stInitCodeTestFiller.json302
-rw-r--r--stRecursiveCreateFiller.json (renamed from recursiveCreateFiller.json)0
-rw-r--r--stRefundTestFiller.json145
-rw-r--r--stTransactionTestFiller.json191
-rw-r--r--state.cpp20
-rw-r--r--vm.cpp42
-rw-r--r--vm.h2
-rw-r--r--webthreestubclient.h775
20 files changed, 1307 insertions, 523 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3336b428..441200fe 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,52 +3,32 @@ 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)
+
+if (JSONRPC)
+ target_link_libraries(testeth web3jsonrpc)
+ target_link_libraries(testeth ${JSON_RPC_CPP_CLIENT_LIBRARIES})
endif()
if (EVMJIT)
target_link_libraries(testeth evmjit-cpp)
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/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 970957b5..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"
@@ -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/solidityCompiler.cpp b/solidityCompiler.cpp
index eae8f314..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();
diff --git a/solidityEndToEndTest.cpp b/solidityEndToEndTest.cpp
index af8b58ba..26f5528a 100644
--- a/solidityEndToEndTest.cpp
+++ b/solidityEndToEndTest.cpp
@@ -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
@@ -402,7 +476,7 @@ BOOST_AUTO_TEST_CASE(empty_string_on_stack)
" }\n"
"}\n";
compileAndRun(sourceCode);
- BOOST_CHECK(callContractFunction(0, bytes({0x02})) == bytes({0x00, 0x02, 'a', 'b', 'c', 0x00}));
+ BOOST_CHECK(callContractFunction(0, bytes(1, 0x02)) == bytes({0x00, 0x02, 0x61/*'a'*/, 0x62/*'b'*/, 0x63/*'c'*/, 0x00}));
}
BOOST_AUTO_TEST_CASE(state_smoke_test)
@@ -442,22 +516,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)
@@ -625,9 +700,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)
@@ -653,9 +728,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)
@@ -1011,6 +1086,49 @@ BOOST_AUTO_TEST_CASE(strings_in_calls)
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/solidityJSONInterfaceTest.cpp b/solidityJSONInterfaceTest.cpp
index 487508bb..c734009c 100644
--- a/solidityJSONInterfaceTest.cpp
+++ b/solidityJSONInterfaceTest.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
diff --git a/solidityNameAndTypeResolution.cpp b/solidityNameAndTypeResolution.cpp
index 03eaebb3..0bda0a1f 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);
}
}
@@ -284,6 +287,30 @@ 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_SUITE_END()
}
diff --git a/solidityNatspecJSON.cpp b/solidityNatspecJSON.cpp
index 641bb82a..2c3ded08 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
diff --git a/solidityParser.cpp b/solidityParser.cpp
index a9e2d531..f978cdd9 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;
+ }
+}
+
}
@@ -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/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..4060bbb7
--- /dev/null
+++ b/stRefundTestFiller.json
@@ -0,0 +1,145 @@
+{
+ "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" : ""
+ }
+ }
+}
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 11ecf48c..b1ad8d44 100644
--- a/state.cpp
+++ b/state.cpp
@@ -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/vm.cpp b/vm.cpp
index 1e9d040d..5b53bc37 100644
--- a/vm.cpp
+++ b/vm.cpp
@@ -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 ff948cbf..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>
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_