aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt6
-rw-r--r--SolidityEndToEndTest.cpp112
-rw-r--r--SolidityNameAndTypeResolution.cpp12
-rw-r--r--TestHelper.cpp13
-rw-r--r--TestHelper.h2
-rw-r--r--boostTest.cpp2
-rw-r--r--checkRandomTest.cpp297
-rw-r--r--createRandomTest.cpp24
-rw-r--r--vm.cpp17
-rw-r--r--vmArithmeticTestFiller.json168
-rw-r--r--vmSystemOperationsTestFiller.json30
11 files changed, 666 insertions, 17 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7cedc117..764bf928 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,6 +2,7 @@ cmake_policy(SET CMP0015 NEW)
aux_source_directory(. SRC_LIST)
list(REMOVE_ITEM SRC_LIST "./createRandomTest.cpp")
+list(REMOVE_ITEM SRC_LIST "./checkRandomTest.cpp")
include_directories(${Boost_INCLUDE_DIRS})
include_directories(${CRYPTOPP_INCLUDE_DIRS})
@@ -12,6 +13,7 @@ include_directories(..)
file(GLOB HEADERS "*.h")
add_executable(testeth ${SRC_LIST} ${HEADERS})
add_executable(createRandomTest createRandomTest.cpp vm.cpp TestHelper.cpp)
+add_executable(checkRandomTest checkRandomTest.cpp vm.cpp TestHelper.cpp)
target_link_libraries(testeth ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES})
target_link_libraries(testeth ${CURL_LIBRARIES})
@@ -29,3 +31,7 @@ endif()
target_link_libraries(createRandomTest ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES})
target_link_libraries(createRandomTest ethereum)
target_link_libraries(createRandomTest ethcore)
+target_link_libraries(checkRandomTest ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES})
+target_link_libraries(checkRandomTest ethereum)
+target_link_libraries(checkRandomTest ethcore)
+
diff --git a/SolidityEndToEndTest.cpp b/SolidityEndToEndTest.cpp
index 2afe875f..16787c8e 100644
--- a/SolidityEndToEndTest.cpp
+++ b/SolidityEndToEndTest.cpp
@@ -28,6 +28,10 @@
#include <libdevcrypto/SHA3.h>
#include <test/solidityExecutionFramework.h>
+#ifdef _MSC_VER
+#pragma warning(disable: 4307) //integral constant overflow for high_bits_cleaning
+#endif
+
using namespace std;
namespace dev
@@ -1291,7 +1295,113 @@ BOOST_AUTO_TEST_CASE(contracts_as_addresses)
}
)";
compileAndRun(sourceCode, 20);
- BOOST_REQUIRE(callContractFunction("getBalance()") == toBigEndian(u256(20 - 5)) + toBigEndian(u256(5)));
+ BOOST_REQUIRE(callContractFunction("getBalance()") == encodeArgs(u256(20 - 5), u256(5)));
+}
+
+BOOST_AUTO_TEST_CASE(gas_and_value_basic)
+{
+ char const* sourceCode = R"(
+ contract helper {
+ bool flag;
+ function getBalance() returns (uint256 myBalance) {
+ return this.balance;
+ }
+ function setFlag() { flag = true; }
+ function getFlag() returns (bool fl) { return flag; }
+ }
+ contract test {
+ helper h;
+ function test() { h = new helper(); }
+ function sendAmount(uint amount) returns (uint256 bal) {
+ return h.getBalance.value(amount)();
+ }
+ function outOfGas() returns (bool flagBefore, bool flagAfter, uint myBal) {
+ flagBefore = h.getFlag();
+ h.setFlag.gas(2)(); // should fail due to OOG, return value can be garbage
+ flagAfter = h.getFlag();
+ myBal = this.balance;
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 20);
+ BOOST_REQUIRE(callContractFunction("sendAmount(uint256)", 5) == encodeArgs(5));
+ // call to helper should not succeed but amount should be transferred anyway
+ BOOST_REQUIRE(callContractFunction("outOfGas()", 5) == encodeArgs(false, false, 20 - 5));
+}
+
+BOOST_AUTO_TEST_CASE(value_complex)
+{
+ char const* sourceCode = R"(
+ contract helper {
+ function getBalance() returns (uint256 myBalance) {
+ return this.balance;
+ }
+ }
+ contract test {
+ helper h;
+ function test() { h = new helper(); }
+ function sendAmount(uint amount) returns (uint256 bal) {
+ var x1 = h.getBalance.value(amount);
+ uint someStackElement = 20;
+ var x2 = x1.gas(1000);
+ return x2.value(amount + 3)();// overwrite value
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 20);
+ BOOST_REQUIRE(callContractFunction("sendAmount(uint256)", 5) == encodeArgs(8));
+}
+
+BOOST_AUTO_TEST_CASE(value_insane)
+{
+ char const* sourceCode = R"(
+ contract helper {
+ function getBalance() returns (uint256 myBalance) {
+ return this.balance;
+ }
+ }
+ contract test {
+ helper h;
+ function test() { h = new helper(); }
+ function sendAmount(uint amount) returns (uint256 bal) {
+ var x1 = h.getBalance.value;
+ uint someStackElement = 20;
+ var x2 = x1(amount).gas;
+ var x3 = x2(1000).value;
+ return x3(amount + 3)();// overwrite value
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 20);
+ BOOST_REQUIRE(callContractFunction("sendAmount(uint256)", 5) == encodeArgs(8));
+}
+
+BOOST_AUTO_TEST_CASE(value_for_constructor)
+{
+ 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.value(10)("abc", true);
+ }
+ function getFlag() returns (bool ret) { return h.getFlag(); }
+ function getName() returns (string3 ret) { return h.getName(); }
+ function getBalances() returns (uint me, uint them) { me = this.balance; them = h.balance;}
+ })";
+ compileAndRun(sourceCode, 22, "Main");
+ BOOST_REQUIRE(callContractFunction("getFlag()") == encodeArgs(true));
+ BOOST_REQUIRE(callContractFunction("getName()") == encodeArgs("abc"));
+ BOOST_REQUIRE(callContractFunction("getBalances()") == encodeArgs(12, 10));
}
BOOST_AUTO_TEST_SUITE_END()
diff --git a/SolidityNameAndTypeResolution.cpp b/SolidityNameAndTypeResolution.cpp
index 94271b1f..e2b4f160 100644
--- a/SolidityNameAndTypeResolution.cpp
+++ b/SolidityNameAndTypeResolution.cpp
@@ -357,6 +357,18 @@ BOOST_AUTO_TEST_CASE(function_canonical_signature_type_aliases)
}
}
+
+BOOST_AUTO_TEST_CASE(hash_collision_in_interface)
+{
+ char const* text = "contract test {\n"
+ " function gsf() {\n"
+ " }\n"
+ " function tgeo() {\n"
+ " }\n"
+ "}\n";
+ BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
+}
+
BOOST_AUTO_TEST_SUITE_END()
}
diff --git a/TestHelper.cpp b/TestHelper.cpp
index ff330d60..355a5080 100644
--- a/TestHelper.cpp
+++ b/TestHelper.cpp
@@ -350,6 +350,19 @@ void checkLog(LogEntries _resultLogs, LogEntries _expectedLogs)
}
}
+void checkCallCreates(eth::Transactions _resultCallCreates, eth::Transactions _expectedCallCreates)
+{
+ BOOST_REQUIRE_EQUAL(_resultCallCreates.size(), _expectedCallCreates.size());
+
+ for (size_t i = 0; i < _resultCallCreates.size(); ++i)
+ {
+ BOOST_CHECK(_resultCallCreates[i].data() == _expectedCallCreates[i].data());
+ BOOST_CHECK(_resultCallCreates[i].receiveAddress() == _expectedCallCreates[i].receiveAddress());
+ BOOST_CHECK(_resultCallCreates[i].gas() == _expectedCallCreates[i].gas());
+ BOOST_CHECK(_resultCallCreates[i].value() == _expectedCallCreates[i].value());
+ }
+}
+
std::string getTestPath()
{
string testPath;
diff --git a/TestHelper.h b/TestHelper.h
index 85017c84..2ef5c6d5 100644
--- a/TestHelper.h
+++ b/TestHelper.h
@@ -73,6 +73,8 @@ json_spirit::mArray exportLog(eth::LogEntries _logs);
void checkOutput(bytes const& _output, json_spirit::mObject& _o);
void checkStorage(std::map<u256, u256> _expectedStore, std::map<u256, u256> _resultStore, Address _expectedAddr);
void checkLog(eth::LogEntries _resultLogs, eth::LogEntries _expectedLogs);
+void checkCallCreates(eth::Transactions _resultCallCreates, eth::Transactions _expectedCallCreates);
+
void executeTests(const std::string& _name, const std::string& _testPathAppendix, std::function<void(json_spirit::mValue&, bool)> doTests);
std::string getTestPath();
void userDefinedTest(std::string testTypeFlag, std::function<void(json_spirit::mValue&, bool)> doTests);
diff --git a/boostTest.cpp b/boostTest.cpp
index cef3cc0a..1523a7a1 100644
--- a/boostTest.cpp
+++ b/boostTest.cpp
@@ -23,6 +23,6 @@
#define BOOST_TEST_MODULE EthereumTests
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
+#define BOOST_DISABLE_WIN32 //disables SEH warning
#include <boost/test/included/unit_test.hpp>
-#pragma warning(pop)
#pragma GCC diagnostic pop
diff --git a/checkRandomTest.cpp b/checkRandomTest.cpp
new file mode 100644
index 00000000..e3442d43
--- /dev/null
+++ b/checkRandomTest.cpp
@@ -0,0 +1,297 @@
+/*
+ This file is part of cpp-ethereum.
+
+ cpp-ethereum is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ cpp-ethereum is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
+*/
+/** @file checkRandomTest.cpp
+ * @author Christoph Jentzsch <jentzsch.simulationsoftware@gmail.com>
+ * @date 2015
+ * Check a random test and return 0/1 for success or failure. To be used for efficiency in the random test simulation.
+ */
+
+#include <libdevcore/Common.h>
+#include <libdevcore/Exceptions.h>
+#include <libdevcore/Log.h>
+#include <libevm/VMFactory.h>
+#include "vm.h"
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+
+using namespace std;
+using namespace json_spirit;
+using namespace dev::test;
+using namespace dev;
+
+bool doVMTest(mValue& v);
+
+int main(int argc, char *argv[])
+{
+ g_logVerbosity = 0;
+ bool ret = false;
+
+ try
+ {
+ mValue v;
+ string s;
+ for (int i = 1; i < argc; ++i)
+ s += argv[i];
+ if (asserts(s.length() > 0))
+ {
+ cout << "Content of argument is empty\n";
+ return 1;
+ }
+ read_string(s, v);
+ ret = doVMTest(v);
+ }
+ catch (Exception const& _e)
+ {
+ cout << "Failed test with Exception: " << diagnostic_information(_e) << endl;
+ ret = false;
+ }
+ catch (std::exception const& _e)
+ {
+ cout << "Failed test with Exception: " << _e.what() << endl;
+ ret = false;
+ }
+ return ret;
+}
+
+bool doVMTest(mValue& v)
+{
+ eth::VMFactory::setKind(eth::VMKind::JIT);
+
+ for (auto& i: v.get_obj())
+ {
+ cnote << i.first;
+ mObject& o = i.second.get_obj();
+
+ assert(o.count("env") > 0);
+ assert(o.count("pre") > 0);
+ assert(o.count("exec") > 0);
+
+ FakeExtVM fev;
+ fev.importEnv(o["env"].get_obj());
+ fev.importState(o["pre"].get_obj());
+
+ fev.importExec(o["exec"].get_obj());
+ if (fev.code.empty())
+ {
+ fev.thisTxCode = get<3>(fev.addresses.at(fev.myAddress));
+ fev.code = fev.thisTxCode;
+ }
+
+ bytes output;
+ u256 gas;
+ bool vmExceptionOccured = false;
+ try
+ {
+ auto vm = eth::VMFactory::create(fev.gas);
+ output = vm->go(fev, fev.simpleTrace()).toBytes();
+ gas = vm->gas();
+ }
+ catch (eth::VMException)
+ {
+ cnote << "Safe VM Exception";
+ vmExceptionOccured = true;
+ }
+ catch (Exception const& _e)
+ {
+ cnote << "VM did throw an exception: " << diagnostic_information(_e);
+ cnote << "Failed VM Test with Exception: " << _e.what();
+ return 1;
+ }
+ catch (std::exception const& _e)
+ {
+ cnote << "VM did throw an exception: " << _e.what();
+ cnote << "Failed VM Test with Exception: " << _e.what();
+ return 1;
+ }
+
+ // delete null entries in storage for the sake of comparison
+ for (auto &a: fev.addresses)
+ {
+ vector<u256> keystoDelete;
+ for (auto &s: get<2>(a.second))
+ {
+ if (s.second == 0)
+ keystoDelete.push_back(s.first);
+ }
+ for (auto const key: keystoDelete )
+ {
+ get<2>(a.second).erase(key);
+ }
+ }
+
+ if (o.count("post") > 0) // No exceptions expected
+ {
+ if (asserts(!vmExceptionOccured) || asserts(o.count("post") > 0) || asserts(o.count("callcreates") > 0) || asserts(o.count("out") > 0) || asserts(o.count("gas") > 0) || asserts(o.count("logs") > 0))
+ return 1;
+
+ dev::test::FakeExtVM test;
+ test.importState(o["post"].get_obj());
+ test.importCallCreates(o["callcreates"].get_array());
+ test.sub.logs = importLog(o["logs"].get_array());
+
+ //checkOutput(output, o);
+ int j = 0;
+ if (o["out"].type() == array_type)
+ for (auto const& d: o["out"].get_array())
+ {
+ if (asserts(output[j] == toInt(d)))
+ {
+ cout << "Output byte [" << j << "] different!";
+ return 1;
+ }
+ ++j;
+ }
+ else if (o["out"].get_str().find("0x") == 0)
+ {
+ if (asserts(output == fromHex(o["out"].get_str().substr(2))))
+ return 1;
+ }
+ else
+ {
+ if (asserts(output == fromHex(o["out"].get_str())))
+ return 1;
+ }
+
+ if (asserts(toInt(o["gas"]) == gas))
+ return 1;
+
+ auto& expectedAddrs = test.addresses;
+ auto& resultAddrs = fev.addresses;
+ for (auto&& expectedPair : expectedAddrs)
+ {
+ auto& expectedAddr = expectedPair.first;
+ auto resultAddrIt = resultAddrs.find(expectedAddr);
+ if (resultAddrIt == resultAddrs.end())
+ {
+ cout << "Missing expected address " << expectedAddr;
+ return 1;
+ }
+ else
+ {
+ auto& expectedState = expectedPair.second;
+ auto& resultState = resultAddrIt->second;
+ if (asserts(std::get<0>(expectedState) == std::get<0>(resultState)))
+ {
+ cout << expectedAddr << ": incorrect balance " << std::get<0>(resultState) << ", expected " << std::get<0>(expectedState);
+ return 1;
+ }
+ if (asserts(std::get<1>(expectedState) == std::get<1>(resultState)))
+ {
+ cout << expectedAddr << ": incorrect txCount " << std::get<1>(resultState) << ", expected " << std::get<1>(expectedState);
+ return 1;
+ }
+ if (asserts(std::get<3>(expectedState) == std::get<3>(resultState)))
+ {
+ cout << expectedAddr << ": incorrect code";
+ return 1;
+ }
+
+ //checkStorage(std::get<2>(expectedState), std::get<2>(resultState), expectedAddr);
+ for (auto&& expectedStorePair : std::get<2>(expectedState))
+ {
+ auto& expectedStoreKey = expectedStorePair.first;
+ auto resultStoreIt = std::get<2>(resultState).find(expectedStoreKey);
+ if (resultStoreIt == std::get<2>(resultState).end())
+ {
+ cout << expectedAddr << ": missing store key " << expectedStoreKey << endl;
+ return 1;
+ }
+ else
+ {
+ auto& expectedStoreValue = expectedStorePair.second;
+ auto& resultStoreValue = resultStoreIt->second;
+ if (asserts(expectedStoreValue == resultStoreValue))
+ {
+ cout << expectedAddr << ": store[" << expectedStoreKey << "] = " << resultStoreValue << ", expected " << expectedStoreValue << endl;
+ return 1;
+ }
+ }
+ }
+ if (assertsEqual(std::get<2>(resultState).size(), std::get<2>(expectedState).size()))
+ return 1;
+ for (auto&& resultStorePair: std::get<2>(resultState))
+ {
+ if (!std::get<2>(expectedState).count(resultStorePair.first))
+ {
+ cout << expectedAddr << ": unexpected store key " << resultStorePair.first << endl;
+ return 1;
+ }
+ }
+ }
+ }
+
+ //checkAddresses<std::map<Address, std::tuple<u256, u256, std::map<u256, u256>, bytes> > >(test.addresses, fev.addresses);
+ for (auto& resultPair : fev.addresses)
+ {
+ auto& resultAddr = resultPair.first;
+ auto expectedAddrIt = test.addresses.find(resultAddr);
+ if (expectedAddrIt == test.addresses.end())
+ {
+ cout << "Missing result address " << resultAddr << endl;
+ return 1;
+ }
+ }
+ if (asserts(test.addresses == fev.addresses))
+ return 1;
+
+ if (asserts(test.callcreates == fev.callcreates))
+ return 1;
+
+ //checkCallCreates(fev.callcreates, test.callcreates);
+ {
+ if (assertsEqual(test.callcreates.size(), fev.callcreates.size()))
+ return 1;
+
+ for (size_t i = 0; i < test.callcreates.size(); ++i)
+ {
+ if (asserts(test.callcreates[i].data() == fev.callcreates[i].data()))
+ return 1;
+ if (asserts(test.callcreates[i].receiveAddress() == fev.callcreates[i].receiveAddress()))
+ return 1;
+ if (asserts(test.callcreates[i].gas() == fev.callcreates[i].gas()))
+ return 1;
+ if (asserts(test.callcreates[i].value() == fev.callcreates[i].value()))
+ return 1;
+ }
+ }
+
+ //checkLog(fev.sub.logs, test.sub.logs);
+ {
+ if (assertsEqual(fev.sub.logs.size(), test.sub.logs.size()))
+ return 1;
+
+ for (size_t i = 0; i < fev.sub.logs.size(); ++i)
+ {
+ if (assertsEqual(fev.sub.logs[i].address, test.sub.logs[i].address))
+ return 1;
+ if (assertsEqual(fev.sub.logs[i].topics, test.sub.logs[i].topics))
+ return 1;
+ if (asserts(fev.sub.logs[i].data == test.sub.logs[i].data))
+ return 1;
+ }
+ }
+
+ }
+ else // Exception expected
+ {
+ if (asserts(vmExceptionOccured))
+ return 1;
+ }
+ }
+ // test passed
+ return 0;
+}
+
diff --git a/createRandomTest.cpp b/createRandomTest.cpp
index 1af12f64..fa5ed7bd 100644
--- a/createRandomTest.cpp
+++ b/createRandomTest.cpp
@@ -54,18 +54,26 @@ int main(int argc, char *argv[])
gen.seed(static_cast<unsigned int>(timeSinceEpoch));
boost::random::uniform_int_distribution<> lengthOfCodeDist(2, 16);
boost::random::uniform_int_distribution<> opcodeDist(0, 255);
+ boost::random::uniform_int_distribution<> BlockInfoOpcodeDist(0x40, 0x45);
boost::random::variate_generator<boost::mt19937&,
boost::random::uniform_int_distribution<> > randGen(gen, opcodeDist);
+ boost::random::variate_generator<boost::mt19937&,
+ boost::random::uniform_int_distribution<> > randGenBlockInfoOpcode(gen, BlockInfoOpcodeDist);
int lengthOfCode = lengthOfCodeDist(gen);
string randomCode;
for (int i = 0; i < lengthOfCode; ++i)
{
- uint8_t opcode = randGen();
+ if (i < 8 && (randGen() < 192))
+ {
+ randomCode += toHex(toCompactBigEndian((uint8_t)randGenBlockInfoOpcode()));
+ continue;
+ }
- // disregard all invalid commands, except of one (0x10)
- if (dev::eth::isValidInstruction(dev::eth::Instruction(opcode)) || opcode == 0x10)
+ uint8_t opcode = randGen();
+ // disregard all invalid commands, except of one (0x0c)
+ if ((dev::eth::isValidInstruction(dev::eth::Instruction(opcode)) || (randGen() > 250)))
randomCode += toHex(toCompactBigEndian(opcode));
else
i--;
@@ -76,10 +84,10 @@ int main(int argc, char *argv[])
\"randomVMtest\": {\n\
\"env\" : {\n\
\"previousHash\" : \"5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6\",\n\
- \"currentNumber\" : \"0\",\n\
+ \"currentNumber\" : \"300\",\n\
\"currentGasLimit\" : \"1000000\",\n\
- \"currentDifficulty\" : \"256\",\n\
- \"currentTimestamp\" : 1,\n\
+ \"currentDifficulty\" : \"115792089237316195423570985008687907853269984665640564039457584007913129639935\",\n\
+ \"currentTimestamp\" : 2,\n\
\"currentCoinbase\" : \"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba\"\n\
},\n\
\"pre\" : {\n\
@@ -106,7 +114,7 @@ int main(int argc, char *argv[])
read_string(s, v);
// insert new random code
- v.get_obj().find("randomVMtest")->second.get_obj().find("pre")->second.get_obj().begin()->second.get_obj()["code"] = "0x" + randomCode;
+ v.get_obj().find("randomVMtest")->second.get_obj().find("pre")->second.get_obj().begin()->second.get_obj()["code"] = "0x" + randomCode + (randGen() > 128 ? "55" : "");
// execute code in vm
doMyTests(v);
@@ -119,6 +127,8 @@ int main(int argc, char *argv[])
void doMyTests(json_spirit::mValue& v)
{
+ eth::VMFactory::setKind(eth::VMKind::Interpreter);
+
for (auto& i: v.get_obj())
{
cnote << i.first;
diff --git a/vm.cpp b/vm.cpp
index 6ae95f25..7afd9de1 100644
--- a/vm.cpp
+++ b/vm.cpp
@@ -232,13 +232,13 @@ void FakeExtVM::importCallCreates(mArray& _callcreates)
for (mValue& v: _callcreates)
{
auto tx = v.get_obj();
- BOOST_REQUIRE(tx.count("data") > 0);
- BOOST_REQUIRE(tx.count("value") > 0);
- BOOST_REQUIRE(tx.count("destination") > 0);
- BOOST_REQUIRE(tx.count("gasLimit") > 0);
+ assert(tx.count("data") > 0);
+ assert(tx.count("value") > 0);
+ assert(tx.count("destination") > 0);
+ assert(tx.count("gasLimit") > 0);
Transaction t = tx["destination"].get_str().empty() ?
- Transaction(toInt(tx["value"]), 0, toInt(tx["gasLimit"]), data.toBytes()) :
- Transaction(toInt(tx["value"]), 0, toInt(tx["gasLimit"]), Address(tx["destination"].get_str()), data.toBytes());
+ Transaction(toInt(tx["value"]), 0, toInt(tx["gasLimit"]), fromHex(tx["data"].get_str())) :
+ Transaction(toInt(tx["value"]), 0, toInt(tx["gasLimit"]), Address(tx["destination"].get_str()), fromHex(tx["data"].get_str()));
callcreates.push_back(t);
}
}
@@ -345,7 +345,7 @@ void doVMTests(json_spirit::mValue& v, bool _fillin)
output = vm->go(fev, fev.simpleTrace()).toBytes();
gas = vm->gas();
}
- catch (VMException const& _e)
+ catch (VMException const&)
{
cnote << "Safe VM Exception";
vmExceptionOccured = true;
@@ -448,7 +448,8 @@ void doVMTests(json_spirit::mValue& v, bool _fillin)
}
checkAddresses<std::map<Address, std::tuple<u256, u256, std::map<u256, u256>, bytes> > >(test.addresses, fev.addresses);
- BOOST_CHECK(test.callcreates == fev.callcreates);
+
+ checkCallCreates(fev.callcreates, test.callcreates);
checkLog(fev.sub.logs, test.sub.logs);
}
diff --git a/vmArithmeticTestFiller.json b/vmArithmeticTestFiller.json
index 12574f51..9e8b3f61 100644
--- a/vmArithmeticTestFiller.json
+++ b/vmArithmeticTestFiller.json
@@ -1346,6 +1346,90 @@
}
},
+ "addmodDivByZero": {
+ "env" : {
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
+ "currentNumber" : "0",
+ "currentGasLimit" : "1000000",
+ "currentDifficulty" : "256",
+ "currentTimestamp" : 1,
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
+ },
+ "pre" : {
+ "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
+ "balance" : "1000000000000000000",
+ "nonce" : 0,
+ "code" : "{ [[ 0 ]] (ADDMOD 4 1 0) } ",
+ "storage": {}
+ }
+ },
+ "exec" : {
+ "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
+ "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681",
+ "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681",
+ "value" : "1000000000000000000",
+ "data" : "",
+ "gasPrice" : "100000000000000",
+ "gas" : "10000"
+ }
+ },
+
+ "addmodDivByZero1": {
+ "env" : {
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
+ "currentNumber" : "0",
+ "currentGasLimit" : "1000000",
+ "currentDifficulty" : "256",
+ "currentTimestamp" : 1,
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
+ },
+ "pre" : {
+ "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
+ "balance" : "1000000000000000000",
+ "nonce" : 0,
+ "code" : "{ [[ 0 ]] (ADDMOD 0 1 0) } ",
+ "storage": {}
+ }
+ },
+ "exec" : {
+ "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
+ "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681",
+ "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681",
+ "value" : "1000000000000000000",
+ "data" : "",
+ "gasPrice" : "100000000000000",
+ "gas" : "10000"
+ }
+ },
+
+ "addmodDivByZero1": {
+ "env" : {
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
+ "currentNumber" : "0",
+ "currentGasLimit" : "1000000",
+ "currentDifficulty" : "256",
+ "currentTimestamp" : 1,
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
+ },
+ "pre" : {
+ "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
+ "balance" : "1000000000000000000",
+ "nonce" : 0,
+ "code" : "{ [[ 0 ]] (ADDMOD 1 0 0) } ",
+ "storage": {}
+ }
+ },
+ "exec" : {
+ "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
+ "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681",
+ "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681",
+ "value" : "1000000000000000000",
+ "data" : "",
+ "gasPrice" : "100000000000000",
+ "gas" : "10000"
+ }
+ },
+
"mulmod0": {
"env" : {
@@ -1543,6 +1627,90 @@
}
},
+ "mulmoddivByZero": {
+ "env" : {
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
+ "currentNumber" : "0",
+ "currentGasLimit" : "1000000",
+ "currentDifficulty" : "256",
+ "currentTimestamp" : 1,
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
+ },
+ "pre" : {
+ "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
+ "balance" : "1000000000000000000",
+ "nonce" : 0,
+ "code" : "{ [[ 0 ]] (MULMOD 5 1 0) } ",
+ "storage": {}
+ }
+ },
+ "exec" : {
+ "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
+ "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681",
+ "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681",
+ "value" : "1000000000000000000",
+ "data" : "",
+ "gasPrice" : "100000000000000",
+ "gas" : "10000"
+ }
+ },
+
+ "mulmoddivByZero1": {
+ "env" : {
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
+ "currentNumber" : "0",
+ "currentGasLimit" : "1000000",
+ "currentDifficulty" : "256",
+ "currentTimestamp" : 1,
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
+ },
+ "pre" : {
+ "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
+ "balance" : "1000000000000000000",
+ "nonce" : 0,
+ "code" : "{ [[ 0 ]] (MULMOD 0 1 0) } ",
+ "storage": {}
+ }
+ },
+ "exec" : {
+ "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
+ "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681",
+ "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681",
+ "value" : "1000000000000000000",
+ "data" : "",
+ "gasPrice" : "100000000000000",
+ "gas" : "10000"
+ }
+ },
+
+ "mulmoddivByZero2": {
+ "env" : {
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
+ "currentNumber" : "0",
+ "currentGasLimit" : "1000000",
+ "currentDifficulty" : "256",
+ "currentTimestamp" : 1,
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
+ },
+ "pre" : {
+ "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
+ "balance" : "1000000000000000000",
+ "nonce" : 0,
+ "code" : "{ [[ 0 ]] (MULMOD 1 0 0) } ",
+ "storage": {}
+ }
+ },
+ "exec" : {
+ "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
+ "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681",
+ "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681",
+ "value" : "1000000000000000000",
+ "data" : "",
+ "gasPrice" : "100000000000000",
+ "gas" : "10000"
+ }
+ },
+
"exp0": {
"env" : {
diff --git a/vmSystemOperationsTestFiller.json b/vmSystemOperationsTestFiller.json
index 1df2697e..a5cd7903 100644
--- a/vmSystemOperationsTestFiller.json
+++ b/vmSystemOperationsTestFiller.json
@@ -147,6 +147,36 @@
}
},
+ "CallToPrecompiledContract" : {
+ "env" : {
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
+ "currentDifficulty" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
+ "currentGasLimit" : "1000000",
+ "currentNumber" : "0",
+ "currentTimestamp" : "2",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "exec" : {
+ "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
+ "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
+ "code" : "0x4243434242434243f14555",
+ "data" : "0x",
+ "gas" : "10000",
+ "gasPrice" : "100000000000000",
+ "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
+ "value" : "1000000000000000000"
+ },
+ "pre" : {
+ "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x4243434242434243f14555",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ }
+ },
+
"CallToReturn1": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",