aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsubtly <subtly@users.noreply.github.com>2014-12-22 08:52:32 +0800
committersubtly <subtly@users.noreply.github.com>2014-12-22 08:52:32 +0800
commit4869ec79517fb0c1c7e99c960bf131c096856620 (patch)
treed8d5ed3382dd6acd42c456f9d682d80d7ce122bf
parent400d19b140acda22ffad294db5f8958190f728e4 (diff)
parent1540cc7b56669b050e22f79d76242a1890f33129 (diff)
downloaddexon-solidity-4869ec79517fb0c1c7e99c960bf131c096856620.tar.gz
dexon-solidity-4869ec79517fb0c1c7e99c960bf131c096856620.tar.zst
dexon-solidity-4869ec79517fb0c1c7e99c960bf131c096856620.zip
Merge branch 'develop' into p2p
-rw-r--r--SolidityABIJSON.cpp53
-rw-r--r--SolidityEndToEndTest.cpp35
-rw-r--r--SolidityNameAndTypeResolution.cpp10
-rw-r--r--SolidityNatspecJSON.cpp29
-rw-r--r--SolidityParser.cpp14
-rw-r--r--SolidityScanner.cpp54
-rw-r--r--TestHelper.cpp19
-rw-r--r--TestHelper.h1
-rw-r--r--createRandomTest.cpp22
-rw-r--r--jsonrpc.cpp4
-rw-r--r--stRefundTestFiller.json163
-rw-r--r--state.cpp2
-rw-r--r--vm.cpp24
13 files changed, 404 insertions, 26 deletions
diff --git a/SolidityABIJSON.cpp b/SolidityABIJSON.cpp
index c734009c..4c7c2381 100644
--- a/SolidityABIJSON.cpp
+++ b/SolidityABIJSON.cpp
@@ -76,6 +76,7 @@ BOOST_AUTO_TEST_CASE(basic_test)
char const* interface = R"([
{
"name": "f",
+ "constant": false,
"inputs": [
{
"name": "a",
@@ -114,6 +115,7 @@ BOOST_AUTO_TEST_CASE(multiple_methods)
char const* interface = R"([
{
"name": "f",
+ "constant": false,
"inputs": [
{
"name": "a",
@@ -129,6 +131,7 @@ BOOST_AUTO_TEST_CASE(multiple_methods)
},
{
"name": "g",
+ "constant": false,
"inputs": [
{
"name": "b",
@@ -156,6 +159,7 @@ BOOST_AUTO_TEST_CASE(multiple_params)
char const* interface = R"([
{
"name": "f",
+ "constant": false,
"inputs": [
{
"name": "a",
@@ -189,6 +193,7 @@ BOOST_AUTO_TEST_CASE(multiple_methods_order)
char const* interface = R"([
{
"name": "c",
+ "constant": false,
"inputs": [
{
"name": "b",
@@ -204,6 +209,7 @@ BOOST_AUTO_TEST_CASE(multiple_methods_order)
},
{
"name": "f",
+ "constant": 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",
+ "constant": true,
+ "inputs": [{
+ "name": "a",
+ "type": "uint32"
+ }],
+ "outputs": [
+ {
+ "name": "b",
+ "type": "uint256"
+ }
+ ]
+ },
+ {
+ "name": "foo",
+ "constant": 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/SolidityEndToEndTest.cpp b/SolidityEndToEndTest.cpp
index aa74f818..9559e370 100644
--- a/SolidityEndToEndTest.cpp
+++ b/SolidityEndToEndTest.cpp
@@ -504,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"
diff --git a/SolidityNameAndTypeResolution.cpp b/SolidityNameAndTypeResolution.cpp
index 0bda0a1f..25bff71f 100644
--- a/SolidityNameAndTypeResolution.cpp
+++ b/SolidityNameAndTypeResolution.cpp
@@ -311,6 +311,16 @@ BOOST_AUTO_TEST_CASE(forward_function_reference)
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 2c3ded08..5b48a67c 100644
--- a/SolidityNatspecJSON.cpp
+++ b/SolidityNatspecJSON.cpp
@@ -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/SolidityParser.cpp b/SolidityParser.cpp
index f978cdd9..c14c0512 100644
--- a/SolidityParser.cpp
+++ b/SolidityParser.cpp
@@ -128,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)
@@ -166,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)
@@ -194,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");
}
@@ -220,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");
}
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 b700b65a..ea848c7c 100644
--- a/TestHelper.cpp
+++ b/TestHelper.cpp
@@ -26,6 +26,7 @@
#include <boost/filesystem/path.hpp>
#include <libethereum/Client.h>
#include <liblll/Compiler.h>
+#include <libevm/VMFactory.h>
using namespace std;
using namespace dev::eth;
@@ -330,7 +331,7 @@ void checkStorage(map<u256, u256> _expectedStore, map<u256, u256> _resultStore,
}
}
BOOST_CHECK_EQUAL(_resultStore.size(), _expectedStore.size());
- for (auto&& resultStorePair : _resultStore)
+ for (auto&& resultStorePair: _resultStore)
{
if (!_expectedStore.count(resultStorePair.first))
BOOST_ERROR(_expectedAddr << ": unexpected store key " << resultStorePair.first);
@@ -472,4 +473,20 @@ void executeTests(const string& _name, const string& _testPathAppendix, std::fun
}
}
+
+void processCommandLineOptions()
+{
+ auto argc = boost::unit_test::framework::master_test_suite().argc;
+ auto argv = boost::unit_test::framework::master_test_suite().argv;
+
+ for (auto i = 0; i < argc; ++i)
+ {
+ if (std::string(argv[i]) == "--jit")
+ {
+ eth::VMFactory::setKind(eth::VMKind::JIT);
+ break;
+ }
+ }
+}
+
} } // namespaces
diff --git a/TestHelper.h b/TestHelper.h
index 3203eae8..20328c91 100644
--- a/TestHelper.h
+++ b/TestHelper.h
@@ -76,6 +76,7 @@ void checkLog(eth::LogEntries _resultLogs, eth::LogEntries _expectedLogs);
void executeTests(const std::string& _name, const std::string& _testPathAppendix, std::function<void(json_spirit::mValue&, bool)> doTests);
std::string getTestPath();
void userDefinedTest(std::string testTypeFlag, std::function<void(json_spirit::mValue&, bool)> doTests);
+void processCommandLineOptions();
template<typename mapType>
void checkAddresses(mapType& _expectedAddrs, mapType& _resultAddrs)
diff --git a/createRandomTest.cpp b/createRandomTest.cpp
index a1168845..1af12f64 100644
--- a/createRandomTest.cpp
+++ b/createRandomTest.cpp
@@ -1,18 +1,18 @@
/*
- This file is part of cpp-ethereum.
+ This file is part of cpp-ethereum.
- cpp-ethereum is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
+ cpp-ethereum is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
- cpp-ethereum is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ cpp-ethereum is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
+ 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 createRandomTest.cpp
* @author Christoph Jentzsch <jentzsch.simulationsoftware@gmail.com>
diff --git a/jsonrpc.cpp b/jsonrpc.cpp
index 37377407..4a35a2e0 100644
--- a/jsonrpc.cpp
+++ b/jsonrpc.cpp
@@ -19,7 +19,7 @@
* @date 2014
*/
-#if ETH_JSONRPC && 0
+#if ETH_JSONRPC
#include <boost/test/unit_test.hpp>
#include <boost/lexical_cast.hpp>
@@ -29,7 +29,7 @@
#include <libwebthree/WebThree.h>
#include <libweb3jsonrpc/WebThreeStubServer.h>
#include <libweb3jsonrpc/CorsHttpServer.h>
-#include <json/json.h>
+//#include <json/json.h>
#include <jsonrpccpp/server/connectors/httpserver.h>
#include <jsonrpccpp/client/connectors/httpclient.h>
#include <set>
diff --git a/stRefundTestFiller.json b/stRefundTestFiller.json
index 4060bbb7..6b2b2fc1 100644
--- a/stRefundTestFiller.json
+++ b/stRefundTestFiller.json
@@ -141,5 +141,168 @@
"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/state.cpp b/state.cpp
index d8a3dd28..b1ad8d44 100644
--- a/state.cpp
+++ b/state.cpp
@@ -43,6 +43,8 @@ namespace dev { namespace test {
void doStateTests(json_spirit::mValue& v, bool _fillin)
{
+ processCommandLineOptions();
+
for (auto& i: v.get_obj())
{
cerr << i.first << endl;
diff --git a/vm.cpp b/vm.cpp
index 010eb4d7..920f0582 100644
--- a/vm.cpp
+++ b/vm.cpp
@@ -20,6 +20,7 @@
* vm test functions.
*/
+#include <chrono>
#include <boost/filesystem.hpp>
#include <libethereum/Executive.h>
#include <libevm/VMFactory.h>
@@ -308,6 +309,8 @@ namespace dev { namespace test {
void doVMTests(json_spirit::mValue& v, bool _fillin)
{
+ processCommandLineOptions();
+
for (auto& i: v.get_obj())
{
cnote << i.first;
@@ -317,7 +320,7 @@ void doVMTests(json_spirit::mValue& v, bool _fillin)
BOOST_REQUIRE(o.count("pre") > 0);
BOOST_REQUIRE(o.count("exec") > 0);
- dev::test::FakeExtVM fev;
+ FakeExtVM fev;
fev.importEnv(o["env"].get_obj());
fev.importState(o["pre"].get_obj());
@@ -332,12 +335,12 @@ void doVMTests(json_spirit::mValue& v, bool _fillin)
}
bytes output;
- auto vm = eth::VMFactory::create(fev.gas);
-
u256 gas;
bool vmExceptionOccured = false;
+ auto startTime = std::chrono::high_resolution_clock::now();
try
{
+ auto vm = eth::VMFactory::create(fev.gas);
output = vm->go(fev, fev.simpleTrace()).toBytes();
gas = vm->gas();
}
@@ -357,6 +360,21 @@ void doVMTests(json_spirit::mValue& v, bool _fillin)
BOOST_ERROR("Failed VM Test with Exception: " << _e.what());
}
+ auto endTime = std::chrono::high_resolution_clock::now();
+ auto argc = boost::unit_test::framework::master_test_suite().argc;
+ auto argv = boost::unit_test::framework::master_test_suite().argv;
+ for (auto i = 0; i < argc; ++i)
+ {
+ if (std::string(argv[i]) == "--show-times")
+ {
+ auto testDuration = endTime - startTime;
+ cnote << "Execution time: "
+ << std::chrono::duration_cast<std::chrono::milliseconds>(testDuration).count()
+ << " ms";
+ break;
+ }
+ }
+
// delete null entries in storage for the sake of comparison
for (auto &a: fev.addresses)