From cf5f86e384889e21ff6af17ae9dbb222bb047787 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Thu, 12 Mar 2015 09:16:32 +0100 Subject: [PATCH 01/33] create random state tests --- CMakeLists.txt | 5 + TestHelper.cpp | 32 +++---- createRandomStateTest.cpp | 186 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 207 insertions(+), 16 deletions(-) create mode 100644 createRandomStateTest.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 292f62a03..83f61c769 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 "./createRandomStateTest.cpp") list(REMOVE_ITEM SRC_LIST "./checkRandomTest.cpp") if (NOT JSONRPC) @@ -18,6 +19,7 @@ include_directories(${JSON_RPC_CPP_INCLUDE_DIRS}) file(GLOB HEADERS "*.h") add_executable(testeth ${SRC_LIST} ${HEADERS}) add_executable(createRandomTest createRandomTest.cpp vm.cpp TestHelper.cpp) +add_executable(createRandomStateTest createRandomStateTest.cpp state.cpp TestHelper.cpp) add_executable(checkRandomTest checkRandomTest.cpp vm.cpp TestHelper.cpp) target_link_libraries(testeth ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES}) @@ -38,6 +40,9 @@ endif() target_link_libraries(createRandomTest ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES}) target_link_libraries(createRandomTest ethereum) target_link_libraries(createRandomTest ethcore) +target_link_libraries(createRandomStateTest ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES}) +target_link_libraries(createRandomStateTest ethereum) +target_link_libraries(createRandomStateTest ethcore) target_link_libraries(checkRandomTest ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES}) target_link_libraries(checkRandomTest ethereum) target_link_libraries(checkRandomTest ethcore) diff --git a/TestHelper.cpp b/TestHelper.cpp index 9ac64107d..4d5563415 100644 --- a/TestHelper.cpp +++ b/TestHelper.cpp @@ -84,12 +84,12 @@ ImportTest::ImportTest(json_spirit::mObject& _o, bool isFiller) : m_statePre(Add void ImportTest::importEnv(json_spirit::mObject& _o) { - BOOST_REQUIRE(_o.count("previousHash") > 0); - BOOST_REQUIRE(_o.count("currentGasLimit") > 0); - BOOST_REQUIRE(_o.count("currentDifficulty") > 0); - BOOST_REQUIRE(_o.count("currentTimestamp") > 0); - BOOST_REQUIRE(_o.count("currentCoinbase") > 0); - BOOST_REQUIRE(_o.count("currentNumber") > 0); + assert(_o.count("previousHash") > 0); + assert(_o.count("currentGasLimit") > 0); + assert(_o.count("currentDifficulty") > 0); + assert(_o.count("currentTimestamp") > 0); + assert(_o.count("currentCoinbase") > 0); + assert(_o.count("currentNumber") > 0); m_environment.previousBlock.hash = h256(_o["previousHash"].get_str()); m_environment.currentBlock.number = toInt(_o["currentNumber"]); @@ -108,10 +108,10 @@ void ImportTest::importState(json_spirit::mObject& _o, State& _state) { json_spirit::mObject o = i.second.get_obj(); - BOOST_REQUIRE(o.count("balance") > 0); - BOOST_REQUIRE(o.count("nonce") > 0); - BOOST_REQUIRE(o.count("storage") > 0); - BOOST_REQUIRE(o.count("code") > 0); + assert(o.count("balance") > 0); + assert(o.count("nonce") > 0); + assert(o.count("storage") > 0); + assert(o.count("code") > 0); if (bigint(o["balance"].get_str()) >= c_max256plus1) BOOST_THROW_EXCEPTION(ValueTooLarge() << errinfo_comment("State 'balance' is equal or greater than 2**256") ); @@ -144,12 +144,12 @@ void ImportTest::importTransaction(json_spirit::mObject& _o) { if (_o.count("secretKey") > 0) { - BOOST_REQUIRE(_o.count("nonce") > 0); - BOOST_REQUIRE(_o.count("gasPrice") > 0); - BOOST_REQUIRE(_o.count("gasLimit") > 0); - BOOST_REQUIRE(_o.count("to") > 0); - BOOST_REQUIRE(_o.count("value") > 0); - BOOST_REQUIRE(_o.count("data") > 0); + assert(_o.count("nonce") > 0); + assert(_o.count("gasPrice") > 0); + assert(_o.count("gasLimit") > 0); + assert(_o.count("to") > 0); + assert(_o.count("value") > 0); + assert(_o.count("data") > 0); if (bigint(_o["nonce"].get_str()) >= c_max256plus1) BOOST_THROW_EXCEPTION(ValueTooLarge() << errinfo_comment("Transaction 'nonce' is equal or greater than 2**256") ); diff --git a/createRandomStateTest.cpp b/createRandomStateTest.cpp new file mode 100644 index 000000000..2743ad191 --- /dev/null +++ b/createRandomStateTest.cpp @@ -0,0 +1,186 @@ +/* + 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 . +*/ +/** @file createRandomStateTest.cpp + * @author Christoph Jentzsch + * @date 2015 + * Creating a random state test. + */ + +#include +#include +#include + +#include +#include + +#pragma GCC diagnostic ignored "-Wunused-parameter" +#include +#include +#include +#include +#include +#include +#include +#include "TestHelper.h" +#include "vm.h" + +using namespace std; +using namespace json_spirit; +using namespace dev; + +void doStateTests(json_spirit::mValue& _v); + +int main(int argc, char *argv[]) +{ + g_logVerbosity = 0; + + // create random code + + boost::random::mt19937 gen; + + auto now = chrono::steady_clock::now().time_since_epoch(); + auto timeSinceEpoch = chrono::duration_cast(now).count(); + gen.seed(static_cast(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 > randGen(gen, opcodeDist); + boost::random::variate_generator > randGenBlockInfoOpcode(gen, BlockInfoOpcodeDist); + + int lengthOfCode = lengthOfCodeDist(gen); + string randomCode; + + for (int i = 0; i < lengthOfCode; ++i) + { + if (i < 8 && (randGen() < 192)) + { + randomCode += toHex(toCompactBigEndian((uint8_t)randGenBlockInfoOpcode())); + continue; + } + + 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--; + } + + string const s = R"( + { + "randomStatetest" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "256", + "currentGasLimit" : "1000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "pre" : { + "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { + "balance" : "1000000000000000000", + "code" : "0x6001600101600055", + "nonce" : "0", + "storage" : { + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "1000000000000000000", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : { + "data" : "", + "gasLimit" : "400000", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "100000" + } + } + } +)"; + + + cout << "the test: " << s << endl; + + mValue v; + read_string(s, v); + + // insert new random code + v.get_obj().find("randomStatetest")->second.get_obj().find("pre")->second.get_obj().begin()->second.get_obj()["code"] = "0x" + randomCode + (randGen() > 128 ? "55" : ""); + + // fill test + doStateTests(v); + + // stream to output for further handling by the bash script + cout << json_spirit::write_string(v, true); + + return 0; +} + +void doStateTests(json_spirit::mValue& _v) +{ + try{ + for (auto& i: _v.get_obj()) + { + cerr << i.first << endl; + mObject& o = i.second.get_obj(); + + assert(o.count("env") > 0); + assert(o.count("pre") > 0); + assert(o.count("transaction") > 0); + + test::ImportTest importer(o, true); + + eth::State theState = importer.m_statePre; + bytes tx = importer.m_transaction.rlp(); + bytes output; + + try + { + theState.execute(test::lastHashes(importer.m_environment.currentBlock.number), tx, &output); + } + catch (Exception const& _e) + { + cnote << "state execution did throw an exception: " << diagnostic_information(_e); + theState.commit(); + } + catch (std::exception const& _e) + { + cnote << "state execution did throw an exception: " << _e.what(); + } +#if ETH_FATDB + importer.exportTest(output, theState); +#else + BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("You can not fill tests when FATDB is switched off")); +#endif + } + } + catch (Exception const& _e) + { + cout << "problem: " << diagnostic_information(_e); + } +} + From 437e5c222b70f1971d3f8183caa623bc1b4e92d9 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Thu, 12 Mar 2015 11:01:06 +0100 Subject: [PATCH 02/33] add check random state test for jit --- CMakeLists.txt | 25 +- checkRandomStateTest.cpp | 219 ++++++++++++++++++ checkRandomTest.cpp => checkRandomVMTest.cpp | 0 createRandomStateTest.cpp | 150 ++++++------ ...teRandomTest.cpp => createRandomVMTest.cpp | 0 state.cpp | 33 +++ 6 files changed, 338 insertions(+), 89 deletions(-) create mode 100644 checkRandomStateTest.cpp rename checkRandomTest.cpp => checkRandomVMTest.cpp (100%) rename createRandomTest.cpp => createRandomVMTest.cpp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 83f61c769..45f83e5e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,10 @@ cmake_policy(SET CMP0015 NEW) aux_source_directory(. SRC_LIST) -list(REMOVE_ITEM SRC_LIST "./createRandomTest.cpp") +list(REMOVE_ITEM SRC_LIST "./createRandomVMTest.cpp") list(REMOVE_ITEM SRC_LIST "./createRandomStateTest.cpp") -list(REMOVE_ITEM SRC_LIST "./checkRandomTest.cpp") +list(REMOVE_ITEM SRC_LIST "./checkRandomVMTest.cpp") +list(REMOVE_ITEM SRC_LIST "./checkRandomStateTest.cpp") if (NOT JSONRPC) list(REMOVE_ITEM SRC_LIST "./AccountHolder.cpp") @@ -18,9 +19,10 @@ include_directories(${JSON_RPC_CPP_INCLUDE_DIRS}) file(GLOB HEADERS "*.h") add_executable(testeth ${SRC_LIST} ${HEADERS}) -add_executable(createRandomTest createRandomTest.cpp vm.cpp TestHelper.cpp) +add_executable(createRandomVMTest createRandomVMTest.cpp vm.cpp TestHelper.cpp) add_executable(createRandomStateTest createRandomStateTest.cpp state.cpp TestHelper.cpp) -add_executable(checkRandomTest checkRandomTest.cpp vm.cpp TestHelper.cpp) +add_executable(checkRandomVMTest checkRandomVMTest.cpp vm.cpp TestHelper.cpp) +add_executable(checkRandomStateTest checkRandomStateTest.cpp state.cpp TestHelper.cpp) target_link_libraries(testeth ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES}) target_link_libraries(testeth ${CURL_LIBRARIES}) @@ -37,13 +39,16 @@ if (JSONRPC) target_link_libraries(testeth ${JSON_RPC_CPP_CLIENT_LIBRARIES}) endif() -target_link_libraries(createRandomTest ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES}) -target_link_libraries(createRandomTest ethereum) -target_link_libraries(createRandomTest ethcore) +target_link_libraries(createRandomVMTest ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES}) +target_link_libraries(createRandomVMTest ethereum) +target_link_libraries(createRandomVMTest ethcore) target_link_libraries(createRandomStateTest ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES}) target_link_libraries(createRandomStateTest ethereum) target_link_libraries(createRandomStateTest ethcore) -target_link_libraries(checkRandomTest ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES}) -target_link_libraries(checkRandomTest ethereum) -target_link_libraries(checkRandomTest ethcore) +target_link_libraries(checkRandomVMTest ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES}) +target_link_libraries(checkRandomVMTest ethereum) +target_link_libraries(checkRandomVMTest ethcore) +target_link_libraries(checkRandomStateTest ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES}) +target_link_libraries(checkRandomStateTest ethereum) +target_link_libraries(checkRandomStateTest ethcore) diff --git a/checkRandomStateTest.cpp b/checkRandomStateTest.cpp new file mode 100644 index 000000000..29ccc2eb0 --- /dev/null +++ b/checkRandomStateTest.cpp @@ -0,0 +1,219 @@ +/* + 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 . +*/ +/** @file checkRandomTest.cpp + * @author Christoph Jentzsch + * @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 +#include +#include +#include +#include "TestHelper.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 doStateTest(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 = doStateTest(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 doStateTest(mValue& v) +{ + eth::VMFactory::setKind(eth::VMKind::JIT); + + for (auto& i: v.get_obj()) + { + //cerr << i.first << endl; + mObject& o = i.second.get_obj(); + + assert(o.count("env") > 0); + assert(o.count("pre") > 0); + assert(o.count("transaction") > 0); + + ImportTest importer(o, false); + + eth::State theState = importer.m_statePre; + bytes tx = importer.m_transaction.rlp(); + bytes output; + + try + { + theState.execute(lastHashes(importer.m_environment.currentBlock.number), tx, &output); + } + catch (Exception const& _e) + { + cnote << "state execution did throw an exception: " << diagnostic_information(_e); + theState.commit(); + } + catch (std::exception const& _e) + { + cnote << "state execution did throw an exception: " << _e.what(); + } + + assert(o.count("post") > 0); + assert(o.count("out") > 0); + + + //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; + } + + + // check logs + //checkLog(theState.pending().size() ? theState.log(0) : LogEntries(), importer.m_environment.sub.logs); + eth::LogEntries logs = theState.pending().size() ? theState.log(0) : eth::LogEntries(); + + //checkLog(logs, importer.m_environment.sub.logs); + { + if (assertsEqual(logs.size(), importer.m_environment.sub.logs.size())) + return 1; + + for (size_t i = 0; i < logs.size(); ++i) + { + if (assertsEqual(logs[i].address, importer.m_environment.sub.logs[i].address)) + return 1; + if (assertsEqual(logs[i].topics, importer.m_environment.sub.logs[i].topics)) + return 1; + if (asserts(logs[i].data == importer.m_environment.sub.logs[i].data)) + return 1; + } + } + + // check addresses +#if ETH_FATDB + auto expectedAddrs = importer.m_statePost.addresses(); + auto resultAddrs = theState.addresses(); + for (auto& expectedPair : expectedAddrs) + { + auto& expectedAddr = expectedPair.first; + auto resultAddrIt = resultAddrs.find(expectedAddr); + if (resultAddrIt == resultAddrs.end()) + BOOST_ERROR("Missing expected address " << expectedAddr); + else + { + BOOST_CHECK_MESSAGE(importer.m_statePost.balance(expectedAddr) == theState.balance(expectedAddr), expectedAddr << ": incorrect balance " << theState.balance(expectedAddr) << ", expected " << importer.m_statePost.balance(expectedAddr)); + BOOST_CHECK_MESSAGE(importer.m_statePost.transactionsFrom(expectedAddr) == theState.transactionsFrom(expectedAddr), expectedAddr << ": incorrect txCount " << theState.transactionsFrom(expectedAddr) << ", expected " << importer.m_statePost.transactionsFrom(expectedAddr)); + BOOST_CHECK_MESSAGE(importer.m_statePost.code(expectedAddr) == theState.code(expectedAddr), expectedAddr << ": incorrect code"); + + //checkStorage(importer.m_statePost.storage(expectedAddr), theState.storage(expectedAddr), expectedAddr); + + map _resultStore = theState.storage(expectedAddr); + + for (auto&& expectedStorePair : importer.m_statePost.storage(expectedAddr)) + { + auto& expectedStoreKey = expectedStorePair.first; + auto resultStoreIt = _resultStore.find(expectedStoreKey); + if (resultStoreIt == _resultStore.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(_resultStore.size(), importer.m_statePost.storage(expectedAddr).size())) + return 1; + for (auto&& resultStorePair: _resultStore) + { + if (!importer.m_statePost.storage(expectedAddr).count(resultStorePair.first)) + { + cout << expectedAddr << ": unexpected store key " << resultStorePair.first << endl; + return 1; + } + } + } + } + //checkAddresses >(expectedAddrs, resultAddrs); + for (auto& resultPair : resultAddrs) + { + auto& resultAddr = resultPair.first; + auto expectedAddrIt = expectedAddrs.find(resultAddr); + if (expectedAddrIt == expectedAddrs.end()) + return 1; + } + if(expectedAddrs != resultAddrs) + return 1; + +#endif + if(theState.rootHash() != h256(o["postStateRoot"].get_str()), "wrong post state root") + return 1; + } + return 0; +} diff --git a/checkRandomTest.cpp b/checkRandomVMTest.cpp similarity index 100% rename from checkRandomTest.cpp rename to checkRandomVMTest.cpp diff --git a/createRandomStateTest.cpp b/createRandomStateTest.cpp index 2743ad191..06a332e0e 100644 --- a/createRandomStateTest.cpp +++ b/createRandomStateTest.cpp @@ -82,57 +82,53 @@ int main(int argc, char *argv[]) i--; } - string const s = R"( - { - "randomStatetest" : { - "env" : { - "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", - "currentDifficulty" : "256", - "currentGasLimit" : "1000000", - "currentNumber" : "0", - "currentTimestamp" : 1, - "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" - }, - "pre" : { - "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { - "balance" : "1000000000000000000", - "code" : "0x6001600101600055", - "nonce" : "0", - "storage" : { - } - }, - "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "1000000000000000000", - "code" : "0x", - "nonce" : "0", - "storage" : { - } - } - }, - "transaction" : { - "data" : "", - "gasLimit" : "400000", - "gasPrice" : "1", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "100000" - } - } - } + string const s = R"( + { + "randomStatetest" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "256", + "currentGasLimit" : "1000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "pre" : { + "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { + "balance" : "1000000000000000000", + "code" : "0x6001600101600055", + "nonce" : "0", + "storage" : { + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "1000000000000000000", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : { + "data" : "", + "gasLimit" : "400000", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "100000" + } + } + } )"; - - - cout << "the test: " << s << endl; - - mValue v; + mValue v; read_string(s, v); // insert new random code - v.get_obj().find("randomStatetest")->second.get_obj().find("pre")->second.get_obj().begin()->second.get_obj()["code"] = "0x" + randomCode + (randGen() > 128 ? "55" : ""); + v.get_obj().find("randomStatetest")->second.get_obj().find("pre")->second.get_obj().begin()->second.get_obj()["code"] = "0x" + randomCode + (randGen() > 128 ? "55" : ""); - // fill test - doStateTests(v); + // fill test + doStateTests(v); // stream to output for further handling by the bash script cout << json_spirit::write_string(v, true); @@ -142,45 +138,41 @@ int main(int argc, char *argv[]) void doStateTests(json_spirit::mValue& _v) { - try{ - for (auto& i: _v.get_obj()) - { - cerr << i.first << endl; - mObject& o = i.second.get_obj(); + eth::VMFactory::setKind(eth::VMKind::Interpreter); - assert(o.count("env") > 0); - assert(o.count("pre") > 0); - assert(o.count("transaction") > 0); + for (auto& i: _v.get_obj()) + { + //cerr << i.first << endl; + mObject& o = i.second.get_obj(); - test::ImportTest importer(o, true); + assert(o.count("env") > 0); + assert(o.count("pre") > 0); + assert(o.count("transaction") > 0); - eth::State theState = importer.m_statePre; - bytes tx = importer.m_transaction.rlp(); - bytes output; + test::ImportTest importer(o, true); - try - { - theState.execute(test::lastHashes(importer.m_environment.currentBlock.number), tx, &output); - } - catch (Exception const& _e) - { - cnote << "state execution did throw an exception: " << diagnostic_information(_e); - theState.commit(); - } - catch (std::exception const& _e) - { - cnote << "state execution did throw an exception: " << _e.what(); - } + eth::State theState = importer.m_statePre; + bytes tx = importer.m_transaction.rlp(); + bytes output; + + try + { + theState.execute(test::lastHashes(importer.m_environment.currentBlock.number), tx, &output); + } + catch (Exception const& _e) + { + cnote << "state execution did throw an exception: " << diagnostic_information(_e); + theState.commit(); + } + catch (std::exception const& _e) + { + cnote << "state execution did throw an exception: " << _e.what(); + } #if ETH_FATDB - importer.exportTest(output, theState); + importer.exportTest(output, theState); #else - BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("You can not fill tests when FATDB is switched off")); + cout << "You can not fill tests when FATDB is switched off"; #endif - } - } - catch (Exception const& _e) - { - cout << "problem: " << diagnostic_information(_e); - } + } } diff --git a/createRandomTest.cpp b/createRandomVMTest.cpp similarity index 100% rename from createRandomTest.cpp rename to createRandomVMTest.cpp diff --git a/state.cpp b/state.cpp index 5202aff22..1c8f4301a 100644 --- a/state.cpp +++ b/state.cpp @@ -251,6 +251,39 @@ BOOST_AUTO_TEST_CASE(stCreateTest) } } +BOOST_AUTO_TEST_CASE(stRandom) +{ + string testPath = dev::test::getTestPath(); + testPath += "/StateTests/RandomTests"; + + vector testFiles; + boost::filesystem::directory_iterator iterator(testPath); + for(; iterator != boost::filesystem::directory_iterator(); ++iterator) + if (boost::filesystem::is_regular_file(iterator->path()) && iterator->path().extension() == ".json") + testFiles.push_back(iterator->path()); + + for (auto& path: testFiles) + { + try + { + cnote << "Testing ..." << path.filename(); + json_spirit::mValue v; + string s = asString(dev::contents(path.string())); + BOOST_REQUIRE_MESSAGE(s.length() > 0, "Content of " + path.string() + " is empty. Have you cloned the 'tests' repo branch develop and set ETHEREUM_TEST_PATH to its path?"); + json_spirit::read_string(s, v); + dev::test::doStateTests(v, false); + } + catch (Exception const& _e) + { + BOOST_ERROR("Failed test with Exception: " << diagnostic_information(_e)); + } + catch (std::exception const& _e) + { + BOOST_ERROR("Failed test with Exception: " << _e.what()); + } + } +} + BOOST_AUTO_TEST_CASE(userDefinedFileState) { dev::test::userDefinedTest("--singletest", dev::test::doStateTests); From 059c1bb49b093656cdadc013d4109d795a5f9de9 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Thu, 12 Mar 2015 11:36:46 +0100 Subject: [PATCH 03/33] remove boost test lib macros from check random state test --- checkRandomStateTest.cpp | 44 +++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/checkRandomStateTest.cpp b/checkRandomStateTest.cpp index 29ccc2eb0..90a88d57e 100644 --- a/checkRandomStateTest.cpp +++ b/checkRandomStateTest.cpp @@ -73,7 +73,6 @@ bool doStateTest(mValue& v) for (auto& i: v.get_obj()) { - //cerr << i.first << endl; mObject& o = i.second.get_obj(); assert(o.count("env") > 0); @@ -103,7 +102,6 @@ bool doStateTest(mValue& v) assert(o.count("post") > 0); assert(o.count("out") > 0); - //checkOutput(output, o); int j = 0; if (o["out"].type() == array_type) @@ -132,20 +130,17 @@ bool doStateTest(mValue& v) //checkLog(theState.pending().size() ? theState.log(0) : LogEntries(), importer.m_environment.sub.logs); eth::LogEntries logs = theState.pending().size() ? theState.log(0) : eth::LogEntries(); - //checkLog(logs, importer.m_environment.sub.logs); - { - if (assertsEqual(logs.size(), importer.m_environment.sub.logs.size())) - return 1; + if (assertsEqual(logs.size(), importer.m_environment.sub.logs.size())) + return 1; - for (size_t i = 0; i < logs.size(); ++i) - { - if (assertsEqual(logs[i].address, importer.m_environment.sub.logs[i].address)) - return 1; - if (assertsEqual(logs[i].topics, importer.m_environment.sub.logs[i].topics)) - return 1; - if (asserts(logs[i].data == importer.m_environment.sub.logs[i].data)) - return 1; - } + for (size_t i = 0; i < logs.size(); ++i) + { + if (assertsEqual(logs[i].address, importer.m_environment.sub.logs[i].address)) + return 1; + if (assertsEqual(logs[i].topics, importer.m_environment.sub.logs[i].topics)) + return 1; + if (asserts(logs[i].data == importer.m_environment.sub.logs[i].data)) + return 1; } // check addresses @@ -160,12 +155,23 @@ bool doStateTest(mValue& v) BOOST_ERROR("Missing expected address " << expectedAddr); else { - BOOST_CHECK_MESSAGE(importer.m_statePost.balance(expectedAddr) == theState.balance(expectedAddr), expectedAddr << ": incorrect balance " << theState.balance(expectedAddr) << ", expected " << importer.m_statePost.balance(expectedAddr)); - BOOST_CHECK_MESSAGE(importer.m_statePost.transactionsFrom(expectedAddr) == theState.transactionsFrom(expectedAddr), expectedAddr << ": incorrect txCount " << theState.transactionsFrom(expectedAddr) << ", expected " << importer.m_statePost.transactionsFrom(expectedAddr)); - BOOST_CHECK_MESSAGE(importer.m_statePost.code(expectedAddr) == theState.code(expectedAddr), expectedAddr << ": incorrect code"); + if (importer.m_statePost.balance(expectedAddr) != theState.balance(expectedAddr)) + { + cout << expectedAddr << ": incorrect balance " << theState.balance(expectedAddr) << ", expected " << importer.m_statePost.balance(expectedAddr); + return 1; + } + if (importer.m_statePost.transactionsFrom(expectedAddr) != theState.transactionsFrom(expectedAddr)) + { + cout << expectedAddr << ": incorrect txCount " << theState.transactionsFrom(expectedAddr) << ", expected " << importer.m_statePost.transactionsFrom(expectedAddr); + return 1; + } + if (importer.m_statePost.code(expectedAddr) != theState.code(expectedAddr)) + { + cout << expectedAddr << ": incorrect code"; + return 1; + } //checkStorage(importer.m_statePost.storage(expectedAddr), theState.storage(expectedAddr), expectedAddr); - map _resultStore = theState.storage(expectedAddr); for (auto&& expectedStorePair : importer.m_statePost.storage(expectedAddr)) From 76c3e165cac2f1ebb246ad6e9febf480dcd60a0d Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Thu, 12 Mar 2015 11:42:16 +0100 Subject: [PATCH 04/33] remove unneccessary dependencies --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 45f83e5e3..d7761b8d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,9 +20,9 @@ include_directories(${JSON_RPC_CPP_INCLUDE_DIRS}) file(GLOB HEADERS "*.h") add_executable(testeth ${SRC_LIST} ${HEADERS}) add_executable(createRandomVMTest createRandomVMTest.cpp vm.cpp TestHelper.cpp) -add_executable(createRandomStateTest createRandomStateTest.cpp state.cpp TestHelper.cpp) +add_executable(createRandomStateTest createRandomStateTest.cpp TestHelper.cpp) add_executable(checkRandomVMTest checkRandomVMTest.cpp vm.cpp TestHelper.cpp) -add_executable(checkRandomStateTest checkRandomStateTest.cpp state.cpp TestHelper.cpp) +add_executable(checkRandomStateTest checkRandomStateTest.cpp TestHelper.cpp) target_link_libraries(testeth ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES}) target_link_libraries(testeth ${CURL_LIBRARIES}) From 5f43489d3db4c0ec20f21960687a2478dd7e2b3b Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Thu, 12 Mar 2015 11:54:11 +0100 Subject: [PATCH 05/33] style fix --- checkRandomStateTest.cpp | 12 +++++++----- checkRandomVMTest.cpp | 6 +++--- createRandomVMTest.cpp | 6 +++--- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/checkRandomStateTest.cpp b/checkRandomStateTest.cpp index 90a88d57e..4c07c3cf9 100644 --- a/checkRandomStateTest.cpp +++ b/checkRandomStateTest.cpp @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with cpp-ethereum. If not, see . */ -/** @file checkRandomTest.cpp +/** @file checkRandomStateTest.cpp * @author Christoph Jentzsch * @date 2015 * Check a random test and return 0/1 for success or failure. To be used for efficiency in the random test simulation. @@ -33,7 +33,7 @@ using namespace json_spirit; using namespace dev::test; using namespace dev; -bool doStateTest(mValue& v); +bool doStateTest(mValue& _v); int main(int argc, char *argv[]) { @@ -67,11 +67,11 @@ int main(int argc, char *argv[]) return ret; } -bool doStateTest(mValue& v) +bool doStateTest(mValue& _v) { eth::VMFactory::setKind(eth::VMKind::JIT); - for (auto& i: v.get_obj()) + for (auto& i: _v.get_obj()) { mObject& o = i.second.get_obj(); @@ -152,7 +152,9 @@ bool doStateTest(mValue& v) auto& expectedAddr = expectedPair.first; auto resultAddrIt = resultAddrs.find(expectedAddr); if (resultAddrIt == resultAddrs.end()) - BOOST_ERROR("Missing expected address " << expectedAddr); + { + cout << "Missing expected address " << expectedAddr; + return 1; else { if (importer.m_statePost.balance(expectedAddr) != theState.balance(expectedAddr)) diff --git a/checkRandomVMTest.cpp b/checkRandomVMTest.cpp index e3442d438..c96357714 100644 --- a/checkRandomVMTest.cpp +++ b/checkRandomVMTest.cpp @@ -32,7 +32,7 @@ using namespace json_spirit; using namespace dev::test; using namespace dev; -bool doVMTest(mValue& v); +bool doVMTest(mValue& _v); int main(int argc, char *argv[]) { @@ -66,11 +66,11 @@ int main(int argc, char *argv[]) return ret; } -bool doVMTest(mValue& v) +bool doVMTest(mValue& _v) { eth::VMFactory::setKind(eth::VMKind::JIT); - for (auto& i: v.get_obj()) + for (auto& i: _v.get_obj()) { cnote << i.first; mObject& o = i.second.get_obj(); diff --git a/createRandomVMTest.cpp b/createRandomVMTest.cpp index 55e023759..de81099fe 100644 --- a/createRandomVMTest.cpp +++ b/createRandomVMTest.cpp @@ -41,7 +41,7 @@ using namespace std; using namespace json_spirit; using namespace dev; -void doMyTests(json_spirit::mValue& v); +void doMyTests(json_spirit::mValue& _v); int main(int argc, char *argv[]) { @@ -127,11 +127,11 @@ int main(int argc, char *argv[]) return 0; } -void doMyTests(json_spirit::mValue& v) +void doMyTests(json_spirit::mValue& _v) { eth::VMFactory::setKind(eth::VMKind::Interpreter); - for (auto& i: v.get_obj()) + for (auto& i: _v.get_obj()) { cnote << i.first; mObject& o = i.second.get_obj(); From eb2fd0f5219facb3e2f68fccee9da8e1fb54b74e Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Thu, 12 Mar 2015 12:49:52 +0100 Subject: [PATCH 06/33] random state test optmization --- checkRandomStateTest.cpp | 1 + createRandomStateTest.cpp | 15 +++++++++++---- stSystemOperationsTestFiller.json | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/checkRandomStateTest.cpp b/checkRandomStateTest.cpp index 4c07c3cf9..ed12b7dc4 100644 --- a/checkRandomStateTest.cpp +++ b/checkRandomStateTest.cpp @@ -155,6 +155,7 @@ bool doStateTest(mValue& _v) { cout << "Missing expected address " << expectedAddr; return 1; + } else { if (importer.m_statePost.balance(expectedAddr) != theState.balance(expectedAddr)) diff --git a/createRandomStateTest.cpp b/createRandomStateTest.cpp index 06a332e0e..6b24f1216 100644 --- a/createRandomStateTest.cpp +++ b/createRandomStateTest.cpp @@ -87,10 +87,10 @@ int main(int argc, char *argv[]) "randomStatetest" : { "env" : { "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", - "currentDifficulty" : "256", - "currentGasLimit" : "1000000", + "currentDifficulty" : "0x945304eb96065b2a98b57a48a06ae28d285a71b5", + "currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935", "currentNumber" : "0", - "currentTimestamp" : 1, + "currentTimestamp" : "1", "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" }, "pre" : { @@ -101,6 +101,13 @@ int main(int argc, char *argv[]) "storage" : { } }, + "945304eb96065b2a98b57a48a06ae28d285a71b5" : { + "balance" : "46", + "code" : "0x6000355415600957005b60203560003555", + "nonce" : "0", + "storage" : { + } + }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { "balance" : "1000000000000000000", "code" : "0x", @@ -110,7 +117,7 @@ int main(int argc, char *argv[]) } }, "transaction" : { - "data" : "", + "data" : "0x42", "gasLimit" : "400000", "gasPrice" : "1", "nonce" : "0", diff --git a/stSystemOperationsTestFiller.json b/stSystemOperationsTestFiller.json index 7460ca94e..e26308e28 100644 --- a/stSystemOperationsTestFiller.json +++ b/stSystemOperationsTestFiller.json @@ -389,7 +389,7 @@ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { "balance" : "1000000000000000000", "nonce" : "0", - "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALL 1000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 64 64 0) }", + "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALL 100000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 64 64 0) }", "storage": {} }, "945304eb96065b2a98b57a48a06ae28d285a71b5" : { @@ -410,7 +410,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "30000", + "gasLimit" : "300000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", From c72197a45315649b9d6d32c84d1cc94f2e8f0e84 Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Mon, 9 Mar 2015 13:49:53 +0100 Subject: [PATCH 07/33] Bytes Tokens properly named and NameAndTypeResolution tests work --- SolidityNameAndTypeResolution.cpp | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/SolidityNameAndTypeResolution.cpp b/SolidityNameAndTypeResolution.cpp index c3a4a3377..3dfac0a3e 100644 --- a/SolidityNameAndTypeResolution.cpp +++ b/SolidityNameAndTypeResolution.cpp @@ -75,6 +75,7 @@ static FunctionTypePointer const& retrieveFunctionBySignature(ContractDefinition FixedHash<4> hash(dev::sha3(_signature)); return _contract->getInterfaceFunctions()[hash]; } + } BOOST_AUTO_TEST_SUITE(SolidityNameAndTypeResolution) @@ -353,7 +354,7 @@ BOOST_AUTO_TEST_CASE(function_canonical_signature) " ret = arg1 + arg2;\n" " }\n" "}\n"; - BOOST_CHECK_NO_THROW(sourceUnit = parseTextAndResolveNames(text)); + ETH_TEST_REQUIRE_NO_THROW(sourceUnit = parseTextAndResolveNames(text), "Parsing and name Resolving failed"); for (ASTPointer const& node: sourceUnit->getNodes()) if (ContractDefinition* contract = dynamic_cast(node.get())) { @@ -366,16 +367,16 @@ BOOST_AUTO_TEST_CASE(function_canonical_signature_type_aliases) { ASTPointer sourceUnit; char const* text = "contract Test {\n" - " function boo(uint arg1, hash arg2, address arg3) returns (uint ret) {\n" + " function boo(uint arg1, bytes32 arg2, address arg3) returns (uint ret) {\n" " ret = 5;\n" " }\n" "}\n"; - BOOST_CHECK_NO_THROW(sourceUnit = parseTextAndResolveNames(text)); + ETH_TEST_REQUIRE_NO_THROW(sourceUnit = parseTextAndResolveNames(text), "Parsing and name Resolving failed"); for (ASTPointer const& node: sourceUnit->getNodes()) if (ContractDefinition* contract = dynamic_cast(node.get())) { auto functions = contract->getDefinedFunctions(); - BOOST_CHECK_EQUAL("boo(uint256,hash256,address)", functions[0]->getCanonicalSignature()); + BOOST_CHECK_EQUAL("boo(uint256,bytes32,address)", functions[0]->getCanonicalSignature()); } } @@ -537,7 +538,7 @@ BOOST_AUTO_TEST_CASE(function_modifier_invocation) contract B { function f() mod1(2, true) mod2("0123456") { } modifier mod1(uint a, bool b) { if (b) _ } - modifier mod2(string7 a) { while (a == "1234567") _ } + modifier mod2(bytes7 a) { while (a == "1234567") _ } } )"; ETH_TEST_CHECK_NO_THROW(parseTextAndResolveNames(text), "Parsing and Name Resolving Failed"); @@ -558,9 +559,9 @@ BOOST_AUTO_TEST_CASE(function_modifier_invocation_parameters) { char const* text = R"( contract B { - function f(uint8 a) mod1(a, true) mod2(r) returns (string7 r) { } + function f(uint8 a) mod1(a, true) mod2(r) returns (bytes7 r) { } modifier mod1(uint a, bool b) { if (b) _ } - modifier mod2(string7 a) { while (a == "1234567") _ } + modifier mod2(bytes7 a) { while (a == "1234567") _ } } )"; ETH_TEST_CHECK_NO_THROW(parseTextAndResolveNames(text), "Parsing and Name Resolving Failed"); @@ -631,8 +632,8 @@ BOOST_AUTO_TEST_CASE(state_variable_accessors) " uint64(2);\n" " }\n" "uint256 public foo;\n" - "mapping(uint=>string4) public map;\n" - "mapping(uint=>mapping(uint=>string4)) public multiple_map;\n" + "mapping(uint=>bytes4) public map;\n" + "mapping(uint=>mapping(uint=>bytes4)) public multiple_map;\n" "}\n"; ASTPointer source; @@ -650,7 +651,7 @@ BOOST_AUTO_TEST_CASE(state_variable_accessors) auto params = function->getParameterTypeNames(); BOOST_CHECK_EQUAL(params.at(0), "uint256"); returnParams = function->getReturnParameterTypeNames(); - BOOST_CHECK_EQUAL(returnParams.at(0), "string4"); + BOOST_CHECK_EQUAL(returnParams.at(0), "bytes4"); BOOST_CHECK(function->isConstant()); function = retrieveFunctionBySignature(contract, "multiple_map(uint256,uint256)"); @@ -659,7 +660,7 @@ BOOST_AUTO_TEST_CASE(state_variable_accessors) BOOST_CHECK_EQUAL(params.at(0), "uint256"); BOOST_CHECK_EQUAL(params.at(1), "uint256"); returnParams = function->getReturnParameterTypeNames(); - BOOST_CHECK_EQUAL(returnParams.at(0), "string4"); + BOOST_CHECK_EQUAL(returnParams.at(0), "bytes4"); BOOST_CHECK(function->isConstant()); } @@ -800,7 +801,7 @@ BOOST_AUTO_TEST_CASE(event) { char const* text = R"( contract c { - event e(uint indexed a, string3 indexed s, bool indexed b); + event e(uint indexed a, bytes3 indexed s, bool indexed b); function f() { e(2, "abc", true); } })"; ETH_TEST_CHECK_NO_THROW(parseTextAndResolveNames(text), "Parsing and Name Resolving Failed"); @@ -810,7 +811,7 @@ BOOST_AUTO_TEST_CASE(event_too_many_indexed) { char const* text = R"( contract c { - event e(uint indexed a, string3 indexed b, bool indexed c, uint indexed d); + event e(uint indexed a, bytes3 indexed b, bool indexed c, uint indexed d); function f() { e(2, "abc", true); } })"; BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError); @@ -820,7 +821,7 @@ BOOST_AUTO_TEST_CASE(event_call) { char const* text = R"( contract c { - event e(uint a, string3 indexed s, bool indexed b); + event e(uint a, bytes3 indexed s, bool indexed b); function f() { e(2, "abc", true); } })"; ETH_TEST_CHECK_NO_THROW(parseTextAndResolveNames(text), "Parsing and Name Resolving Failed"); @@ -830,7 +831,7 @@ BOOST_AUTO_TEST_CASE(event_inheritance) { char const* text = R"( contract base { - event e(uint a, string3 indexed s, bool indexed b); + event e(uint a, bytes3 indexed s, bool indexed b); } contract c is base { function f() { e(2, "abc", true); } From 5abf18c27f48c70948876fca06b4a26a608454ce Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Mon, 9 Mar 2015 17:48:33 +0100 Subject: [PATCH 08/33] Most EndToEndTests are now compliant with the Bytes renaming --- SolidityEndToEndTest.cpp | 140 +++++++++++++++--------------- SolidityNameAndTypeResolution.cpp | 105 ++++++++++++++++++++++ SolidityParser.cpp | 4 +- 3 files changed, 178 insertions(+), 71 deletions(-) diff --git a/SolidityEndToEndTest.cpp b/SolidityEndToEndTest.cpp index 3205c038a..d9ea6ed98 100644 --- a/SolidityEndToEndTest.cpp +++ b/SolidityEndToEndTest.cpp @@ -507,23 +507,23 @@ BOOST_AUTO_TEST_CASE(small_signed_types) BOOST_AUTO_TEST_CASE(strings) { char const* sourceCode = "contract test {\n" - " function fixed() returns(string32 ret) {\n" + " function fixed() returns(bytes32 ret) {\n" " return \"abc\\x00\\xff__\";\n" " }\n" - " function pipeThrough(string2 small, bool one) returns(string16 large, bool oneRet) {\n" + " function pipeThrough(bytes2 small, bool one) returns(bytes16 large, bool oneRet) {\n" " oneRet = one;\n" " large = small;\n" " }\n" "}\n"; compileAndRun(sourceCode); BOOST_CHECK(callContractFunction("fixed()") == encodeArgs(string("abc\0\xff__", 7))); - BOOST_CHECK(callContractFunction("pipeThrough(string2,bool)", string("\0\x02", 2), true) == encodeArgs(string("\0\x2", 2), true)); + BOOST_CHECK(callContractFunction("pipeThrough(bytes2,bool)", string("\0\x02", 2), true) == encodeArgs(string("\0\x2", 2), true)); } - +# BOOST_AUTO_TEST_CASE(empty_string_on_stack) { char const* sourceCode = "contract test {\n" - " function run(string0 empty, uint8 inp) returns(uint16 a, string0 b, string4 c) {\n" + " function run(bytes0 empty, uint8 inp) returns(uint16 a, bytes0 b, bytes4 c) {\n" " var x = \"abc\";\n" " var y = \"\";\n" " var z = inp;\n" @@ -531,7 +531,7 @@ BOOST_AUTO_TEST_CASE(empty_string_on_stack) " }\n" "}\n"; compileAndRun(sourceCode); - BOOST_CHECK(callContractFunction("run(string0,uint8)", string(), byte(0x02)) == encodeArgs(0x2, string(""), string("abc\0"))); + BOOST_CHECK(callContractFunction("run(bytes0,uint8)", string(), byte(0x02)) == encodeArgs(0x2, string(""), string("abc\0"))); } BOOST_AUTO_TEST_CASE(state_smoke_test) @@ -948,8 +948,8 @@ BOOST_AUTO_TEST_CASE(multiple_elementary_accessors) { char const* sourceCode = "contract test {\n" " uint256 public data;\n" - " string6 public name;\n" - " hash public a_hash;\n" + " bytes6 public name;\n" + " bytes32 public a_hash;\n" " address public an_address;\n" " function test() {\n" " data = 8;\n" @@ -971,7 +971,7 @@ BOOST_AUTO_TEST_CASE(multiple_elementary_accessors) BOOST_AUTO_TEST_CASE(complex_accessors) { char const* sourceCode = "contract test {\n" - " mapping(uint256 => string4) public to_string_map;\n" + " mapping(uint256 => bytes4) public to_string_map;\n" " mapping(uint256 => bool) public to_bool_map;\n" " mapping(uint256 => uint256) public to_uint_map;\n" " mapping(uint256 => mapping(uint256 => uint256)) public to_multiple_map;\n" @@ -1076,96 +1076,96 @@ BOOST_AUTO_TEST_CASE(type_conversions_cleanup) 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x11, 0x22})); } -BOOST_AUTO_TEST_CASE(convert_string_to_string) +BOOST_AUTO_TEST_CASE(convert_fixed_bytes_to_fixed_bytes_smaller_size) { char const* sourceCode = R"( contract Test { - function pipeTrough(string3 input) returns (string3 ret) { - return string3(input); + function pipeTrough(bytes3 input) returns (bytes2 ret) { + return bytes2(input); } })"; compileAndRun(sourceCode); - BOOST_CHECK(callContractFunction("pipeTrough(string3)", "abc") == encodeArgs("abc")); + BOOST_CHECK(callContractFunction("pipeTrough(bytes3)", "abc") == encodeArgs("ab")); } -BOOST_AUTO_TEST_CASE(convert_hash_to_string_same_size) +BOOST_AUTO_TEST_CASE(convert_uint_to_fixed_bytes_same_size) { char const* sourceCode = R"( contract Test { - function hashToString(hash h) returns (string32 s) { - return string32(h); + function uintToBytes(uint256 h) returns (bytes32 s) { + return bytes32(h); } })"; compileAndRun(sourceCode); u256 a("0x6162630000000000000000000000000000000000000000000000000000000000"); - BOOST_CHECK(callContractFunction("hashToString(hash256)", a) == encodeArgs(a)); + BOOST_CHECK(callContractFunction("uintToBytes(uint256)", a) == encodeArgs(a)); } -BOOST_AUTO_TEST_CASE(convert_hash_to_string_different_size) +BOOST_AUTO_TEST_CASE(convert_uint_to_fixed_bytes_different_size) { char const* sourceCode = R"( contract Test { - function hashToString(hash160 h) returns (string20 s) { - return string20(h); + function uintToBytes(uint160 h) returns (bytes20 s) { + return bytes20(h); } })"; compileAndRun(sourceCode); - BOOST_CHECK(callContractFunction("hashToString(hash160)", u160("0x6161626361626361626361616263616263616263")) == - encodeArgs(string("aabcabcabcaabcabcabc"))); + BOOST_CHECK(callContractFunction("uintToBytes(uint160)", + u160("0x6161626361626361626361616263616263616263")) == encodeArgs(string("aabcabcabcaabcabcabc"))); } -BOOST_AUTO_TEST_CASE(convert_string_to_hash_same_size) +BOOST_AUTO_TEST_CASE(convert_fixed_bytes_to_uint_same_size) { char const* sourceCode = R"( contract Test { - function stringToHash(string32 s) returns (hash h) { - return hash(s); + function bytesToUint(bytes32 s) returns (uint256 h) { + return uint(s); } })"; compileAndRun(sourceCode); - BOOST_CHECK(callContractFunction("stringToHash(string32)", string("abc2")) == - encodeArgs(u256("0x6162633200000000000000000000000000000000000000000000000000000000"))); + BOOST_CHECK(callContractFunction("bytesToUint(bytes32)", string("abc2")) == + encodeArgs(u256("0x6162633200000000000000000000000000000000000000000000000000000000"))); } -BOOST_AUTO_TEST_CASE(convert_string_to_hash_different_size) +BOOST_AUTO_TEST_CASE(convert_fixed_bytes_to_uint_different_size) { char const* sourceCode = R"( contract Test { - function stringToHash(string20 s) returns (hash160 h) { - return hash160(s); + function bytesToUint(bytes20 s) returns (uint160 h) { + return uint160(s); } })"; compileAndRun(sourceCode); - BOOST_CHECK(callContractFunction("stringToHash(string20)", string("aabcabcabcaabcabcabc")) == - encodeArgs(u160("0x6161626361626361626361616263616263616263"))); + BOOST_CHECK(callContractFunction("bytesToUint(bytes20)", string("aabcabcabcaabcabcabc")) == + encodeArgs(u160("0x6161626361626361626361616263616263616263"))); } -BOOST_AUTO_TEST_CASE(convert_string_to_hash_different_min_size) +BOOST_AUTO_TEST_CASE(convert_fixed_bytes_to_uint_different_min_size) { char const* sourceCode = R"( contract Test { - function stringToHash(string1 s) returns (hash8 h) { - return hash8(s); + function bytesToUint(bytes1 s) returns (uint8 h) { + return uint8(s); } })"; compileAndRun(sourceCode); - BOOST_CHECK(callContractFunction("stringToHash(string1)", string("a")) == - encodeArgs(u256("0x61"))); + BOOST_CHECK(callContractFunction("bytesToUint(bytes1)", string("a")) == + encodeArgs(u256("0x61"))); } -BOOST_AUTO_TEST_CASE(convert_hash_to_string_different_min_size) +BOOST_AUTO_TEST_CASE(convert_uint_to_fixed_bytes_different_min_size) { char const* sourceCode = R"( contract Test { - function HashToString(hash8 h) returns (string1 s) { - return string1(h); + function UintToBytes(uint8 h) returns (bytes1 s) { + return bytes1(h); } })"; compileAndRun(sourceCode); - BOOST_CHECK(callContractFunction("HashToString(hash8)", u256("0x61")) == - encodeArgs(string("a"))); + BOOST_CHECK(callContractFunction("UintToBytes(uint8)", u256("0x61")) == + encodeArgs(string("a"))); } BOOST_AUTO_TEST_CASE(send_ether) @@ -1182,12 +1182,14 @@ BOOST_AUTO_TEST_CASE(send_ether) BOOST_CHECK(callContractFunction("a(address,uint256)", address, amount) == encodeArgs(1)); BOOST_CHECK_EQUAL(m_state.balance(address), amount); } - +// TODO: Note that these tests should actually be +// simply converting integer constant to bytes32. This conversion is not there +// yet. When it's implemented DO change the tests too BOOST_AUTO_TEST_CASE(log0) { char const* sourceCode = "contract test {\n" " function a() {\n" - " log0(1);\n" + " log0(bytes32(int(1)));\n" " }\n" "}\n"; compileAndRun(sourceCode); @@ -1202,7 +1204,7 @@ BOOST_AUTO_TEST_CASE(log1) { char const* sourceCode = "contract test {\n" " function a() {\n" - " log1(1, 2);\n" + " log1(bytes32(int(1)), bytes32(int(2)));\n" " }\n" "}\n"; compileAndRun(sourceCode); @@ -1218,7 +1220,7 @@ BOOST_AUTO_TEST_CASE(log2) { char const* sourceCode = "contract test {\n" " function a() {\n" - " log2(1, 2, 3);\n" + " log2(bytes32(int(1)), bytes32(int(2)), bytes32(int(3)));\n" " }\n" "}\n"; compileAndRun(sourceCode); @@ -1235,7 +1237,7 @@ BOOST_AUTO_TEST_CASE(log3) { char const* sourceCode = "contract test {\n" " function a() {\n" - " log3(1, 2, 3, 4);\n" + " log3(bytes32(int(1)), bytes32(int(2)), bytes32(int(3)), bytes32(int(4)));\n" " }\n" "}\n"; compileAndRun(sourceCode); @@ -1252,7 +1254,7 @@ BOOST_AUTO_TEST_CASE(log4) { char const* sourceCode = "contract test {\n" " function a() {\n" - " log4(1, 2, 3, 4, 5);\n" + " log4(bytes32(int(1)), bytes32(int(2)), bytes32(int(3)), bytes32(int(4)), bytes32(int(5)));\n" " }\n" "}\n"; compileAndRun(sourceCode); @@ -1269,7 +1271,7 @@ BOOST_AUTO_TEST_CASE(log_in_constructor) { char const* sourceCode = "contract test {\n" " function test() {\n" - " log1(1, 2);\n" + " log1(bytes32(int(1)), bytes32(int(2)));\n" " }\n" "}\n"; compileAndRun(sourceCode); @@ -1299,7 +1301,7 @@ BOOST_AUTO_TEST_CASE(suicide) BOOST_AUTO_TEST_CASE(sha3) { char const* sourceCode = "contract test {\n" - " function a(hash input) returns (hash sha3hash) {\n" + " function a(bytes32 input) returns (bytes32 sha3hash) {\n" " return sha3(input);\n" " }\n" "}\n"; @@ -1308,15 +1310,15 @@ BOOST_AUTO_TEST_CASE(sha3) { return dev::sha3(toBigEndian(_x)); }; - testSolidityAgainstCpp("a(hash256)", f, u256(4)); - testSolidityAgainstCpp("a(hash256)", f, u256(5)); - testSolidityAgainstCpp("a(hash256)", f, u256(-1)); + testSolidityAgainstCpp("a(bytes32)", f, u256(4)); + testSolidityAgainstCpp("a(bytes32)", f, u256(5)); + testSolidityAgainstCpp("a(bytes32)", f, u256(-1)); } BOOST_AUTO_TEST_CASE(sha256) { char const* sourceCode = "contract test {\n" - " function a(hash input) returns (hash sha256hash) {\n" + " function a(bytes32 input) returns (bytes32 sha256hash) {\n" " return sha256(input);\n" " }\n" "}\n"; @@ -1327,15 +1329,15 @@ BOOST_AUTO_TEST_CASE(sha256) dev::sha256(dev::ref(toBigEndian(_input)), bytesRef(&ret[0], 32)); return ret; }; - testSolidityAgainstCpp("a(hash256)", f, u256(4)); - testSolidityAgainstCpp("a(hash256)", f, u256(5)); - testSolidityAgainstCpp("a(hash256)", f, u256(-1)); + testSolidityAgainstCpp("a(bytes32)", f, u256(4)); + testSolidityAgainstCpp("a(bytes32)", f, u256(5)); + testSolidityAgainstCpp("a(bytes32)", f, u256(-1)); } BOOST_AUTO_TEST_CASE(ripemd) { char const* sourceCode = "contract test {\n" - " function a(hash input) returns (hash sha256hash) {\n" + " function a(bytes32 input) returns (bytes32 sha256hash) {\n" " return ripemd160(input);\n" " }\n" "}\n"; @@ -1346,16 +1348,16 @@ BOOST_AUTO_TEST_CASE(ripemd) dev::ripemd160(dev::ref(toBigEndian(_input)), bytesRef(&ret[0], 32)); return u256(ret) >> (256 - 160); }; - testSolidityAgainstCpp("a(hash256)", f, u256(4)); - testSolidityAgainstCpp("a(hash256)", f, u256(5)); - testSolidityAgainstCpp("a(hash256)", f, u256(-1)); + testSolidityAgainstCpp("a(bytes32)", f, u256(4)); + testSolidityAgainstCpp("a(bytes32)", f, u256(5)); + testSolidityAgainstCpp("a(bytes32)", f, u256(-1)); } BOOST_AUTO_TEST_CASE(ecrecover) { char const* sourceCode = "contract test {\n" - " function a(hash h, uint8 v, hash r, hash s) returns (address addr) {\n" - " return ecrecover(h, v, r, s);\n" + " function a(bytes32 h, uint8 v, bytes32 r, bytes32 s) returns (address addr) {\n" + " return ecrecover(h, bytes1(v), r, s);\n" " }\n" "}\n"; compileAndRun(sourceCode); @@ -1364,7 +1366,7 @@ BOOST_AUTO_TEST_CASE(ecrecover) u256 r("0x73b1693892219d736caba55bdb67216e485557ea6b6af75f37096c9aa6a5a75f"); u256 s("0xeeb940b1d03b21e36b0e47e79769f095fe2ab855bd91e3a38756b7d75a9c4549"); u160 addr("0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b"); - BOOST_CHECK(callContractFunction("a(hash256,uint8,hash256,hash256)", h, v, r, s) == encodeArgs(addr)); + BOOST_CHECK(callContractFunction("a(bytes32,uint8,bytes32,bytes32)", h, v, r, s) == encodeArgs(addr)); } BOOST_AUTO_TEST_CASE(inter_contract_calls) @@ -2090,13 +2092,13 @@ BOOST_AUTO_TEST_CASE(event) { char const* sourceCode = R"( contract ClientReceipt { - event Deposit(address indexed _from, hash indexed _id, uint _value); - function deposit(hash _id, bool _manually) { + event Deposit(address indexed _from, bytes32 indexed _id, uint _value); + function deposit(bytes32 _id, bool _manually) { if (_manually) { - hash s = 0x50cb9fe53daa9737b786ab3646f04d0150dc50ef4e75f59509d83667ad5adb20; - log3(msg.value, s, hash32(msg.sender), _id); + bytes32 s = uint(0x50cb9fe53daa9737b786ab3646f04d0150dc50ef4e75f59509d83667ad5adb20); + log3(msg.value, s, bytes4(msg.sender), _id); } else - Deposit(hash32(msg.sender), _id, msg.value); + Deposit(bytes4(msg.sender), _id, msg.value); } } )"; diff --git a/SolidityNameAndTypeResolution.cpp b/SolidityNameAndTypeResolution.cpp index 3dfac0a3e..a73c937f9 100644 --- a/SolidityNameAndTypeResolution.cpp +++ b/SolidityNameAndTypeResolution.cpp @@ -1288,6 +1288,111 @@ BOOST_AUTO_TEST_CASE(storage_variable_initialization_with_incorrect_type_string) BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError); } +BOOST_AUTO_TEST_CASE(test_fromElementaryTypeName) +{ + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Int) == *make_shared(256, IntegerType::Modifier::Signed)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Int8) == *make_shared(8, IntegerType::Modifier::Signed)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Int16) == *make_shared(16, IntegerType::Modifier::Signed)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Int24) == *make_shared(24, IntegerType::Modifier::Signed)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Int32) == *make_shared(32, IntegerType::Modifier::Signed)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Int40) == *make_shared(40, IntegerType::Modifier::Signed)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Int48) == *make_shared(48, IntegerType::Modifier::Signed)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Int56) == *make_shared(56, IntegerType::Modifier::Signed)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Int64) == *make_shared(64, IntegerType::Modifier::Signed)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Int72) == *make_shared(72, IntegerType::Modifier::Signed)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Int80) == *make_shared(80, IntegerType::Modifier::Signed)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Int88) == *make_shared(88, IntegerType::Modifier::Signed)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Int96) == *make_shared(96, IntegerType::Modifier::Signed)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Int104) == *make_shared(104, IntegerType::Modifier::Signed)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Int112) == *make_shared(112, IntegerType::Modifier::Signed)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Int120) == *make_shared(120, IntegerType::Modifier::Signed)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Int128) == *make_shared(128, IntegerType::Modifier::Signed)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Int136) == *make_shared(136, IntegerType::Modifier::Signed)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Int144) == *make_shared(144, IntegerType::Modifier::Signed)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Int152) == *make_shared(152, IntegerType::Modifier::Signed)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Int160) == *make_shared(160, IntegerType::Modifier::Signed)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Int168) == *make_shared(168, IntegerType::Modifier::Signed)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Int176) == *make_shared(176, IntegerType::Modifier::Signed)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Int184) == *make_shared(184, IntegerType::Modifier::Signed)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Int192) == *make_shared(192, IntegerType::Modifier::Signed)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Int200) == *make_shared(200, IntegerType::Modifier::Signed)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Int208) == *make_shared(208, IntegerType::Modifier::Signed)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Int216) == *make_shared(216, IntegerType::Modifier::Signed)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Int224) == *make_shared(224, IntegerType::Modifier::Signed)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Int232) == *make_shared(232, IntegerType::Modifier::Signed)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Int240) == *make_shared(240, IntegerType::Modifier::Signed)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Int248) == *make_shared(248, IntegerType::Modifier::Signed)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Int256) == *make_shared(256, IntegerType::Modifier::Signed)); + + BOOST_CHECK(*Type::fromElementaryTypeName(Token::UInt) == *make_shared(256, IntegerType::Modifier::Unsigned)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::UInt8) == *make_shared(8, IntegerType::Modifier::Unsigned)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::UInt16) == *make_shared(16, IntegerType::Modifier::Unsigned)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::UInt24) == *make_shared(24, IntegerType::Modifier::Unsigned)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::UInt32) == *make_shared(32, IntegerType::Modifier::Unsigned)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::UInt40) == *make_shared(40, IntegerType::Modifier::Unsigned)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::UInt48) == *make_shared(48, IntegerType::Modifier::Unsigned)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::UInt56) == *make_shared(56, IntegerType::Modifier::Unsigned)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::UInt64) == *make_shared(64, IntegerType::Modifier::Unsigned)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::UInt72) == *make_shared(72, IntegerType::Modifier::Unsigned)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::UInt80) == *make_shared(80, IntegerType::Modifier::Unsigned)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::UInt88) == *make_shared(88, IntegerType::Modifier::Unsigned)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::UInt96) == *make_shared(96, IntegerType::Modifier::Unsigned)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::UInt104) == *make_shared(104, IntegerType::Modifier::Unsigned)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::UInt112) == *make_shared(112, IntegerType::Modifier::Unsigned)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::UInt120) == *make_shared(120, IntegerType::Modifier::Unsigned)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::UInt128) == *make_shared(128, IntegerType::Modifier::Unsigned)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::UInt136) == *make_shared(136, IntegerType::Modifier::Unsigned)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::UInt144) == *make_shared(144, IntegerType::Modifier::Unsigned)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::UInt152) == *make_shared(152, IntegerType::Modifier::Unsigned)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::UInt160) == *make_shared(160, IntegerType::Modifier::Unsigned)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::UInt168) == *make_shared(168, IntegerType::Modifier::Unsigned)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::UInt176) == *make_shared(176, IntegerType::Modifier::Unsigned)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::UInt184) == *make_shared(184, IntegerType::Modifier::Unsigned)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::UInt192) == *make_shared(192, IntegerType::Modifier::Unsigned)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::UInt200) == *make_shared(200, IntegerType::Modifier::Unsigned)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::UInt208) == *make_shared(208, IntegerType::Modifier::Unsigned)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::UInt216) == *make_shared(216, IntegerType::Modifier::Unsigned)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::UInt224) == *make_shared(224, IntegerType::Modifier::Unsigned)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::UInt232) == *make_shared(232, IntegerType::Modifier::Unsigned)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::UInt240) == *make_shared(240, IntegerType::Modifier::Unsigned)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::UInt248) == *make_shared(248, IntegerType::Modifier::Unsigned)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::UInt256) == *make_shared(256, IntegerType::Modifier::Unsigned)); + + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes0) == *make_shared(0)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes1) == *make_shared(1)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes2) == *make_shared(2)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes3) == *make_shared(3)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes4) == *make_shared(4)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes5) == *make_shared(5)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes6) == *make_shared(6)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes7) == *make_shared(7)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes8) == *make_shared(8)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes9) == *make_shared(9)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes10) == *make_shared(10)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes11) == *make_shared(11)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes12) == *make_shared(12)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes13) == *make_shared(13)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes14) == *make_shared(14)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes15) == *make_shared(15)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes16) == *make_shared(16)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes17) == *make_shared(17)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes18) == *make_shared(18)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes19) == *make_shared(19)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes20) == *make_shared(20)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes21) == *make_shared(21)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes22) == *make_shared(22)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes23) == *make_shared(23)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes24) == *make_shared(24)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes25) == *make_shared(25)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes26) == *make_shared(26)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes27) == *make_shared(27)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes28) == *make_shared(28)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes29) == *make_shared(29)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes30) == *make_shared(30)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes31) == *make_shared(31)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes32) == *make_shared(32)); +} + BOOST_AUTO_TEST_SUITE_END() } diff --git a/SolidityParser.cpp b/SolidityParser.cpp index 88b86e638..608e1707e 100644 --- a/SolidityParser.cpp +++ b/SolidityParser.cpp @@ -307,7 +307,7 @@ BOOST_AUTO_TEST_CASE(mapping_in_struct) " struct test_struct {\n" " address addr;\n" " uint256 count;\n" - " mapping(hash => test_struct) self_reference;\n" + " mapping(bytes32 => test_struct) self_reference;\n" " }\n" "}\n"; ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); @@ -318,7 +318,7 @@ BOOST_AUTO_TEST_CASE(mapping_to_mapping_in_struct) char const* text = "contract test {\n" " struct test_struct {\n" " address addr;\n" - " mapping (uint64 => mapping (hash => uint)) complex_mapping;\n" + " mapping (uint64 => mapping (bytes32 => uint)) complex_mapping;\n" " }\n" "}\n"; ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); From 125a1bb670a4e1b0d1e6816928957142d24b4830 Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Tue, 10 Mar 2015 18:22:19 +0100 Subject: [PATCH 09/33] Conversion changes after renaming Hash/String to Bytes. - Almost all end to end tests pass. Still needs a little bit of work --- SolidityEndToEndTest.cpp | 66 ++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/SolidityEndToEndTest.cpp b/SolidityEndToEndTest.cpp index d9ea6ed98..b47048272 100644 --- a/SolidityEndToEndTest.cpp +++ b/SolidityEndToEndTest.cpp @@ -1357,7 +1357,7 @@ BOOST_AUTO_TEST_CASE(ecrecover) { char const* sourceCode = "contract test {\n" " function a(bytes32 h, uint8 v, bytes32 r, bytes32 s) returns (address addr) {\n" - " return ecrecover(h, bytes1(v), r, s);\n" + " return ecrecover(h, v, r, s);\n" " }\n" "}\n"; compileAndRun(sourceCode); @@ -1526,17 +1526,17 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls_with_local_vars) BOOST_REQUIRE(callContractFunction("callHelper(uint256,uint256)", a, b) == encodeArgs(a * b + 9)); } -BOOST_AUTO_TEST_CASE(strings_in_calls) +BOOST_AUTO_TEST_CASE(fixed_bytes_in_calls) { char const* sourceCode = R"( contract Helper { - function invoke(string3 x, bool stop) returns (string4 ret) { + function invoke(bytes3 x, bool stop) returns (bytes4 ret) { return x; } } contract Main { Helper h; - function callHelper(string2 x, bool stop) returns (string5 ret) { + function callHelper(bytes2 x, bool stop) returns (bytes5 ret) { return h.invoke(x, stop); } function getHelper() returns (address addr) { @@ -1551,21 +1551,21 @@ BOOST_AUTO_TEST_CASE(strings_in_calls) compileAndRun(sourceCode, 0, "Main"); BOOST_REQUIRE(callContractFunction("setHelper(address)", c_helperAddress) == bytes()); BOOST_REQUIRE(callContractFunction("getHelper()", c_helperAddress) == encodeArgs(c_helperAddress)); - BOOST_CHECK(callContractFunction("callHelper(string2,bool)", string("\0a", 2), true) == encodeArgs(string("\0a\0\0\0", 5))); + BOOST_CHECK(callContractFunction("callHelper(bytes2,bool)", string("\0a", 2), true) == encodeArgs(string("\0a\0\0\0", 5))); } BOOST_AUTO_TEST_CASE(constructor_arguments) { char const* sourceCode = R"( contract Helper { - string3 name; + bytes3 name; bool flag; - function Helper(string3 x, bool f) { + function Helper(bytes3 x, bool f) { name = x; flag = f; } - function getName() returns (string3 ret) { return name; } + function getName() returns (bytes3 ret) { return name; } function getFlag() returns (bool ret) { return flag; } } contract Main { @@ -1574,7 +1574,7 @@ BOOST_AUTO_TEST_CASE(constructor_arguments) h = new Helper("abc", true); } function getFlag() returns (bool ret) { return h.getFlag(); } - function getName() returns (string3 ret) { return h.getName(); } + function getName() returns (bytes3 ret) { return h.getName(); } })"; compileAndRun(sourceCode, 0, "Main"); BOOST_REQUIRE(callContractFunction("getFlag()") == encodeArgs(true)); @@ -1585,13 +1585,13 @@ BOOST_AUTO_TEST_CASE(functions_called_by_constructor) { char const* sourceCode = R"( contract Test { - string3 name; + bytes3 name; bool flag; function Test() { setName("abc"); } - function getName() returns (string3 ret) { return name; } - function setName(string3 _name) private { name = _name; } + function getName() returns (bytes3 ret) { return name; } + function setName(bytes3 _name) private { name = _name; } })"; compileAndRun(sourceCode); BOOST_REQUIRE(callContractFunction("getName()") == encodeArgs("abc")); @@ -1699,13 +1699,13 @@ BOOST_AUTO_TEST_CASE(value_for_constructor) { char const* sourceCode = R"( contract Helper { - string3 name; + bytes3 name; bool flag; - function Helper(string3 x, bool f) { + function Helper(bytes3 x, bool f) { name = x; flag = f; } - function getName() returns (string3 ret) { return name; } + function getName() returns (bytes3 ret) { return name; } function getFlag() returns (bool ret) { return flag; } } contract Main { @@ -1714,7 +1714,7 @@ BOOST_AUTO_TEST_CASE(value_for_constructor) h = new Helper.value(10)("abc", true); } function getFlag() returns (bool ret) { return h.getFlag(); } - function getName() returns (string3 ret) { return h.getName(); } + function getName() returns (bytes3 ret) { return h.getName(); } function getBalances() returns (uint me, uint them) { me = this.balance; them = h.balance;} })"; compileAndRun(sourceCode, 22, "Main"); @@ -2095,10 +2095,10 @@ BOOST_AUTO_TEST_CASE(event) event Deposit(address indexed _from, bytes32 indexed _id, uint _value); function deposit(bytes32 _id, bool _manually) { if (_manually) { - bytes32 s = uint(0x50cb9fe53daa9737b786ab3646f04d0150dc50ef4e75f59509d83667ad5adb20); - log3(msg.value, s, bytes4(msg.sender), _id); + bytes32 s = 0x19dacbf83c5de6658e14cbf7bcae5c15eca2eedecf1c66fbca928e4d351bea0f; + log3(bytes32(msg.value), s, bytes32(msg.sender), _id); } else - Deposit(bytes4(msg.sender), _id, msg.value); + Deposit(msg.sender, _id, msg.value); } } )"; @@ -2107,12 +2107,12 @@ BOOST_AUTO_TEST_CASE(event) u256 id(0x1234); for (bool manually: {true, false}) { - callContractFunctionWithValue("deposit(hash256,bool)", value, id, manually); + callContractFunctionWithValue("deposit(bytes32,bool)", value, id, manually); BOOST_REQUIRE_EQUAL(m_logs.size(), 1); BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress); BOOST_CHECK_EQUAL(h256(m_logs[0].data), h256(u256(value))); BOOST_REQUIRE_EQUAL(m_logs[0].topics.size(), 3); - BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::sha3(string("Deposit(address,hash256,uint256)"))); + BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::sha3(string("Deposit(address,bytes32,uint256)"))); BOOST_CHECK_EQUAL(m_logs[0].topics[1], h256(m_sender)); BOOST_CHECK_EQUAL(m_logs[0].topics[2], h256(id)); } @@ -2141,21 +2141,21 @@ BOOST_AUTO_TEST_CASE(event_lots_of_data) { char const* sourceCode = R"( contract ClientReceipt { - event Deposit(address _from, hash _id, uint _value, bool _flag); - function deposit(hash _id) { - Deposit(msg.sender, hash32(_id), msg.value, true); + event Deposit(address _from, bytes32 _id, uint _value, bool _flag); + function deposit(bytes32 _id) { + Deposit(msg.sender, _id, msg.value, true); } } )"; compileAndRun(sourceCode); u256 value(18); u256 id(0x1234); - callContractFunctionWithValue("deposit(hash256)", value, id); + callContractFunctionWithValue("deposit(bytes32)", value, id); BOOST_REQUIRE_EQUAL(m_logs.size(), 1); BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress); BOOST_CHECK(m_logs[0].data == encodeArgs((u160)m_sender, id, value, true)); BOOST_REQUIRE_EQUAL(m_logs[0].topics.size(), 1); - BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::sha3(string("Deposit(address,hash256,uint256,bool)"))); + BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::sha3(string("Deposit(address,bytes32,uint256,bool)"))); } BOOST_AUTO_TEST_CASE(empty_name_input_parameter_with_named_one) @@ -2189,7 +2189,7 @@ BOOST_AUTO_TEST_CASE(sha3_multiple_arguments) { char const* sourceCode = R"( contract c { - function foo(uint a, uint b, uint c) returns (hash d) + function foo(uint a, uint b, uint c) returns (bytes32 d) { d = sha3(a, b, c); } @@ -2207,7 +2207,7 @@ BOOST_AUTO_TEST_CASE(sha3_multiple_arguments_with_numeric_literals) { char const* sourceCode = R"( contract c { - function foo(uint a, uint16 b) returns (hash d) + function foo(uint a, uint16 b) returns (bytes32 d) { d = sha3(a, b, 145); } @@ -2225,11 +2225,11 @@ BOOST_AUTO_TEST_CASE(sha3_multiple_arguments_with_string_literals) { char const* sourceCode = R"( contract c { - function foo() returns (hash d) + function foo() returns (bytes32 d) { d = sha3("foo"); } - function bar(uint a, uint16 b) returns (hash d) + function bar(uint a, uint16 b) returns (bytes32 d) { d = sha3(a, b, 145, "foo"); } @@ -2256,7 +2256,7 @@ BOOST_AUTO_TEST_CASE(generic_call) contract sender { function doSend(address rec) returns (uint d) { - string4 signature = string4(string32(sha3("receive(uint256)"))); + bytes4 signature = bytes4(bytes32(sha3("receive(uint256)"))); rec.call.value(2)(signature, 23); return receiver(rec).received(); } @@ -2292,7 +2292,7 @@ BOOST_AUTO_TEST_CASE(bytes_from_calldata_to_memory) { char const* sourceCode = R"( contract C { - function() returns (hash) { + function() returns (bytes32) { return sha3("abc", msg.data); } } @@ -3016,6 +3016,7 @@ BOOST_AUTO_TEST_CASE(bytes_index_access) 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33}; + cout << toHex(callContractFunction("direct(bytes,uint256)", u256(array.length()), 32, array)) << endl; BOOST_CHECK(callContractFunction("direct(bytes,uint256)", u256(array.length()), 32, array) == encodeArgs(32)); BOOST_CHECK(callContractFunction("storageCopyRead(bytes,uint256)", u256(array.length()), 32, array) == encodeArgs(32)); BOOST_CHECK(callContractFunction("storageWrite()") == encodeArgs(0x193)); @@ -3183,7 +3184,6 @@ BOOST_AUTO_TEST_CASE(pass_dynamic_arguments_to_the_base_base_with_gap) BOOST_CHECK(callContractFunction("m_i()") == encodeArgs(4)); } - BOOST_AUTO_TEST_SUITE_END() } From 5e42f54f968eab2ca20812b7344577862ab75956 Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Wed, 11 Mar 2015 11:38:11 +0100 Subject: [PATCH 10/33] Changes in Solidity Tests to use the new bytesXX type --- SolidityABIJSON.cpp | 10 +++++----- SolidityInterface.cpp | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/SolidityABIJSON.cpp b/SolidityABIJSON.cpp index 5f67a5667..195270138 100644 --- a/SolidityABIJSON.cpp +++ b/SolidityABIJSON.cpp @@ -339,10 +339,10 @@ BOOST_AUTO_TEST_CASE(inherited) char const* sourceCode = " contract Base { \n" " function baseFunction(uint p) returns (uint i) { return p; } \n" - " event baseEvent(string32 indexed evtArgBase); \n" + " event baseEvent(bytes32 indexed evtArgBase); \n" " } \n" " contract Derived is Base { \n" - " function derivedFunction(string32 p) returns (string32 i) { return p; } \n" + " function derivedFunction(bytes32 p) returns (bytes32 i) { return p; } \n" " event derivedEvent(uint indexed evtArgDerived); \n" " }"; @@ -369,12 +369,12 @@ BOOST_AUTO_TEST_CASE(inherited) "inputs": [{ "name": "p", - "type": "string32" + "type": "bytes32" }], "outputs": [{ "name": "i", - "type": "string32" + "type": "bytes32" }] }, { @@ -394,7 +394,7 @@ BOOST_AUTO_TEST_CASE(inherited) [{ "indexed": true, "name": "evtArgBase", - "type": "string32" + "type": "bytes32" }] }])"; diff --git a/SolidityInterface.cpp b/SolidityInterface.cpp index ecab64c8c..48e2fd7aa 100644 --- a/SolidityInterface.cpp +++ b/SolidityInterface.cpp @@ -84,10 +84,10 @@ BOOST_AUTO_TEST_CASE(single_function) BOOST_AUTO_TEST_CASE(single_constant_function) { ContractDefinition const& contract = checkInterface( - "contract test { function f(uint a) constant returns(hash8 x) { 1==2; } }"); + "contract test { function f(uint a) constant returns(bytes1 x) { 1==2; } }"); BOOST_REQUIRE_EQUAL(1, contract.getDefinedFunctions().size()); BOOST_CHECK_EQUAL(getSourcePart(*contract.getDefinedFunctions().front()), - "function f(uint256 a)constant returns(hash8 x){}"); + "function f(uint256 a)constant returns(bytes1 x){}"); } BOOST_AUTO_TEST_CASE(multiple_functions) @@ -128,15 +128,15 @@ BOOST_AUTO_TEST_CASE(inheritance) char const* sourceCode = " contract Base { \n" " function baseFunction(uint p) returns (uint i) { return p; } \n" - " event baseEvent(string32 indexed evtArgBase); \n" + " event baseEvent(bytes32 indexed evtArgBase); \n" " } \n" " contract Derived is Base { \n" - " function derivedFunction(string32 p) returns (string32 i) { return p; } \n" + " function derivedFunction(bytes32 p) returns (bytes32 i) { return p; } \n" " event derivedEvent(uint indexed evtArgDerived); \n" " }"; ContractDefinition const& contract = checkInterface(sourceCode); set expectedFunctions({"function baseFunction(uint256 p)returns(uint256 i){}", - "function derivedFunction(string32 p)returns(string32 i){}"}); + "function derivedFunction(bytes32 p)returns(bytes32 i){}"}); BOOST_REQUIRE_EQUAL(2, contract.getDefinedFunctions().size()); BOOST_CHECK(expectedFunctions == set({getSourcePart(*contract.getDefinedFunctions().at(0)), getSourcePart(*contract.getDefinedFunctions().at(1))})); From 6e9d0d7345f06595b6890831e3cd80449b4d2201 Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Wed, 11 Mar 2015 16:58:25 +0100 Subject: [PATCH 11/33] Fixing byte array index access code generation --- SolidityEndToEndTest.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/SolidityEndToEndTest.cpp b/SolidityEndToEndTest.cpp index b47048272..c3116a994 100644 --- a/SolidityEndToEndTest.cpp +++ b/SolidityEndToEndTest.cpp @@ -3016,7 +3016,6 @@ BOOST_AUTO_TEST_CASE(bytes_index_access) 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33}; - cout << toHex(callContractFunction("direct(bytes,uint256)", u256(array.length()), 32, array)) << endl; BOOST_CHECK(callContractFunction("direct(bytes,uint256)", u256(array.length()), 32, array) == encodeArgs(32)); BOOST_CHECK(callContractFunction("storageCopyRead(bytes,uint256)", u256(array.length()), 32, array) == encodeArgs(32)); BOOST_CHECK(callContractFunction("storageWrite()") == encodeArgs(0x193)); From f3fc870e03cef67d1a8acc4cf49df574f324212a Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Wed, 11 Mar 2015 17:41:12 +0100 Subject: [PATCH 12/33] byte is now an alias for byte1 --- SolidityNameAndTypeResolution.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/SolidityNameAndTypeResolution.cpp b/SolidityNameAndTypeResolution.cpp index a73c937f9..99a1a8bcb 100644 --- a/SolidityNameAndTypeResolution.cpp +++ b/SolidityNameAndTypeResolution.cpp @@ -1393,6 +1393,16 @@ BOOST_AUTO_TEST_CASE(test_fromElementaryTypeName) BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes32) == *make_shared(32)); } +BOOST_AUTO_TEST_CASE(test_byte_is_alias_of_byte1) +{ + char const* text = R"( + contract c { + bytes arr; + function f() { byte a = arr[0];} + })"; + ETH_TEST_REQUIRE_NO_THROW(parseTextAndResolveNames(text), "Type resolving failed"); +} + BOOST_AUTO_TEST_SUITE_END() } From 0b411d98e9aea631bfbbf10e870800363e8f20dc Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Wed, 11 Mar 2015 18:06:33 +0100 Subject: [PATCH 13/33] Removing uncecessary intermediate int conversion in log tests --- SolidityEndToEndTest.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/SolidityEndToEndTest.cpp b/SolidityEndToEndTest.cpp index c3116a994..1492f03c1 100644 --- a/SolidityEndToEndTest.cpp +++ b/SolidityEndToEndTest.cpp @@ -1189,7 +1189,7 @@ BOOST_AUTO_TEST_CASE(log0) { char const* sourceCode = "contract test {\n" " function a() {\n" - " log0(bytes32(int(1)));\n" + " log0(bytes32(1));\n" " }\n" "}\n"; compileAndRun(sourceCode); @@ -1204,7 +1204,7 @@ BOOST_AUTO_TEST_CASE(log1) { char const* sourceCode = "contract test {\n" " function a() {\n" - " log1(bytes32(int(1)), bytes32(int(2)));\n" + " log1(bytes32(1), bytes32(2));\n" " }\n" "}\n"; compileAndRun(sourceCode); @@ -1220,7 +1220,7 @@ BOOST_AUTO_TEST_CASE(log2) { char const* sourceCode = "contract test {\n" " function a() {\n" - " log2(bytes32(int(1)), bytes32(int(2)), bytes32(int(3)));\n" + " log2(bytes32(1), bytes32(2), bytes32(3));\n" " }\n" "}\n"; compileAndRun(sourceCode); @@ -1237,7 +1237,7 @@ BOOST_AUTO_TEST_CASE(log3) { char const* sourceCode = "contract test {\n" " function a() {\n" - " log3(bytes32(int(1)), bytes32(int(2)), bytes32(int(3)), bytes32(int(4)));\n" + " log3(bytes32(1), bytes32(2), bytes32(3), bytes32(4));\n" " }\n" "}\n"; compileAndRun(sourceCode); @@ -1254,7 +1254,7 @@ BOOST_AUTO_TEST_CASE(log4) { char const* sourceCode = "contract test {\n" " function a() {\n" - " log4(bytes32(int(1)), bytes32(int(2)), bytes32(int(3)), bytes32(int(4)), bytes32(int(5)));\n" + " log4(bytes32(1), bytes32(2), bytes32(3), bytes32(4), bytes32(5));\n" " }\n" "}\n"; compileAndRun(sourceCode); @@ -1271,7 +1271,7 @@ BOOST_AUTO_TEST_CASE(log_in_constructor) { char const* sourceCode = "contract test {\n" " function test() {\n" - " log1(bytes32(int(1)), bytes32(int(2)));\n" + " log1(bytes32(1), bytes32(2));\n" " }\n" "}\n"; compileAndRun(sourceCode); From 3d0f4b0f228126c6636001ae5f4ec425fac5cb0f Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Thu, 12 Mar 2015 12:25:07 +0100 Subject: [PATCH 14/33] Style fixes and some additional hash to bytes32 renaming --- SolidityEndToEndTest.cpp | 2 +- SolidityParser.cpp | 32 ++++++++++++++++---------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/SolidityEndToEndTest.cpp b/SolidityEndToEndTest.cpp index 1492f03c1..5f95709c5 100644 --- a/SolidityEndToEndTest.cpp +++ b/SolidityEndToEndTest.cpp @@ -519,7 +519,7 @@ BOOST_AUTO_TEST_CASE(strings) BOOST_CHECK(callContractFunction("fixed()") == encodeArgs(string("abc\0\xff__", 7))); BOOST_CHECK(callContractFunction("pipeThrough(bytes2,bool)", string("\0\x02", 2), true) == encodeArgs(string("\0\x2", 2), true)); } -# + BOOST_AUTO_TEST_CASE(empty_string_on_stack) { char const* sourceCode = "contract test {\n" diff --git a/SolidityParser.cpp b/SolidityParser.cpp index 608e1707e..cfdb3f95f 100644 --- a/SolidityParser.cpp +++ b/SolidityParser.cpp @@ -83,7 +83,7 @@ BOOST_AUTO_TEST_CASE(empty_function) { char const* text = "contract test {\n" " uint256 stateVar;\n" - " function functionName(hash160 arg1, address addr) constant\n" + " function functionName(bytes20 arg1, address addr) constant\n" " returns (int id)\n" " { }\n" "}\n"; @@ -103,7 +103,7 @@ BOOST_AUTO_TEST_CASE(single_function_param) { char const* text = "contract test {\n" " uint256 stateVar;\n" - " function functionName(hash hashin) returns (hash hashout) {}\n" + " function functionName(bytes32 in) returns (bytes32 out) {}\n" "}\n"; ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed."); } @@ -133,7 +133,7 @@ BOOST_AUTO_TEST_CASE(function_natspec_documentation) char const* text = "contract test {\n" " uint256 stateVar;\n" " /// This is a test function\n" - " function functionName(hash hashin) returns (hash hashout) {}\n" + " function functionName(bytes32 in) returns (bytes32 out) {}\n" "}\n"; ETH_TEST_REQUIRE_NO_THROW(contract = parseText(text), "Parsing failed"); auto functions = contract->getDefinedFunctions(); @@ -148,7 +148,7 @@ BOOST_AUTO_TEST_CASE(function_normal_comments) char const* text = "contract test {\n" " uint256 stateVar;\n" " // We won't see this comment\n" - " function functionName(hash hashin) returns (hash hashout) {}\n" + " function functionName(bytes32 in) returns (bytes32 out) {}\n" "}\n"; ETH_TEST_REQUIRE_NO_THROW(contract = parseText(text), "Parsing failed"); auto functions = contract->getDefinedFunctions(); @@ -164,13 +164,13 @@ BOOST_AUTO_TEST_CASE(multiple_functions_natspec_documentation) char const* text = "contract test {\n" " uint256 stateVar;\n" " /// This is test function 1\n" - " function functionName1(hash hashin) returns (hash hashout) {}\n" + " function functionName1(bytes32 in) returns (bytes32 out) {}\n" " /// This is test function 2\n" - " function functionName2(hash hashin) returns (hash hashout) {}\n" + " function functionName2(bytes32 in) returns (bytes32 out) {}\n" " // nothing to see here\n" - " function functionName3(hash hashin) returns (hash hashout) {}\n" + " function functionName3(bytes32 in) returns (bytes32 out) {}\n" " /// This is test function 4\n" - " function functionName4(hash hashin) returns (hash hashout) {}\n" + " function functionName4(bytes32 in) returns (bytes32 out) {}\n" "}\n"; ETH_TEST_REQUIRE_NO_THROW(contract = parseText(text), "Parsing failed"); auto functions = contract->getDefinedFunctions(); @@ -197,7 +197,7 @@ BOOST_AUTO_TEST_CASE(multiline_function_documentation) " uint256 stateVar;\n" " /// This is a test function\n" " /// and it has 2 lines\n" - " function functionName1(hash hashin) returns (hash hashout) {}\n" + " function functionName1(bytes32 in) returns (bytes32 out) {}\n" "}\n"; ETH_TEST_REQUIRE_NO_THROW(contract = parseText(text), "Parsing failed"); auto functions = contract->getDefinedFunctions(); @@ -217,12 +217,12 @@ BOOST_AUTO_TEST_CASE(natspec_comment_in_function_body) " var b;\n" " /// I should not interfere with actual natspec comments\n" " uint256 c;\n" - " mapping(address=>hash) d;\n" + " mapping(address=>bytes32) d;\n" " string name = \"Solidity\";" " }\n" " /// This is a test function\n" " /// and it has 2 lines\n" - " function fun(hash hashin) returns (hash hashout) {}\n" + " function fun(bytes32 in) returns (bytes32 out) {}\n" "}\n"; ETH_TEST_REQUIRE_NO_THROW(contract = parseText(text), "Parsing failed"); auto functions = contract->getDefinedFunctions(); @@ -246,7 +246,7 @@ BOOST_AUTO_TEST_CASE(natspec_docstring_between_keyword_and_signature) " var b;\n" " /// I should not interfere with actual natspec comments\n" " uint256 c;\n" - " mapping(address=>hash) d;\n" + " mapping(address=>bytes32) d;\n" " string name = \"Solidity\";" " }\n" "}\n"; @@ -269,7 +269,7 @@ BOOST_AUTO_TEST_CASE(natspec_docstring_after_signature) " var b;\n" " /// I should not interfere with actual natspec comments\n" " uint256 c;\n" - " mapping(address=>hash) d;\n" + " mapping(address=>bytes32) d;\n" " string name = \"Solidity\";" " }\n" "}\n"; @@ -330,7 +330,7 @@ BOOST_AUTO_TEST_CASE(variable_definition) " function fun(uint256 a) {\n" " var b;\n" " uint256 c;\n" - " mapping(address=>hash) d;\n" + " mapping(address=>bytes32) d;\n" " customtype varname;\n" " }\n" "}\n"; @@ -343,7 +343,7 @@ BOOST_AUTO_TEST_CASE(variable_definition_with_initialization) " function fun(uint256 a) {\n" " var b = 2;\n" " uint256 c = 0x87;\n" - " mapping(address=>hash) d;\n" + " mapping(address=>bytes32) d;\n" " string name = \"Solidity\";" " customtype varname;\n" " }\n" @@ -366,7 +366,7 @@ BOOST_AUTO_TEST_CASE(variable_definition_in_mapping) char const* text = R"( contract test { function fun() { - mapping(var=>hash) d; + mapping(var=>bytes32) d; } } )"; From c89413f6ea0e755808ac46f12b53965a28948ace Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Thu, 12 Mar 2015 13:39:12 +0100 Subject: [PATCH 15/33] Some fixes on Types.cpp for FixedBytesType --- SolidityParser.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/SolidityParser.cpp b/SolidityParser.cpp index cfdb3f95f..2f5d06ef6 100644 --- a/SolidityParser.cpp +++ b/SolidityParser.cpp @@ -103,7 +103,7 @@ BOOST_AUTO_TEST_CASE(single_function_param) { char const* text = "contract test {\n" " uint256 stateVar;\n" - " function functionName(bytes32 in) returns (bytes32 out) {}\n" + " function functionName(bytes32 input) returns (bytes32 out) {}\n" "}\n"; ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed."); } @@ -133,7 +133,7 @@ BOOST_AUTO_TEST_CASE(function_natspec_documentation) char const* text = "contract test {\n" " uint256 stateVar;\n" " /// This is a test function\n" - " function functionName(bytes32 in) returns (bytes32 out) {}\n" + " function functionName(bytes32 input) returns (bytes32 out) {}\n" "}\n"; ETH_TEST_REQUIRE_NO_THROW(contract = parseText(text), "Parsing failed"); auto functions = contract->getDefinedFunctions(); @@ -148,7 +148,7 @@ BOOST_AUTO_TEST_CASE(function_normal_comments) char const* text = "contract test {\n" " uint256 stateVar;\n" " // We won't see this comment\n" - " function functionName(bytes32 in) returns (bytes32 out) {}\n" + " function functionName(bytes32 input) returns (bytes32 out) {}\n" "}\n"; ETH_TEST_REQUIRE_NO_THROW(contract = parseText(text), "Parsing failed"); auto functions = contract->getDefinedFunctions(); @@ -164,13 +164,13 @@ BOOST_AUTO_TEST_CASE(multiple_functions_natspec_documentation) char const* text = "contract test {\n" " uint256 stateVar;\n" " /// This is test function 1\n" - " function functionName1(bytes32 in) returns (bytes32 out) {}\n" + " function functionName1(bytes32 input) returns (bytes32 out) {}\n" " /// This is test function 2\n" - " function functionName2(bytes32 in) returns (bytes32 out) {}\n" + " function functionName2(bytes32 input) returns (bytes32 out) {}\n" " // nothing to see here\n" - " function functionName3(bytes32 in) returns (bytes32 out) {}\n" + " function functionName3(bytes32 input) returns (bytes32 out) {}\n" " /// This is test function 4\n" - " function functionName4(bytes32 in) returns (bytes32 out) {}\n" + " function functionName4(bytes32 input) returns (bytes32 out) {}\n" "}\n"; ETH_TEST_REQUIRE_NO_THROW(contract = parseText(text), "Parsing failed"); auto functions = contract->getDefinedFunctions(); @@ -197,7 +197,7 @@ BOOST_AUTO_TEST_CASE(multiline_function_documentation) " uint256 stateVar;\n" " /// This is a test function\n" " /// and it has 2 lines\n" - " function functionName1(bytes32 in) returns (bytes32 out) {}\n" + " function functionName1(bytes32 input) returns (bytes32 out) {}\n" "}\n"; ETH_TEST_REQUIRE_NO_THROW(contract = parseText(text), "Parsing failed"); auto functions = contract->getDefinedFunctions(); @@ -218,11 +218,11 @@ BOOST_AUTO_TEST_CASE(natspec_comment_in_function_body) " /// I should not interfere with actual natspec comments\n" " uint256 c;\n" " mapping(address=>bytes32) d;\n" - " string name = \"Solidity\";" + " bytes7 name = \"Solidity\";" " }\n" " /// This is a test function\n" " /// and it has 2 lines\n" - " function fun(bytes32 in) returns (bytes32 out) {}\n" + " function fun(bytes32 input) returns (bytes32 out) {}\n" "}\n"; ETH_TEST_REQUIRE_NO_THROW(contract = parseText(text), "Parsing failed"); auto functions = contract->getDefinedFunctions(); @@ -247,7 +247,7 @@ BOOST_AUTO_TEST_CASE(natspec_docstring_between_keyword_and_signature) " /// I should not interfere with actual natspec comments\n" " uint256 c;\n" " mapping(address=>bytes32) d;\n" - " string name = \"Solidity\";" + " bytes7 name = \"Solidity\";" " }\n" "}\n"; ETH_TEST_REQUIRE_NO_THROW(contract = parseText(text), "Parsing failed"); @@ -270,7 +270,7 @@ BOOST_AUTO_TEST_CASE(natspec_docstring_after_signature) " /// I should not interfere with actual natspec comments\n" " uint256 c;\n" " mapping(address=>bytes32) d;\n" - " string name = \"Solidity\";" + " bytes7 name = \"Solidity\";" " }\n" "}\n"; ETH_TEST_REQUIRE_NO_THROW(contract = parseText(text), "Parsing failed"); @@ -296,7 +296,7 @@ BOOST_AUTO_TEST_CASE(struct_definition) BOOST_AUTO_TEST_CASE(mapping) { char const* text = "contract test {\n" - " mapping(address => string) names;\n" + " mapping(address => bytes32) names;\n" "}\n"; ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); } @@ -344,7 +344,7 @@ BOOST_AUTO_TEST_CASE(variable_definition_with_initialization) " var b = 2;\n" " uint256 c = 0x87;\n" " mapping(address=>bytes32) d;\n" - " string name = \"Solidity\";" + " bytes7 name = \"Solidity\";" " customtype varname;\n" " }\n" "}\n"; @@ -662,7 +662,7 @@ BOOST_AUTO_TEST_CASE(event_arguments) { char const* text = R"( contract c { - event e(uint a, string32 s); + event e(uint a, bytes32 s); })"; ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); } @@ -671,7 +671,7 @@ BOOST_AUTO_TEST_CASE(event_arguments_indexed) { char const* text = R"( contract c { - event e(uint a, string32 indexed s, bool indexed b); + event e(uint a, bytes32 indexed s, bool indexed b); })"; ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); } @@ -799,7 +799,7 @@ BOOST_AUTO_TEST_CASE(arrays_in_events) { char const* text = R"( contract c { - event e(uint[10] a, string7[8] indexed b, c[3] x); + event e(uint[10] a, bytes7[8] indexed b, c[3] x); })"; ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); } From 08bc97766032b95e630095a6efe0c76997bc062f Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Thu, 12 Mar 2015 14:33:00 +0100 Subject: [PATCH 16/33] style --- checkRandomStateTest.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/checkRandomStateTest.cpp b/checkRandomStateTest.cpp index ed12b7dc4..9cd42dfd3 100644 --- a/checkRandomStateTest.cpp +++ b/checkRandomStateTest.cpp @@ -125,8 +125,6 @@ bool doStateTest(mValue& _v) return 1; } - - // check logs //checkLog(theState.pending().size() ? theState.log(0) : LogEntries(), importer.m_environment.sub.logs); eth::LogEntries logs = theState.pending().size() ? theState.log(0) : eth::LogEntries(); @@ -219,7 +217,6 @@ bool doStateTest(mValue& _v) } if(expectedAddrs != resultAddrs) return 1; - #endif if(theState.rootHash() != h256(o["postStateRoot"].get_str()), "wrong post state root") return 1; From 1bb7f3cbc3737bbdf6653d3721d01dc95a217707 Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Thu, 12 Mar 2015 17:31:39 +0100 Subject: [PATCH 17/33] Small FixedBytes type fixes - Integer Constant is explicitly convertible to FixedBytes, so using that in the tests --- SolidityEndToEndTest.cpp | 16 +++++++--------- SolidityNameAndTypeResolution.cpp | 1 + 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/SolidityEndToEndTest.cpp b/SolidityEndToEndTest.cpp index 5f95709c5..2f965849b 100644 --- a/SolidityEndToEndTest.cpp +++ b/SolidityEndToEndTest.cpp @@ -1182,14 +1182,12 @@ BOOST_AUTO_TEST_CASE(send_ether) BOOST_CHECK(callContractFunction("a(address,uint256)", address, amount) == encodeArgs(1)); BOOST_CHECK_EQUAL(m_state.balance(address), amount); } -// TODO: Note that these tests should actually be -// simply converting integer constant to bytes32. This conversion is not there -// yet. When it's implemented DO change the tests too + BOOST_AUTO_TEST_CASE(log0) { char const* sourceCode = "contract test {\n" " function a() {\n" - " log0(bytes32(1));\n" + " log0(1);\n" " }\n" "}\n"; compileAndRun(sourceCode); @@ -1204,7 +1202,7 @@ BOOST_AUTO_TEST_CASE(log1) { char const* sourceCode = "contract test {\n" " function a() {\n" - " log1(bytes32(1), bytes32(2));\n" + " log1(1, 2);\n" " }\n" "}\n"; compileAndRun(sourceCode); @@ -1220,7 +1218,7 @@ BOOST_AUTO_TEST_CASE(log2) { char const* sourceCode = "contract test {\n" " function a() {\n" - " log2(bytes32(1), bytes32(2), bytes32(3));\n" + " log2(1, 2, 3);\n" " }\n" "}\n"; compileAndRun(sourceCode); @@ -1237,7 +1235,7 @@ BOOST_AUTO_TEST_CASE(log3) { char const* sourceCode = "contract test {\n" " function a() {\n" - " log3(bytes32(1), bytes32(2), bytes32(3), bytes32(4));\n" + " log3(1, 2, 3, 4);\n" " }\n" "}\n"; compileAndRun(sourceCode); @@ -1254,7 +1252,7 @@ BOOST_AUTO_TEST_CASE(log4) { char const* sourceCode = "contract test {\n" " function a() {\n" - " log4(bytes32(1), bytes32(2), bytes32(3), bytes32(4), bytes32(5));\n" + " log4(1, 2, 3, 4, 5);\n" " }\n" "}\n"; compileAndRun(sourceCode); @@ -1271,7 +1269,7 @@ BOOST_AUTO_TEST_CASE(log_in_constructor) { char const* sourceCode = "contract test {\n" " function test() {\n" - " log1(bytes32(1), bytes32(2));\n" + " log1(1, 2);\n" " }\n" "}\n"; compileAndRun(sourceCode); diff --git a/SolidityNameAndTypeResolution.cpp b/SolidityNameAndTypeResolution.cpp index 99a1a8bcb..a310800f7 100644 --- a/SolidityNameAndTypeResolution.cpp +++ b/SolidityNameAndTypeResolution.cpp @@ -1358,6 +1358,7 @@ BOOST_AUTO_TEST_CASE(test_fromElementaryTypeName) BOOST_CHECK(*Type::fromElementaryTypeName(Token::UInt248) == *make_shared(248, IntegerType::Modifier::Unsigned)); BOOST_CHECK(*Type::fromElementaryTypeName(Token::UInt256) == *make_shared(256, IntegerType::Modifier::Unsigned)); + BOOST_CHECK(*Type::fromElementaryTypeName(Token::Byte) == *make_shared(1)); BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes0) == *make_shared(0)); BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes1) == *make_shared(1)); BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes2) == *make_shared(2)); From 20cb72b297caccd95e4cb7349076277caf1d9ab1 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Thu, 12 Mar 2015 17:44:57 +0100 Subject: [PATCH 18/33] bugfix --- checkRandomStateTest.cpp | 5 ++++- createRandomStateTest.cpp | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/checkRandomStateTest.cpp b/checkRandomStateTest.cpp index 9cd42dfd3..601ef1ca9 100644 --- a/checkRandomStateTest.cpp +++ b/checkRandomStateTest.cpp @@ -218,8 +218,11 @@ bool doStateTest(mValue& _v) if(expectedAddrs != resultAddrs) return 1; #endif - if(theState.rootHash() != h256(o["postStateRoot"].get_str()), "wrong post state root") + if(theState.rootHash() != h256(o["postStateRoot"].get_str())) + { + cout << "wrong post state root" << endl; return 1; + } } return 0; } diff --git a/createRandomStateTest.cpp b/createRandomStateTest.cpp index 6b24f1216..f9baa0091 100644 --- a/createRandomStateTest.cpp +++ b/createRandomStateTest.cpp @@ -86,8 +86,8 @@ int main(int argc, char *argv[]) { "randomStatetest" : { "env" : { - "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", - "currentDifficulty" : "0x945304eb96065b2a98b57a48a06ae28d285a71b5", + "currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5", + "currentDifficulty" : "5623894562375", "currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935", "currentNumber" : "0", "currentTimestamp" : "1", From 363d41738470ad4754973352b18114641c345c0a Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Thu, 12 Mar 2015 19:01:09 +0100 Subject: [PATCH 19/33] style --- createRandomStateTest.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/createRandomStateTest.cpp b/createRandomStateTest.cpp index f9baa0091..13b622bb1 100644 --- a/createRandomStateTest.cpp +++ b/createRandomStateTest.cpp @@ -58,10 +58,8 @@ int main(int argc, char *argv[]) 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 > randGen(gen, opcodeDist); - boost::random::variate_generator > randGenBlockInfoOpcode(gen, BlockInfoOpcodeDist); + boost::random::variate_generator > randGen(gen, opcodeDist); + boost::random::variate_generator > randGenBlockInfoOpcode(gen, BlockInfoOpcodeDist); int lengthOfCode = lengthOfCodeDist(gen); string randomCode; From 6243d0048bb9424388bca6970a11a865b18239c3 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Thu, 12 Mar 2015 19:03:07 +0100 Subject: [PATCH 20/33] style --- checkRandomStateTest.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/checkRandomStateTest.cpp b/checkRandomStateTest.cpp index 601ef1ca9..17e785f60 100644 --- a/checkRandomStateTest.cpp +++ b/checkRandomStateTest.cpp @@ -215,10 +215,10 @@ bool doStateTest(mValue& _v) if (expectedAddrIt == expectedAddrs.end()) return 1; } - if(expectedAddrs != resultAddrs) + if (expectedAddrs != resultAddrs) return 1; #endif - if(theState.rootHash() != h256(o["postStateRoot"].get_str())) + if (theState.rootHash() != h256(o["postStateRoot"].get_str())) { cout << "wrong post state root" << endl; return 1; From 1d93fc79f4af8bcd499bd75a2e525112ef276404 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 13 Mar 2015 12:29:59 +0100 Subject: [PATCH 21/33] fix calldataload --- vmEnvironmentalInfoTestFiller.json | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/vmEnvironmentalInfoTestFiller.json b/vmEnvironmentalInfoTestFiller.json index d9e1ef654..951e65c32 100644 --- a/vmEnvironmentalInfoTestFiller.json +++ b/vmEnvironmentalInfoTestFiller.json @@ -367,6 +367,34 @@ } }, + "calldataload_BigOffset": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "1000000", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "100000000000000000000000", + "nonce" : "0", + "code" : "{ [[ 0 ]] (CALLDATALOAD 0x4200000000000000000000000000000000000000000000000000000000000000)}", + "storage": {} + } + }, + "exec" : { + "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "value" : "1000000000000000000", + "data" : "0x4200000000000000000000000000000000000000000000000000000000000000", + "gasPrice" : "1000000000", + "gas" : "100000000000" + } + }, + "calldataload1": { "env" : { "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", From 9da83dc6d2d26c43a5aa53fda4fc105f7d3c2862 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 13 Mar 2015 13:04:05 +0100 Subject: [PATCH 22/33] add addmod test in order toc check that nothing get downcasted inbetween --- vmArithmeticTestFiller.json | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/vmArithmeticTestFiller.json b/vmArithmeticTestFiller.json index 16e085a12..1aae823bd 100644 --- a/vmArithmeticTestFiller.json +++ b/vmArithmeticTestFiller.json @@ -1485,6 +1485,34 @@ } }, + "addmodBigIntCast": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "1000000", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ [[ 0 ]] (ADDMOD 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 1 5) } ", + "storage": {} + } + }, + "exec" : { + "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", + "value" : "1000000000000000000", + "data" : "", + "gasPrice" : "100000000000000", + "gas" : "100000" + } + }, + "addmod1_overflow2": { "env" : { "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", From f72e8d93a675fa312e7ae1fd1a0c740bdfb3f96f Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 13 Mar 2015 14:58:47 +0100 Subject: [PATCH 23/33] remove seedhash from block header tests --- bcBlockChainTestFiller.json | 1 - bcInvalidHeaderTestFiller.json | 14 -------------- bcUncleTestFiller.json | 13 ------------- bcValidBlockTestFiller.json | 8 -------- blockchain.cpp | 2 +- 5 files changed, 1 insertion(+), 37 deletions(-) diff --git a/bcBlockChainTestFiller.json b/bcBlockChainTestFiller.json index b149f5938..ed70a5296 100644 --- a/bcBlockChainTestFiller.json +++ b/bcBlockChainTestFiller.json @@ -13,7 +13,6 @@ "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", "timestamp" : "0x54c98c81", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" diff --git a/bcInvalidHeaderTestFiller.json b/bcInvalidHeaderTestFiller.json index 39a91a583..da3d13163 100644 --- a/bcInvalidHeaderTestFiller.json +++ b/bcInvalidHeaderTestFiller.json @@ -8,7 +8,6 @@ "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", @@ -64,7 +63,6 @@ "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", @@ -120,7 +118,6 @@ "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", @@ -175,7 +172,6 @@ "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", @@ -230,7 +226,6 @@ "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", @@ -285,7 +280,6 @@ "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", @@ -341,7 +335,6 @@ "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", @@ -396,7 +389,6 @@ "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", @@ -451,7 +443,6 @@ "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", @@ -506,7 +497,6 @@ "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", @@ -561,7 +551,6 @@ "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", @@ -616,7 +605,6 @@ "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", @@ -671,7 +659,6 @@ "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", @@ -726,7 +713,6 @@ "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", diff --git a/bcUncleTestFiller.json b/bcUncleTestFiller.json index 73d1e5487..5fb466967 100644 --- a/bcUncleTestFiller.json +++ b/bcUncleTestFiller.json @@ -13,7 +13,6 @@ "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", "timestamp" : "0x54c98c81", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" @@ -68,7 +67,6 @@ "number" : "1", "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", "timestamp" : "0x54c98c82", "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -93,7 +91,6 @@ "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", "timestamp" : "0x54c98c81", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" @@ -163,7 +160,6 @@ "number" : "2", "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", "timestamp" : "0x54c98c82", "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -188,7 +184,6 @@ "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", "timestamp" : "0x54c98c81", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" @@ -258,7 +253,6 @@ "number" : "2", "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", "timestamp" : "0x54c98c82", "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -286,7 +280,6 @@ "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", "timestamp" : "0x54c98c81", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" @@ -356,7 +349,6 @@ "number" : "2", "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", "timestamp" : "0x54c98c82", "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -375,7 +367,6 @@ "number" : "2", "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", "timestamp" : "0x54c98c82", "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -400,7 +391,6 @@ "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", "timestamp" : "0x54c98c81", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" @@ -470,7 +460,6 @@ "number" : "2", "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", "timestamp" : "0x54c98c82", "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -489,7 +478,6 @@ "number" : "2", "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", "timestamp" : "0x54c98c82", "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -508,7 +496,6 @@ "number" : "2", "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", "timestamp" : "0x54c98c82", "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", diff --git a/bcValidBlockTestFiller.json b/bcValidBlockTestFiller.json index 14d4cfb2c..e184a0849 100644 --- a/bcValidBlockTestFiller.json +++ b/bcValidBlockTestFiller.json @@ -9,7 +9,6 @@ "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", @@ -56,7 +55,6 @@ "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", @@ -102,7 +100,6 @@ "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", @@ -148,7 +145,6 @@ "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", @@ -194,7 +190,6 @@ "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", @@ -249,7 +244,6 @@ "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", @@ -304,7 +298,6 @@ "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", @@ -356,7 +349,6 @@ "gasLimit" : "125000", "gasUsed" : "100", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0xefb4db878627027c81b3bb1c7dd3a18dae3914a49cdd24a3e40ab3bbfbb240c5", diff --git a/blockchain.cpp b/blockchain.cpp index 045f2de5b..b86cd7833 100644 --- a/blockchain.cpp +++ b/blockchain.cpp @@ -386,7 +386,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) { mObject uBlH = uBlHeaderObj.get_obj(); cout << "uBlH.size(): " << uBlH.size() << endl; - BOOST_REQUIRE(uBlH.size() == 17); + BOOST_REQUIRE(uBlH.size() == 16); bytes uncleRLP = createBlockRLPFromFields(uBlH); const RLP c_uRLP(uncleRLP); BlockInfo uncleBlockHeader; From 132533babb710cc3c210550c1f70b1f13aa6fcb4 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 13 Mar 2015 15:35:32 +0100 Subject: [PATCH 24/33] clean up --- blockchain.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/blockchain.cpp b/blockchain.cpp index b86cd7833..ac872c0f3 100644 --- a/blockchain.cpp +++ b/blockchain.cpp @@ -533,7 +533,7 @@ void overwriteBlockHeader(BlockInfo& _current_BlockHeader, mObject& _blObj) std::pair ret; while (!ProofOfWork::verify(_current_BlockHeader)) { - ret = pow.mine(_current_BlockHeader, 1000, true, true); // tie(ret, blockFromFields.nonce) + ret = pow.mine(_current_BlockHeader, 1000, true, true); Ethash::assignResult(ret.second, _current_BlockHeader); } } @@ -580,7 +580,7 @@ void updatePoW(BlockInfo& _bi) std::pair ret; while (!ProofOfWork::verify(_bi)) { - ret = pow.mine(_bi, 10000, true, true); // tie(ret, blockFromFields.nonce) + ret = pow.mine(_bi, 10000, true, true); Ethash::assignResult(ret.second, _bi); } _bi.hash = _bi.headerHash(WithNonce); From 60162d919b28549a6fee59f9a08309743c6548fe Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Fri, 13 Mar 2015 16:13:43 +0100 Subject: [PATCH 25/33] Squashed 'libjsqrc/ethereumjs/' changes from d509360..eceeda7 eceeda7 gulp cc3e373 Merge pull request #109 from LefterisJP/string_hash_rename 3a22498 string type basically becomes bytes type 760634a Changing abi tests to use fixed bytes type 6554479 Merge pull request #108 from frozeman/apiOverhaul b322378 removed unecessary utils 9a3d320 changed my author url 8516a2f removed uncommented line 1730f21 add version replacement use version.json now 27e5706 bumped version 3614cea bumped version 9c3d1b2 merged develop 2e320ed add versions 08a38b3 removed unecessary open in httpprovidor 5636510 add inputformatter for sha3 50ca903 add build f351e95 removed unecessary log 67ab5ef removed unecessary log git-subtree-dir: libjsqrc/ethereumjs git-subtree-split: eceeda7d0878579cdc6324f3026ae88079c30720 --- abi.inputParser.js | 66 +++++------------------------------------ abi.outputParser.js | 72 +++++---------------------------------------- db.methods.js | 4 +-- 3 files changed, 17 insertions(+), 125 deletions(-) diff --git a/abi.inputParser.js b/abi.inputParser.js index 2ee87761f..1d3a869e3 100644 --- a/abi.inputParser.js +++ b/abi.inputParser.js @@ -227,56 +227,6 @@ describe('abi', function() { }); - it('should parse input hash', function() { - - // given - var d = clone(description); - - d[0].inputs = [ - { type: "hash" } - ]; - - // when - var parser = abi.inputParser(d); - - // then - assert.equal(parser.test("0x407d73d8a49eeb85d32cf465507dd71d507100c1"), "000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1"); - - }); - - it('should parse input hash256', function() { - - // given - var d = clone(description); - - d[0].inputs = [ - { type: "hash256" } - ]; - - // when - var parser = abi.inputParser(d); - - // then - assert.equal(parser.test("0x407d73d8a49eeb85d32cf465507dd71d507100c1"), "000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1"); - - }); - - - it('should parse input hash160', function() { - // given - var d = clone(description); - - d[0].inputs = [ - { type: "hash160" } - ]; - - // when - var parser = abi.inputParser(d); - - // then - assert.equal(parser.test("0x407d73d8a49eeb85d32cf465507dd71d507100c1"), "000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1"); - }); - it('should parse input address', function () { // given @@ -294,13 +244,13 @@ describe('abi', function() { }); - it('should parse input string', function () { + it('should parse input fixed bytes type', function () { // given var d = clone(description); d[0].inputs = [ - { type: "string" } + { type: "bytes" } ]; // when @@ -318,14 +268,14 @@ describe('abi', function() { ); }); - it('should parse input int followed by a string', function () { + it('should parse input int followed by a fixed bytes type', function () { // given var d = clone(description); d[0].inputs = [ { type: "int" }, - { type: "string" } + { type: "bytes" } ]; // when @@ -340,13 +290,13 @@ describe('abi', function() { ); }); - it('should parse input string followed by an int', function () { + it('should parse input fixed bytes type followed by an int', function () { // given var d = clone(description); d[0].inputs = [ - { type: "string" }, + { type: "bytes" }, { type: "int" } ]; @@ -391,8 +341,8 @@ describe('abi', function() { },{ name: "test2", type: "function", - inputs: [{ type: "string" }], - outputs: [{ type: "string" }] + inputs: [{ type: "bytes" }], + outputs: [{ type: "bytes" }] }]; // when diff --git a/abi.outputParser.js b/abi.outputParser.js index 1ddd9d4fd..955c0d5f1 100644 --- a/abi.outputParser.js +++ b/abi.outputParser.js @@ -21,13 +21,13 @@ var description = [{ describe('abi', function() { describe('outputParser', function() { - it('should parse output string', function() { + it('should parse output fixed bytes type', function() { // given var d = clone(description); d[0].outputs = [ - { type: "string" } + { type: "bytes" } ]; // when @@ -181,64 +181,6 @@ describe('abi', function() { assert.equal(parser.test("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0")[0], -16); }); - it('should parse output hash', function() { - - // given - var d = clone(description); - - d[0].outputs = [ - { type: 'hash' } - ]; - - // when - var parser = abi.outputParser(d); - - // then - assert.equal( - parser.test("0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1")[0], - "0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1" - ); - }); - - it('should parse output hash256', function() { - - // given - var d = clone(description); - - d[0].outputs = [ - { type: 'hash256' } - ]; - - // when - var parser = abi.outputParser(d); - - // then - assert.equal( - parser.test("0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1")[0], - "0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1" - ); - }); - - it('should parse output hash160', function() { - - // given - var d = clone(description); - - d[0].outputs = [ - { type: 'hash160' } - ]; - - // when - var parser = abi.outputParser(d); - - // then - assert.equal( - parser.test("0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1")[0], - "0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1" - ); - // TODO shouldnt' the expected hash be shorter? - }); - it('should parse output address', function() { // given @@ -317,14 +259,14 @@ describe('abi', function() { }); - it('should parse multiple output strings', function() { + it('should parse multiple output fixed bytes type', function() { // given var d = clone(description); d[0].outputs = [ - { type: "string" }, - { type: "string" } + { type: "bytes" }, + { type: "bytes" } ]; // when @@ -380,8 +322,8 @@ describe('abi', function() { },{ name: "test2", type: "function", - inputs: [{ type: "string" }], - outputs: [{ type: "string" }] + inputs: [{ type: "bytes" }], + outputs: [{ type: "bytes" }] }]; // when diff --git a/db.methods.js b/db.methods.js index 2ad384579..aac8981d2 100644 --- a/db.methods.js +++ b/db.methods.js @@ -5,8 +5,8 @@ var u = require('./test.utils.js'); describe('web3', function() { describe('db', function() { - u.methodExists(web3.db, 'put'); - u.methodExists(web3.db, 'get'); + u.methodExists(web3.db, 'putHex'); + u.methodExists(web3.db, 'getHex'); u.methodExists(web3.db, 'putString'); u.methodExists(web3.db, 'getString'); }); From a6f328a613718601c3507923996813a9e50988d5 Mon Sep 17 00:00:00 2001 From: chriseth Date: Fri, 13 Mar 2015 13:14:51 +0100 Subject: [PATCH 26/33] Fix gas for builtin. Fixes #1300 --- SolidityEndToEndTest.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/SolidityEndToEndTest.cpp b/SolidityEndToEndTest.cpp index 2f965849b..07ad3edbc 100644 --- a/SolidityEndToEndTest.cpp +++ b/SolidityEndToEndTest.cpp @@ -1647,6 +1647,21 @@ BOOST_AUTO_TEST_CASE(gas_and_value_basic) BOOST_REQUIRE(callContractFunction("checkState()", 5) == encodeArgs(false, 20 - 5)); } +BOOST_AUTO_TEST_CASE(gas_for_builtin) +{ + char const* sourceCode = R"( + contract Contract { + function test(uint g) returns (bytes32 data, bool flag) { + data = ripemd160.gas(g)("abc"); + flag = true; + } + } + )"; + compileAndRun(sourceCode); + BOOST_CHECK(callContractFunction("test(uint256)", 500) == bytes()); + BOOST_CHECK(callContractFunction("test(uint256)", 800) == encodeArgs(u256("0x8eb208f7e05d987a9b044a8e98c6b087f15a0bfc"), true)); +} + BOOST_AUTO_TEST_CASE(value_complex) { char const* sourceCode = R"( From 31db4fbde86ede91b3af9336d7632e4c700960d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Fri, 13 Mar 2015 11:19:26 +0100 Subject: [PATCH 27/33] Stats for testeth Simple listener support added to testeth. Stats class implements the Listener interface and collects tests execution times. Try options: --stats or --stats=full. Closes ethereum/cpp-ethereum#1285 --- CMakeLists.txt | 8 ++++---- TestHelper.cpp | 28 ++++++++++++++++++++++++++++ TestHelper.h | 30 +++++++++++++++++++++++++++++- state.cpp | 21 ++++----------------- vm.cpp | 39 +++++++++------------------------------ 5 files changed, 74 insertions(+), 52 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d7761b8d3..ef292c2bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,10 +19,10 @@ include_directories(${JSON_RPC_CPP_INCLUDE_DIRS}) file(GLOB HEADERS "*.h") add_executable(testeth ${SRC_LIST} ${HEADERS}) -add_executable(createRandomVMTest createRandomVMTest.cpp vm.cpp TestHelper.cpp) -add_executable(createRandomStateTest createRandomStateTest.cpp TestHelper.cpp) -add_executable(checkRandomVMTest checkRandomVMTest.cpp vm.cpp TestHelper.cpp) -add_executable(checkRandomStateTest checkRandomStateTest.cpp TestHelper.cpp) +add_executable(createRandomVMTest createRandomVMTest.cpp vm.cpp TestHelper.cpp Stats.cpp) +add_executable(createRandomStateTest createRandomStateTest.cpp TestHelper.cpp Stats.cpp) +add_executable(checkRandomVMTest checkRandomVMTest.cpp vm.cpp TestHelper.cpp Stats.cpp) +add_executable(checkRandomStateTest checkRandomStateTest.cpp TestHelper.cpp Stats.cpp) target_link_libraries(testeth ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES}) target_link_libraries(testeth ${CURL_LIBRARIES}) diff --git a/TestHelper.cpp b/TestHelper.cpp index ddc929e4e..72fecf593 100644 --- a/TestHelper.cpp +++ b/TestHelper.cpp @@ -551,6 +551,10 @@ Options::Options() vmtrace = true; else if (arg == "--filltests") fillTests = true; + else if (arg == "--stats") + stats = true; + else if (arg == "--stats=full") + stats = statsFull = true; else if (arg == "--performance") performance = true; else if (arg == "--quadratic") @@ -578,6 +582,7 @@ Options const& Options::get() return instance; } + LastHashes lastHashes(u256 _currentBlockNumber) { LastHashes ret; @@ -586,4 +591,27 @@ LastHashes lastHashes(u256 _currentBlockNumber) return ret; } + +namespace +{ + Listener* g_listener; +} + +void Listener::registerListener(Listener& _listener) +{ + g_listener = &_listener; +} + +void Listener::notifyTestStarted(std::string const& _name) +{ + if (g_listener) + g_listener->testStarted(_name); +} + +void Listener::notifyTestFinished() +{ + if (g_listener) + g_listener->testFinished(); +} + } } // namespaces diff --git a/TestHelper.h b/TestHelper.h index 9efed0fa6..ade20f5e4 100644 --- a/TestHelper.h +++ b/TestHelper.h @@ -162,8 +162,9 @@ class Options public: bool jit = false; ///< Use JIT bool vmtrace = false; ///< Create EVM execution tracer // TODO: Link with log verbosity? - bool showTimes = false; ///< Print test groups execution times bool fillTests = false; ///< Create JSON test files from execution results + bool stats = false; ///< Execution time stats + bool statsFull = false; ///< Output full stats - execution times for every test /// Test selection /// @{ @@ -183,5 +184,32 @@ private: Options(Options const&) = delete; }; +/// Allows observing test execution process. +/// This class also provides methods for registering and notifying the listener +class Listener +{ +public: + virtual ~Listener() = default; + + virtual void testStarted(std::string const& _name) = 0; + virtual void testFinished() = 0; + + static void registerListener(Listener& _listener); + static void notifyTestStarted(std::string const& _name); + static void notifyTestFinished(); + + /// Test started/finished notification RAII helper + class ExecTimeGuard + { + public: + ExecTimeGuard(std::string const& _testName) { notifyTestStarted(_testName); } + ~ExecTimeGuard() { notifyTestFinished(); } + ExecTimeGuard(ExecTimeGuard const&) = delete; + ExecTimeGuard& operator=(ExecTimeGuard) = delete; + }; +}; + + + } } diff --git a/state.cpp b/state.cpp index d6790029a..8c191aa70 100644 --- a/state.cpp +++ b/state.cpp @@ -31,6 +31,7 @@ #include #include #include "TestHelper.h" +#include "Stats.h" using namespace std; using namespace json_spirit; @@ -41,7 +42,8 @@ namespace dev { namespace test { void doStateTests(json_spirit::mValue& v, bool _fillin) { - Options::get(); // process command line options + if (Options::get().stats) + Listener::registerListener(Stats::get()); for (auto& i: v.get_obj()) { @@ -60,6 +62,7 @@ void doStateTests(json_spirit::mValue& v, bool _fillin) try { + Listener::ExecTimeGuard guard{i.first}; theState.execute(lastHashes(importer.m_environment.currentBlock.number), tx, &output); } catch (Exception const& _e) @@ -178,29 +181,13 @@ BOOST_AUTO_TEST_CASE(stBlockHashTest) BOOST_AUTO_TEST_CASE(stQuadraticComplexityTest) { if (test::Options::get().quadratic) - { - auto start = chrono::steady_clock::now(); - dev::test::executeTests("stQuadraticComplexityTest", "/StateTests", dev::test::doStateTests); - - auto end = chrono::steady_clock::now(); - auto duration(chrono::duration_cast(end - start)); - cnote << "test duration: " << duration.count() << " milliseconds.\n"; - } } BOOST_AUTO_TEST_CASE(stMemoryStressTest) { if (test::Options::get().memory) - { - auto start = chrono::steady_clock::now(); - dev::test::executeTests("stMemoryStressTest", "/StateTests", dev::test::doStateTests); - - auto end = chrono::steady_clock::now(); - auto duration(chrono::duration_cast(end - start)); - cnote << "test duration: " << duration.count() << " milliseconds.\n"; - } } BOOST_AUTO_TEST_CASE(stSolidityTest) diff --git a/vm.cpp b/vm.cpp index 4433a60ee..24ae4e069 100644 --- a/vm.cpp +++ b/vm.cpp @@ -20,13 +20,12 @@ * vm test functions. */ -#include - #include #include #include #include "vm.h" +#include "Stats.h" using namespace std; using namespace json_spirit; @@ -312,7 +311,8 @@ namespace dev { namespace test { void doVMTests(json_spirit::mValue& v, bool _fillin) { - Options::get(); // process command line options // TODO: We need to control the main() function + if (Options::get().stats) + Listener::registerListener(Stats::get()); for (auto& i: v.get_obj()) { @@ -340,12 +340,16 @@ void doVMTests(json_spirit::mValue& v, bool _fillin) bytes output; u256 gas; bool vmExceptionOccured = false; - auto startTime = std::chrono::high_resolution_clock::now(); try { auto vm = eth::VMFactory::create(fev.gas); auto vmtrace = Options::get().vmtrace ? fev.simpleTrace() : OnOpFunc{}; - output = vm->go(fev, vmtrace).toBytes(); + auto outputRef = bytesConstRef{}; + { + Listener::ExecTimeGuard guard{i.first}; + outputRef = vm->go(fev, vmtrace); + } + output = outputRef.toBytes(); gas = vm->gas(); } catch (VMException const&) @@ -364,15 +368,6 @@ 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(); - if (Options::get().showTimes) - { - auto testDuration = endTime - startTime; - cnote << "Execution time: " - << std::chrono::duration_cast(testDuration).count() - << " ms"; - } - // delete null entries in storage for the sake of comparison for (auto &a: fev.addresses) @@ -513,29 +508,13 @@ BOOST_AUTO_TEST_CASE(vmSystemOperationsTest) BOOST_AUTO_TEST_CASE(vmPerformanceTest) { if (test::Options::get().performance) - { - auto start = chrono::steady_clock::now(); - dev::test::executeTests("vmPerformanceTest", "/VMTests", dev::test::doVMTests); - - auto end = chrono::steady_clock::now(); - auto duration(chrono::duration_cast(end - start)); - cnote << "test duration: " << duration.count() << " milliseconds.\n"; - } } BOOST_AUTO_TEST_CASE(vmInputLimitsTest1) { if (test::Options::get().inputLimits) - { - auto start = chrono::steady_clock::now(); - dev::test::executeTests("vmInputLimits1", "/VMTests", dev::test::doVMTests); - - auto end = chrono::steady_clock::now(); - auto duration(chrono::duration_cast(end - start)); - cnote << "test duration: " << duration.count() << " milliseconds.\n"; - } } BOOST_AUTO_TEST_CASE(vmInputLimitsTest2) From 3782a33e5004df06714648b5462d3d1960ed9de0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Fri, 13 Mar 2015 13:10:38 +0100 Subject: [PATCH 28/33] Prettify VM and State test outputs --- TestHelper.cpp | 2 +- state.cpp | 6 +++--- vm.cpp | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/TestHelper.cpp b/TestHelper.cpp index 72fecf593..128318b8c 100644 --- a/TestHelper.cpp +++ b/TestHelper.cpp @@ -473,7 +473,7 @@ void executeTests(const string& _name, const string& _testPathAppendix, std::fun try { - cnote << "Testing ..." << _name; + std::cout << "TEST " << _name << ":\n"; json_spirit::mValue v; string s = asString(dev::contents(testPath + "/" + _name + ".json")); BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of " + testPath + "/" + _name + ".json is empty. Have you cloned the 'tests' repo branch develop and set ETHEREUM_TEST_PATH to its path?"); diff --git a/state.cpp b/state.cpp index 8c191aa70..162ae5f34 100644 --- a/state.cpp +++ b/state.cpp @@ -47,7 +47,7 @@ void doStateTests(json_spirit::mValue& v, bool _fillin) for (auto& i: v.get_obj()) { - cerr << i.first << endl; + std::cout << " " << i.first << "\n"; mObject& o = i.second.get_obj(); BOOST_REQUIRE(o.count("env") > 0); @@ -67,12 +67,12 @@ void doStateTests(json_spirit::mValue& v, bool _fillin) } catch (Exception const& _e) { - cnote << "state execution did throw an exception: " << diagnostic_information(_e); + cnote << "Exception:\n" << diagnostic_information(_e); theState.commit(); } catch (std::exception const& _e) { - cnote << "state execution did throw an exception: " << _e.what(); + cnote << "state execution exception: " << _e.what(); } if (_fillin) diff --git a/vm.cpp b/vm.cpp index 24ae4e069..2bdafb270 100644 --- a/vm.cpp +++ b/vm.cpp @@ -316,7 +316,7 @@ void doVMTests(json_spirit::mValue& v, bool _fillin) for (auto& i: v.get_obj()) { - cnote << i.first; + std::cout << " " << i.first << "\n"; mObject& o = i.second.get_obj(); BOOST_REQUIRE(o.count("env") > 0); @@ -354,7 +354,7 @@ void doVMTests(json_spirit::mValue& v, bool _fillin) } catch (VMException const&) { - cnote << "Safe VM Exception"; + std::cout << " Safe VM Exception\n"; vmExceptionOccured = true; } catch (Exception const& _e) @@ -544,7 +544,7 @@ BOOST_AUTO_TEST_CASE(vmRandom) { try { - cnote << "Testing ..." << path.filename(); + std::cout << "TEST " << path.filename() << "\n"; json_spirit::mValue v; string s = asString(dev::contents(path.string())); BOOST_REQUIRE_MESSAGE(s.length() > 0, "Content of " + path.string() + " is empty. Have you cloned the 'tests' repo branch develop and set ETHEREUM_TEST_PATH to its path?"); From ecccdb7065c1153beaa668db345cf4bfddee3c76 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Sat, 14 Mar 2015 10:26:06 +0100 Subject: [PATCH 29/33] test for callcode to 0 --- stSystemOperationsTestFiller.json | 34 +++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/stSystemOperationsTestFiller.json b/stSystemOperationsTestFiller.json index 23ff8c4c3..a20fdbcaf 100644 --- a/stSystemOperationsTestFiller.json +++ b/stSystemOperationsTestFiller.json @@ -835,6 +835,40 @@ } }, + "callcodeTo0": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "30000000", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ [[ 0 ]] (CALLCODE 50000 0 1 0 0 0 0) }", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "", + "storage": {} + } + + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "3000000", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "100000", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, "CallToNameRegistratorOutOfGas": { "env" : { From fb254086570aa0d0b1431889538c153f614b39c8 Mon Sep 17 00:00:00 2001 From: winsvega Date: Thu, 12 Mar 2015 19:34:34 +0300 Subject: [PATCH 30/33] State Tests poc9 --- stPreCompiledContractsFiller.json | 14 +- stSolidityTestFiller.json | 641 +++++++++++++++++++++--------- stSpecialTestFiller.json | 4 +- 3 files changed, 462 insertions(+), 197 deletions(-) diff --git a/stPreCompiledContractsFiller.json b/stPreCompiledContractsFiller.json index 9e5fa862a..ff0cda3f5 100644 --- a/stPreCompiledContractsFiller.json +++ b/stPreCompiledContractsFiller.json @@ -12,7 +12,7 @@ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { "balance" : "20000000", "nonce" : "0", - "code": "{ (MSTORE 0 0x18c547e4f7b0f325ad1e56f57e26c745b09a3e503d86e00e5255ff7f715d3d1c) (MSTORE 32 28) (MSTORE 64 0x73b1693892219d736caba55bdb67216e485557ea6b6af75f37096c9aa6a5a75f) (MSTORE 96 0xeeb940b1d03b21e36b0e47e79769f095fe2ab855bd91e3a38756b7d75a9c4549) [[ 2 ]] (CALL 100000 1 0 0 128 128 32) [[ 0 ]] (MOD (MLOAD 128) (EXP 2 160)) [[ 1 ]] (EQ (ORIGIN) (SLOAD 0)) }", + "code": "{ (MSTORE 0 0x18c547e4f7b0f325ad1e56f57e26c745b09a3e503d86e00e5255ff7f715d3d1c) (MSTORE 32 28) (MSTORE 64 0x73b1693892219d736caba55bdb67216e485557ea6b6af75f37096c9aa6a5a75f) (MSTORE 96 0xeeb940b1d03b21e36b0e47e79769f095fe2ab855bd91e3a38756b7d75a9c4549) [[ 2 ]] (CALL 300000 1 0 0 128 128 32) [[ 0 ]] (MOD (MLOAD 128) (EXP 2 160)) [[ 1 ]] (EQ (ORIGIN) (SLOAD 0)) }", "storage": {} }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { @@ -46,7 +46,7 @@ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { "balance" : "20000000", "nonce" : "0", - "code": "{ (MSTORE 0 0x18c547e4f7b0f325ad1e56f57e26c745b09a3e503d86e00e5255ff7f715d3d1c) (MSTORE 32 28) (MSTORE 64 0x73b1693892219d736caba55bdb67216e485557ea6b6af75f37096c9aa6a5a75f) (MSTORE 96 0xeeb940b1d03b21e36b0e47e79769f095fe2ab855bd91e3a38756b7d75a9c4549) [[ 2 ]] (CALL 100000 1 0 0 128 64 32) [[ 0 ]] (MOD (MLOAD 64) (EXP 2 160)) [[ 1 ]] (EQ (ORIGIN) (SLOAD 0)) }", + "code": "{ (MSTORE 0 0x18c547e4f7b0f325ad1e56f57e26c745b09a3e503d86e00e5255ff7f715d3d1c) (MSTORE 32 28) (MSTORE 64 0x73b1693892219d736caba55bdb67216e485557ea6b6af75f37096c9aa6a5a75f) (MSTORE 96 0xeeb940b1d03b21e36b0e47e79769f095fe2ab855bd91e3a38756b7d75a9c4549) [[ 2 ]] (CALL 300000 1 0 0 128 64 32) [[ 0 ]] (MOD (MLOAD 64) (EXP 2 160)) [[ 1 ]] (EQ (ORIGIN) (SLOAD 0)) }", "storage": {} }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { @@ -81,7 +81,7 @@ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { "balance" : "20000000", "nonce" : "0", - "code": "{ (MSTORE 0 0x18c547e4f7b0f325ad1e56f57e26c745b09a3e503d86e00e5255ff7f715d3d1c) (MSTORE 32 28) (MSTORE 64 0x73b1693892219d736caba55bdb67216e485557ea6b6af75f37096c9aa6a5a75f) (MSTORE 96 0xeeb940b1d03b21e36b0e47e79769f095fe2ab855bd91e3a38756b7d75a9c4549) [[ 2 ]] (CALL 100000 1 0 0 128 128 32) [[ 0 ]] (MLOAD 128) }", + "code": "{ (MSTORE 0 0x18c547e4f7b0f325ad1e56f57e26c745b09a3e503d86e00e5255ff7f715d3d1c) (MSTORE 32 28) (MSTORE 64 0x73b1693892219d736caba55bdb67216e485557ea6b6af75f37096c9aa6a5a75f) (MSTORE 96 0xeeb940b1d03b21e36b0e47e79769f095fe2ab855bd91e3a38756b7d75a9c4549) [[ 2 ]] (CALL 3000 1 0 0 128 128 32) [[ 0 ]] (MLOAD 128) }", "storage": {} }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { @@ -217,7 +217,7 @@ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { "balance" : "20000000", "nonce" : "0", - "code": "{ [[ 2 ]] (CALL 100000 1 0 0 128 128 32) [[ 0 ]] (MOD (MLOAD 128) (EXP 2 160)) }", + "code": "{ [[ 2 ]] (CALL 300000 1 0 0 128 128 32) [[ 0 ]] (MOD (MLOAD 128) (EXP 2 160)) }", "storage": {} }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { @@ -230,7 +230,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "365224", + "gasLimit" : "3652240", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -421,7 +421,7 @@ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { "balance" : "200000000", "nonce" : "0", - "code" : "{ [[ 2 ]] (CALL 20000000 2 0x13 0 0 0 32) [[ 0 ]] (MLOAD 0)}", + "code" : "{ [[ 2 ]] (CALL 200000 2 0x13 0 0 0 32) [[ 0 ]] (MLOAD 0)}", "storage": {} }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { @@ -591,7 +591,7 @@ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { "balance" : "20000000", "nonce" : "0", - "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) [[ 2 ]] (CALL 500 2 0 0 1000000 0 32) [[ 0 ]] (MLOAD 0)}", + "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) [[ 2 ]] (CALL 600 2 0 0 1000000 0 32) [[ 0 ]] (MLOAD 0)}", "storage": {} }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { diff --git a/stSolidityTestFiller.json b/stSolidityTestFiller.json index f2a2a0aa0..253a90c14 100644 --- a/stSolidityTestFiller.json +++ b/stSolidityTestFiller.json @@ -1,83 +1,24 @@ { - "SolidityTest" : { + "TestCryptographicFunctions" : { "env" : { "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", "currentDifficulty" : "45678256", - "currentGasLimit" : "1000000000000000000000000", + "currentGasLimit" : "1000000000000000000000", "currentNumber" : "120", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" }, "pre" : { - "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "1000000000000000000", - "code" : "", - "nonce" : "0", - "storage" : { - } - }, - - "d94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "1000000", - "//" : " ", - "//" : "contract TestContract ", + "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { + "balance" : "100000", + "//" : "contract main ", "//" : "{ ", - "//" : " function testMethod() returns (int res) ", + "//" : " function run() returns (bool) ", "//" : " { ", - "//" : " return 225; ", - "//" : " } ", - "//" : " ", - "//" : " function destroy(address sendFoundsTo) ", - "//" : " { ", - "//" : " suicide(sendFoundsTo); ", - "//" : " } ", - "//" : "} ", - "//" : " ", - "//" : "contract TestSolidityContracts ", - "//" : "{ ", - "//" : "struct StructTest ", - "//" : " { ", - "//" : " address addr; ", - "//" : " int amount; ", - "//" : " string32 str; ", - "//" : " mapping (uint => address) funders; ", - "//" : " } ", - "//" : " ", - "//" : " int globalValue; ", - "//" : " StructTest globalData; ", - "//" : " function runSolidityTests() returns (hash res) ", - "//" : " { ", - "//" : " //res is a mask of failing tests given the first byte is first test ", - "//" : " res = 0x0000000000000000000000000000000000000000000000000000000000000000; ", - "//" : " ", - "//" : " createContractFromMethod(); ", - "//" : " ", - "//" : " if (!testKeywords()) ", - "//" : " res = hash(int(res) + int(0xf000000000000000000000000000000000000000000000000000000000000000)); ", - "//" : " ", - "//" : " if (!testContractInteraction()) ", - "//" : " res = hash(int(res) + int(0x0f00000000000000000000000000000000000000000000000000000000000000)); ", - "//" : " ", - "//" : " if (!testContractSuicide()) ", - "//" : " res = hash(int(res) + int(0x00f0000000000000000000000000000000000000000000000000000000000000)); ", - "//" : " ", - "//" : " if (!testBlockAndTransactionProperties()) ", - "//" : " res = hash(int(res) + int(0x000f000000000000000000000000000000000000000000000000000000000000)); ", - "//" : " ", - "//" : " globalValue = 255; ", - "//" : " globalData.addr = 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b; ", - "//" : " globalData.amount = 255; ", - "//" : " globalData.str = 'global data 32 length string'; ", - "//" : " globalData.funders[0] = 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b; ", - "//" : " if (!testStructuresAndVariabless()) ", - "//" : " res = hash(int(res) + int(0x0000f00000000000000000000000000000000000000000000000000000000000)); ", - "//" : " ", - "//" : " if (!testCryptographicFunctions()) ", - "//" : " res = hash(int(res) + int(0x00000f0000000000000000000000000000000000000000000000000000000000)); ", - "//" : " ", - "//" : " } ", - "//" : " ", + "//" : " return testCryptographicFunctions(); ", + "//" : " } ", + "//" : " ", "//" : " function testCryptographicFunctions() returns (bool res) ", "//" : " { ", "//" : " res = true; ", @@ -92,139 +33,463 @@ "//" : " ", "//" : " //ecrecover ", "//" : " } ", - "//" : " ", - "//" : " function testStructuresAndVariabless() returns (bool res) ", - "//" : " { ", - "//" : " res = true; ", - "//" : " if (globalValue != 255) ", - "//" : " return false; ", - "//" : " ", - "//" : " if (globalValue != globalData.amount) ", - "//" : " return false; ", - "//" : " ", - "//" : " if (globalData.addr != 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b) ", - "//" : " return false; ", - "//" : " ", - "//" : " if (globalData.str != 'global data 32 length string') ", - "//" : " return false; ", - "//" : " ", - "//" : " if (globalData.funders[0] != 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b) ", - "//" : " return false; ", - "//" : " } ", - "//" : " ", - "//" : " function testBlockAndTransactionProperties() returns (bool res) ", - "//" : " { ", - "//" : " res = true; ", - "//" : " if (block.coinbase != 0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba) ", - "//" : " return false; ", - "//" : " ", - "//" : " if (block.difficulty != 45678256) ", - "//" : " return false; ", - "//" : " ", - "//" : " //for some reason does not work 27.01.2015 ", - "//" : " if (block.gaslimit != 1000000000000000000000) ", - "//" : " return false; ", - "//" : " ", - "//" : " if (block.number != 120) ", - "//" : " return false; ", - "//" : " ", - "//" : " //try to call this ", - "//" : " block.blockhash(120); ", - "//" : " block.timestamp; ", - "//" : " msg.gas; ", - "//" : " ", - "//" : " if (msg.sender != 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b) ", - "//" : " return false; ", - "//" : " ", - "//" : " if (msg.value != 100) ", - "//" : " return false; ", - "//" : " ", - "//" : " if (tx.gasprice != 1) ", - "//" : " return false; ", - "//" : " ", - "//" : " if (tx.origin != 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b) ", - "//" : " return false; ", - "//" : " ", - "//" : " } ", - "//" : " ", - "//" : " function testContractSuicide() returns (bool res) ", - "//" : " { ", - "//" : " TestContract a = new TestContract(); ", - "//" : " a.destroy(block.coinbase); ", - "//" : " if (a.testMethod() == 225) //we should be able to call a contract ", - "//" : " return true; ", - "//" : " return false; ", - "//" : " } ", - "//" : " ", - "//" : " function testContractInteraction() returns (bool res) ", - "//" : " { ", - "//" : " TestContract a = new TestContract(); ", - "//" : " if (a.testMethod() == 225) ", - "//" : " return true; ", - "//" : " return false; ", - "//" : " } ", - "//" : " ", - "//" : " function testKeywords() returns (bool res) ", - "//" : " { ", - "//" : " //some simple checks for the if statemnt ", - "//" : " //if, else, while, for, break, continue, return ", - "//" : " int i = 0; ", - "//" : " res = false; ", - "//" : " ", - "//" : " if (i == 0) ", - "//" : " { ", - "//" : " if( i <= -25) ", - "//" : " { ", - "//" : " return false; ", - "//" : " } ", - "//" : " else ", - "//" : " { ", - "//" : " while(i < 10) ", - "//" : " i++; ", - "//" : " ", - "//" : " if (i == 10) ", - "//" : " { ", - "//" : " for(var j=10; j>0; j--) ", - "//" : " { ", - "//" : " i--; ", - "//" : " } ", - "//" : " } ", - "//" : " } ", - "//" : " } ", - "//" : " ", - "//" : " if (i == 0) ", - "//" : " return true; ", - "//" : " ", - "//" : " return false; ", - "//" : " } ", - "//" : " ", - "//" : " function createContractFromMethod() returns (TestContract a) ", - "//" : " { ", - "//" : " a = new TestContract(); ", - "//" : " } ", "//" : "} ", - "code" : "0x60003560e060020a900480630c4c9a80146100635780632a9afb8314610075578063380e4396146100875780637ee17e1214610099578063a60eedda146100a7578063e0a9fd28146100b9578063e97384dc146100cb578063ed973fe9146100dd57005b61006b610473565b8060005260206000f35b61007d61064e565b8060005260206000f35b61008f61073f565b8060005260206000f35b6100a16107fe565b60006000f35b6100af6100ef565b8060005260206000f35b6100c1610196565b8060005260206000f35b6100d3610352565b8060005260206000f35b6100e56102eb565b8060005260206000f35b60006000600191506060610815600039606060006000f0905080600160a060020a031662f55d9d600060008260e060020a02600052600441600160a060020a03168152602001600060008660325a03f161014557005b505080600160a060020a031663b9c3d0a5602060008260e060020a026000526004600060008660325a03f161017657005b505060005160e1141561018857610191565b60009150610192565b5b5090565b60006001905060007f74657374737472696e67000000000000000000000000000000000000000000008152600a016000207f43c4b4524adb81e4e9a5c4648a98e9d320e3908ac5b6c889144b642cd08ae16d14156101f3576101fc565b600090506102e8565b60026020600060007f74657374737472696e67000000000000000000000000000000000000000000008152600a01600060008560325a03f161023a57005b506000517f3c8727e019a42b444667a587b6001251becadabbb36bfed8087a92c18882d111141561026a57610273565b600090506102e8565b60036020600060007f74657374737472696e67000000000000000000000000000000000000000000008152600a01600060008560325a03f16102b157005b50600051600160a060020a031673cd566972b5e50104011a92b59fa8e0b1234851ae14156102de576102e7565b600090506102e8565b5b90565b600060006060610815600039606060006000f0905080600160a060020a031663b9c3d0a5602060008260e060020a026000526004600060008660325a03f161032f57005b505060005160e11461034057610349565b6001915061034e565b600091505b5090565b60006001905041600160a060020a0316732adc25665018aa1fe0e6bc666dac8fc2697ff9ba14156103825761038b565b60009050610470565b446302b8feb0141561039c576103a5565b60009050610470565b45683635c9adc5dea0000014156103bb576103c4565b60009050610470565b43607814156103d2576103db565b60009050610470565b33600160a060020a031673a94f5374fce5edbc8e2a8697c15331677e6ebf0b14156104055761040e565b60009050610470565b346064141561041c57610425565b60009050610470565b3a600114156104335761043c565b60009050610470565b32600160a060020a031673a94f5374fce5edbc8e2a8697c15331677e6ebf0b14156104665761046f565b60009050610470565b5b90565b6000600090506104816107fe565b5061048a61073f565b15610494576104ba565b7ff000000000000000000000000000000000000000000000000000000000000000810190505b6104c26102eb565b156104cc576104f2565b7f0f00000000000000000000000000000000000000000000000000000000000000810190505b6104fa6100ef565b1561050457610529565b7ef0000000000000000000000000000000000000000000000000000000000000810190505b610531610352565b1561053b57610560565b7e0f000000000000000000000000000000000000000000000000000000000000810190505b60ff60008190555073a94f5374fce5edbc8e2a8697c15331677e6ebf0b60018190555060ff6002819055507f676c6f62616c2064617461203332206c656e67746820737472696e670000000060038190555073a94f5374fce5edbc8e2a8697c15331677e6ebf0b6004600060008152602001908152602001600020819055506105e761064e565b156105f157610615565b7df00000000000000000000000000000000000000000000000000000000000810190505b61061d610196565b156106275761064b565b7d0f0000000000000000000000000000000000000000000000000000000000810190505b90565b60006001905060005460ff14156106645761066d565b6000905061073c565b600254600054141561067e57610687565b6000905061073c565b600154600160a060020a031673a94f5374fce5edbc8e2a8697c15331677e6ebf0b14156106b3576106bc565b6000905061073c565b6003547f676c6f62616c2064617461203332206c656e67746820737472696e670000000014156106eb576106f4565b6000905061073c565b600460006000815260200190815260200160002054600160a060020a031673a94f5374fce5edbc8e2a8697c15331677e6ebf0b14156107325761073b565b6000905061073c565b5b90565b60006000600060009150600092508160001461075a576107de565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe78213156107d4575b600a821215610799578180600101925050610783565b81600a146107a6576107cf565b600a90505b60008160ff1611156107ce578180600190039250508080600190039150506107ab565b5b6107dd565b600092506107f9565b5b816000146107eb576107f4565b600192506107f9565b600092505b505090565b60006060610815600039606060006000f09050905600605480600c6000396000f30060003560e060020a90048062f55d9d14601e578063b9c3d0a514602d57005b60276004356046565b60006000f35b6033603d565b8060005260206000f35b600060e1905090565b80600160a060020a0316ff5056", + "code" : "0x60003560e060020a90048063c040622614610021578063e0a9fd281461003357005b610029610045565b8060005260206000f35b61003b610054565b8060005260206000f35b600061004f610054565b905090565b60006001905060007f74657374737472696e67000000000000000000000000000000000000000000008152600a017f030d40000000000000000000000000000000000000000000000000000000000081526003016000207f43c4b4524adb81e4e9a5c4648a98e9d320e3908ac5b6c889144b642cd08ae16d14156100d7576100e0565b60009050610218565b60026020600060007f74657374737472696e67000000000000000000000000000000000000000000008152600a017f030d4000000000000000000000000000000000000000000000000000000000008152600301600060008560325a03f161014457005b506000517f3c8727e019a42b444667a587b6001251becadabbb36bfed8087a92c18882d11114156101745761017d565b60009050610218565b60036020600060007f74657374737472696e67000000000000000000000000000000000000000000008152600a017f030d4000000000000000000000000000000000000000000000000000000000008152600301600060008560325a03f16101e157005b50600051600160a060020a031673cd566972b5e50104011a92b59fa8e0b1234851ae141561020e57610217565b60009050610218565b5b9056", "nonce" : "0", "storage" : { - } + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "50000000", + "nonce" : "0", + "code" : "", + "storage": {} } }, - "transaction" : - { - "//" : "createContractFromMethod()", - "data" : "0x7ee17e12", - "//" : "runSolidityTests()", - "data" : "0x0c4c9a80", - "gasLimit" : "15000000", + { + "//" : "run()", + "data" : "0xc0406226", + "gasLimit" : "35000000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "d94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100" } }, + "TestStructuresAndVariabless" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "45678256", + "currentGasLimit" : "1000000000000000000000", + "currentNumber" : "120", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "pre" : + { + "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { + "balance" : "100000", + "//" : "contract main ", + "//" : "{ ", + "//" : " struct StructTest ", + "//" : " { ", + "//" : " address addr; ", + "//" : " int amount; ", + "//" : " string32 str; ", + "//" : " mapping (uint => address) funders; ", + "//" : " } ", + "//" : " ", + "//" : " int globalValue; ", + "//" : " StructTest globalData; ", + "//" : " function run() returns (bool) ", + "//" : " { ", + "//" : " globalValue = 255; ", + "//" : " globalData.addr = 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b; ", + "//" : " globalData.amount = 255; ", + "//" : " globalData.str = 'global data 32 length string'; ", + "//" : " globalData.funders[0] = 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b; ", + "//" : " return testStructuresAndVariabless(); ", + "//" : " } ", + "//" : " ", + "//" : " function testStructuresAndVariabless() returns (bool res) ", + "//" : " { ", + "//" : " res = true; ", + "//" : " if (globalValue != 255) ", + "//" : " return false; ", + "//" : " ", + "//" : " if (globalValue != globalData.amount) ", + "//" : " return false; ", + "//" : " ", + "//" : " if (globalData.addr != 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b) ", + "//" : " return false; ", + "//" : " ", + "//" : " if (globalData.str != 'global data 32 length string') ", + "//" : " return false; ", + "//" : " ", + "//" : " if (globalData.funders[0] != 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b) ", + "//" : " return false; ", + "//" : " } ", + "//" : "} ", + "code" : "0x60003560e060020a900480632a9afb8314610021578063c04062261461003357005b610029610045565b8060005260206000f35b61003b610136565b8060005260206000f35b60006001905060005460ff141561005b57610064565b60009050610133565b60025460005414156100755761007e565b60009050610133565b600154600160a060020a031673a94f5374fce5edbc8e2a8697c15331677e6ebf0b14156100aa576100b3565b60009050610133565b6003547f676c6f62616c2064617461203332206c656e67746820737472696e670000000014156100e2576100eb565b60009050610133565b600460006000815260200190815260200160002054600160a060020a031673a94f5374fce5edbc8e2a8697c15331677e6ebf0b141561012957610132565b60009050610133565b5b90565b600060ff60008190555073a94f5374fce5edbc8e2a8697c15331677e6ebf0b60018190555060ff6002819055507f676c6f62616c2064617461203332206c656e67746820737472696e670000000060038190555073a94f5374fce5edbc8e2a8697c15331677e6ebf0b6004600060008152602001908152602001600020819055506101bf610045565b90509056", + "nonce" : "0", + "storage" : { + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "1000000", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : + { + "//" : "run()", + "data" : "0xc0406226", + "gasLimit" : "350000", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "100" + } + }, + + "TestBlockAndTransactionProperties" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "45678256", + "currentGasLimit" : "1000000000000000000000", + "currentNumber" : "120", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "pre" : + { + "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { + "balance" : "100000", + "//" : "contract main ", + "//" : "{ ", + "//" : " function run() returns (bool) ", + "//" : " { ", + "//" : " return testBlockAndTransactionProperties(); ", + "//" : " } ", + "//" : " ", + "//" : " function testBlockAndTransactionProperties() returns (bool res) ", + "//" : " { ", + "//" : " res = true; ", + "//" : " if (block.coinbase != 0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba) ", + "//" : " return false; ", + "//" : " ", + "//" : " if (block.difficulty != 45678256) ", + "//" : " return false; ", + "//" : " ", + "//" : " if (block.gaslimit != 1000000000000000000000) ", + "//" : " return false; ", + "//" : " ", + "//" : " if (block.number != 120) ", + "//" : " return false; ", + "//" : " ", + "//" : " //try to call this ", + "//" : " block.blockhash(120); ", + "//" : " block.timestamp; ", + "//" : " msg.gas; ", + "//" : " ", + "//" : " if (msg.sender != 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b) ", + "//" : " return false; ", + "//" : " ", + "//" : " if (msg.value != 100) ", + "//" : " return false; ", + "//" : " ", + "//" : " if (tx.gasprice != 1) ", + "//" : " return false; ", + "//" : " ", + "//" : " if (tx.origin != 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b) ", + "//" : " return false; ", + "//" : " ", + "//" : " } ", + "//" : "} ", + "code" : "0x60003560e060020a90048063c040622614610021578063e97384dc1461003357005b610029610045565b8060005260206000f35b61003b610054565b8060005260206000f35b600061004f610054565b905090565b60006001905041600160a060020a0316732adc25665018aa1fe0e6bc666dac8fc2697ff9ba14156100845761008d565b60009050610172565b446302b8feb0141561009e576100a7565b60009050610172565b45683635c9adc5dea0000014156100bd576100c6565b60009050610172565b43607814156100d4576100dd565b60009050610172565b33600160a060020a031673a94f5374fce5edbc8e2a8697c15331677e6ebf0b141561010757610110565b60009050610172565b346064141561011e57610127565b60009050610172565b3a600114156101355761013e565b60009050610172565b32600160a060020a031673a94f5374fce5edbc8e2a8697c15331677e6ebf0b141561016857610171565b60009050610172565b5b9056", + "nonce" : "0", + "storage" : { + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "1000000", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : + { + "//" : "run()", + "data" : "0xc0406226", + "gasLimit" : "350000", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "100" + } + }, + + "TestContractSuicide" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "45678256", + "currentGasLimit" : "100000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "pre" : + { + "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { + "balance" : "100000", + "//": "contract TestContract ", + "//": "{ ", + "//": " function testMethod() returns (int res) ", + "//": " { ", + "//": " return 225; ", + "//": " } ", + "//": " ", + "//": " function destroy(address sendFoundsTo) ", + "//": " { ", + "//": " suicide(sendFoundsTo); ", + "//": " } ", + "//": "} ", + "//": "contract main ", + "//": "{ ", + "//": " function run() returns (bool) ", + "//": " { ", + "//": " return testContractSuicide(); ", + "//": " } ", + "//": " ", + "//": " function testContractSuicide() returns (bool res) ", + "//": " { ", + "//": " TestContract a = new TestContract(); ", + "//": " a.destroy(block.coinbase); ", + "//": " if (a.testMethod() == 225) //we should be able to call a contract ", + "//": " return true; ", + "//": " return false; ", + "//": " } ", + "//": "} ", + "code" : "0x60003560e060020a90048063a60eedda14610021578063c04062261461003357005b610029610045565b8060005260206000f35b61003b6100eb565b8060005260206000f35b6000600060606100fb600039606060006000f0905080600160a060020a031662f55d9d600060008260e060020a02600052600441600160a060020a03168152602001600060008660325a03f161009757005b505080600160a060020a031663b9c3d0a5602060008260e060020a026000526004600060008660325a03f16100c857005b505060005160e1146100d9576100e2565b600191506100e7565b600091505b5090565b60006100f5610045565b9050905600605480600c6000396000f30060003560e060020a90048062f55d9d14601e578063b9c3d0a514602d57005b60276004356046565b60006000f35b6033603d565b8060005260206000f35b600060e1905090565b80600160a060020a0316ff5056", + "nonce" : "0", + "storage" : { + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "1000000", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : + { + "//" : "run()", + "data" : "0xc0406226", + "gasLimit" : "350000", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "1" + } + }, + + "TestContractInteraction" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "45678256", + "currentGasLimit" : "100000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "pre" : + { + "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { + "balance" : "100000", + "//": "contract TestContract ", + "//": "{ ", + "//": " function testMethod() returns (int res) ", + "//": " { ", + "//": " return 225; ", + "//": " } ", + "//": " ", + "//": " function destroy(address sendFoundsTo) ", + "//": " { ", + "//": " suicide(sendFoundsTo); ", + "//": " } ", + "//": "} ", + "//": "contract main ", + "//": "{ ", + "//": " function run() returns (bool) ", + "//": " { ", + "//": " return testContractInteraction(); ", + "//": " } ", + "//": " ", + "//" : " function testContractInteraction() returns (bool res) ", + "//" : " { ", + "//" : " TestContract a = new TestContract(); ", + "//" : " if (a.testMethod() == 225) ", + "//" : " return true; ", + "//" : " return false; ", + "//" : " } ", + "//": "} ", + "code" : "0x60003560e060020a90048063c040622614610021578063ed973fe91461003357005b6100296100ac565b8060005260206000f35b61003b610045565b8060005260206000f35b6000600060606100bc600039606060006000f0905080600160a060020a031663b9c3d0a5602060008260e060020a026000526004600060008660325a03f161008957005b505060005160e11461009a576100a3565b600191506100a8565b600091505b5090565b60006100b6610045565b9050905600605480600c6000396000f30060003560e060020a90048062f55d9d14601e578063b9c3d0a514602d57005b6027600435603d565b60006000f35b6033604b565b8060005260206000f35b80600160a060020a0316ff50565b600060e190509056", + "nonce" : "0", + "storage" : { + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "1000000", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : + { + "//" : "run()", + "data" : "0xc0406226", + "gasLimit" : "350000", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "1" + } + }, + + "TestKeywords" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "45678256", + "currentGasLimit" : "100000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "pre" : + { + "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { + "balance" : "100000", + "//": "contract main ", + "//": "{ ", + "//": " function run() returns (bool) ", + "//": " { ", + "//": " return testKeywords(); ", + "//": " } ", + "//": " ", + "//": " function testKeywords() returns (bool res) ", + "//": " { ", + "//": " //some simple checks for the if statemnt ", + "//": " //if, else, while, for, break, continue, return ", + "//": " int i = 0; ", + "//": " res = false; ", + "//": " ", + "//": " if (i == 0) ", + "//": " { ", + "//": " if( i <= -25) ", + "//": " { ", + "//": " return false; ", + "//": " } ", + "//": " else ", + "//": " { ", + "//": " while(i < 10) ", + "//": " i++; ", + "//": " ", + "//": " if (i == 10) ", + "//": " { ", + "//": " for(var j=10; j>0; j--) ", + "//": " { ", + "//": " i--; ", + "//": " } ", + "//": " } ", + "//": " } ", + "//": " } ", + "//": " ", + "//": " if (i == 0) ", + "//": " return true; ", + "//": " ", + "//": " return false; ", + "//": " } ", + "//": "} ", + "code" : "0x60003560e060020a90048063380e439614601f578063c040622614602f57005b6025603f565b8060005260206000f35b603560f0565b8060005260206000f35b60006000600060009150600092508160001460585760d3565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe782131560ca575b600a82121560945781806001019250506080565b81600a14609f5760c6565b600a90505b60008160ff16111560c55781806001900392505080806001900391505060a4565b5b60d2565b6000925060eb565b5b8160001460de5760e6565b6001925060eb565b600092505b505090565b600060f8603f565b90509056", + "nonce" : "0", + "storage" : { + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "1000000", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : + { + "//" : "run()", + "data" : "0xc0406226", + "gasLimit" : "350000", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "1" + } + }, + + "CreateContractFromMethod" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "45678256", + "currentGasLimit" : "100000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "pre" : + { + "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { + "balance" : "100000", + "//": "contract TestContract ", + "//": "{ ", + "//": " function testMethod() returns (int res) ", + "//": " { ", + "//": " return 225; ", + "//": " } ", + "//": " ", + "//": " function destroy(address sendFoundsTo) ", + "//": " { ", + "//": " suicide(sendFoundsTo); ", + "//": " } ", + "//": "} ", + "//": " ", + "//": "contract main ", + "//": "{ ", + "//": " function run() returns (uint) ", + "//": " { ", + "//": " createContractFromMethod(); ", + "//": " } ", + "//": " ", + "//": " function createContractFromMethod() returns (TestContract a) ", + "//": " { ", + "//": " a = new TestContract(); ", + "//": " } ", + "//": "} ", + "code" : "0x60003560e060020a900480637ee17e1214601f578063c040622614602b57005b60256047565b60006000f35b6031603b565b8060005260206000f35b600060436047565b5090565b60006060605d600039606060006000f09050905600605480600c6000396000f30060003560e060020a90048062f55d9d14601e578063b9c3d0a514602d57005b60276004356046565b60006000f35b6033603d565b8060005260206000f35b600060e1905090565b80600160a060020a0316ff5056", + "nonce" : "0", + "storage" : { + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "1000000", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : + { + "//" : "run()", + "data" : "0xc0406226", + "gasLimit" : "350000", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "1" + } + }, + "CallLowLevelCreatesSolidity" : { "env" : { "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", diff --git a/stSpecialTestFiller.json b/stSpecialTestFiller.json index 223d9f75f..b6552923f 100644 --- a/stSpecialTestFiller.json +++ b/stSpecialTestFiller.json @@ -22,7 +22,7 @@ "storage": {} }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "100000", + "balance" : "1000000", "nonce" : "0", "code" : "", "storage": {} @@ -31,7 +31,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "22850", + "gasLimit" : "228500", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "10", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", From d60773a4294bc6c150b61410ea649a0f09879799 Mon Sep 17 00:00:00 2001 From: winsvega Date: Fri, 13 Mar 2015 17:46:38 +0300 Subject: [PATCH 31/33] State Tests stSystemOperations poc9 --- stSystemOperationsTestFiller.json | 80 +++++++++++++++---------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/stSystemOperationsTestFiller.json b/stSystemOperationsTestFiller.json index 23ff8c4c3..bb4484961 100644 --- a/stSystemOperationsTestFiller.json +++ b/stSystemOperationsTestFiller.json @@ -3,7 +3,7 @@ "env" : { "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", "currentNumber" : "0", - "currentGasLimit" : "1000000", + "currentGasLimit" : "100000000", "currentDifficulty" : "256", "currentTimestamp" : 1, "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" @@ -25,7 +25,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "30000", + "gasLimit" : "300000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -60,7 +60,7 @@ }, "transaction" : { "data" : "", - "gasLimit" : "30000", + "gasLimit" : "300000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -95,7 +95,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "30000", + "gasLimit" : "300000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -129,7 +129,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "30000", + "gasLimit" : "300000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -163,7 +163,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "30000", + "gasLimit" : "300000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -197,7 +197,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "30000", + "gasLimit" : "300000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -232,7 +232,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "30000", + "gasLimit" : "300000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -257,7 +257,7 @@ "storage": {} }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "100000", + "balance" : "1000000", "nonce" : "0", "code" : "", "storage": {} @@ -266,7 +266,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "30000", + "gasLimit" : "300000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -300,7 +300,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "30000", + "gasLimit" : "300000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -334,7 +334,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "30000", + "gasLimit" : "300000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -368,7 +368,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "30000", + "gasLimit" : "300000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -452,7 +452,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "30000", + "gasLimit" : "300000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -494,7 +494,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "30000", + "gasLimit" : "300000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -536,7 +536,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "30000", + "gasLimit" : "300000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -578,7 +578,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "30000", + "gasLimit" : "300000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -619,7 +619,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "30000", + "gasLimit" : "300000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -660,7 +660,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "30000", + "gasLimit" : "300000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -701,7 +701,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "30000", + "gasLimit" : "300000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -743,7 +743,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "30000", + "gasLimit" : "300000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -785,7 +785,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "30000", + "gasLimit" : "300000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -870,7 +870,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "30000", + "gasLimit" : "300000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -911,7 +911,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "30000", + "gasLimit" : "300000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -952,7 +952,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "30000", + "gasLimit" : "300000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -993,7 +993,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "30000", + "gasLimit" : "300000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1035,7 +1035,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "30000", + "gasLimit" : "300000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1076,7 +1076,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "30000", + "gasLimit" : "300000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1894,12 +1894,12 @@ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { "balance" : "1000000000000000000", "nonce" : "0", - "code" : "{ [[ (PC) ]] (CALL 1000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 24 0 0 0 0) }", + "code" : "{ [[ (PC) ]] (CALL 100000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 24 0 0 0 0) }", "storage": {} }, "945304eb96065b2a98b57a48a06ae28d285a71b5" : { "balance" : "23", - "code" : " { [[ (PC) ]] (ADD 1 (CALL 500 0x095e7baea6a6c7c4c2dfeb977efac326af552d87 23 0 0 0 0)) } ", + "code" : " { [[ (PC) ]] (ADD 1 (CALL 50000 0x095e7baea6a6c7c4c2dfeb977efac326af552d87 23 0 0 0 0)) } ", "nonce" : "0", "storage" : { } @@ -1935,12 +1935,12 @@ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { "balance" : "1000000000000000000", "nonce" : "0", - "code" : "{ [[ (PC) ]] (CALL (- (GAS) 1000) 0x945304eb96065b2a98b57a48a06ae28d285a71b5 24 0 0 0 0) }", + "code" : "{ [[ (PC) ]] (CALL (- (GAS) 100000) 0x945304eb96065b2a98b57a48a06ae28d285a71b5 24 0 0 0 0) }", "storage": {} }, "945304eb96065b2a98b57a48a06ae28d285a71b5" : { "balance" : "23", - "code" : " { [[ (PC) ]] (ADD 1 (CALL (- (GAS) 1000) 0x095e7baea6a6c7c4c2dfeb977efac326af552d87 23 0 0 0 0)) } ", + "code" : " { [[ (PC) ]] (ADD 1 (CALL (- (GAS) 100000) 0x095e7baea6a6c7c4c2dfeb977efac326af552d87 23 0 0 0 0)) } ", "nonce" : "0", "storage" : { } @@ -1976,12 +1976,12 @@ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { "balance" : "1000000000000000000", "nonce" : "0", - "code" : "{ [[ 0 ]] (ADD (SLOAD 0) 1) (CALL (- (GAS) 1000) 0x945304eb96065b2a98b57a48a06ae28d285a71b5 1 0 0 0 0) }", + "code" : "{ [[ 0 ]] (ADD (SLOAD 0) 1) (CALL (- (GAS) 100000) 0x945304eb96065b2a98b57a48a06ae28d285a71b5 1 0 0 0 0) }", "storage": {} }, "945304eb96065b2a98b57a48a06ae28d285a71b5" : { "balance" : "0", - "code" : " { [[ 0 ]] (ADD (SLOAD 0) 1) (CALL (- (GAS) 1000) 0x095e7baea6a6c7c4c2dfeb977efac326af552d87 0 0 0 0 0) } ", + "code" : " { [[ 0 ]] (ADD (SLOAD 0) 1) (CALL (- (GAS) 100000) 0x095e7baea6a6c7c4c2dfeb977efac326af552d87 0 0 0 0 0) } ", "nonce" : "0", "storage" : { } @@ -2017,12 +2017,12 @@ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { "balance" : "1025000", "nonce" : "0", - "code" : "{ [[ 0 ]] (ADD (SLOAD 0) 1) (CALL (- (GAS) 1000) 0x945304eb96065b2a98b57a48a06ae28d285a71b5 1 0 0 0 0) }", + "code" : "{ [[ 0 ]] (ADD (SLOAD 0) 1) (CALL (- (GAS) 100000) 0x945304eb96065b2a98b57a48a06ae28d285a71b5 1 0 0 0 0) }", "storage": {} }, "945304eb96065b2a98b57a48a06ae28d285a71b5" : { "balance" : "0", - "code" : " { [[ 0 ]] (ADD (SLOAD 0) 1) (CALL (- (GAS) 1000) 0x095e7baea6a6c7c4c2dfeb977efac326af552d87 0 0 0 0 0) } ", + "code" : " { [[ 0 ]] (ADD (SLOAD 0) 1) (CALL (- (GAS) 100000) 0x095e7baea6a6c7c4c2dfeb977efac326af552d87 0 0 0 0 0) } ", "nonce" : "0", "storage" : { } @@ -2058,12 +2058,12 @@ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { "balance" : "1000000000000000000", "nonce" : "0", - "code" : "{ [[ (PC) ]] (CALL 1000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 24 0 0 0 0) (SUICIDE 0x945304eb96065b2a98b57a48a06ae28d285a71b5) }", + "code" : "{ [[ (PC) ]] (CALL 100000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 24 0 0 0 0) (SUICIDE 0x945304eb96065b2a98b57a48a06ae28d285a71b5) }", "storage": {} }, "945304eb96065b2a98b57a48a06ae28d285a71b5" : { "balance" : "23", - "code" : "{ [[ (PC) ]] (ADD 1 (CALL 500 0x095e7baea6a6c7c4c2dfeb977efac326af552d87 23 0 0 0 0)) } ", + "code" : "{ [[ (PC) ]] (ADD 1 (CALL 50000 0x095e7baea6a6c7c4c2dfeb977efac326af552d87 23 0 0 0 0)) } ", "nonce" : "0", "storage" : { } @@ -2099,12 +2099,12 @@ "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { "balance" : "1000000000000000000", "nonce" : "0", - "code" : "{ [[ (PC) ]] (CALL 1000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 24 0 0 0 0) }", + "code" : "{ [[ (PC) ]] (CALL 100000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 24 0 0 0 0) }", "storage": {} }, "945304eb96065b2a98b57a48a06ae28d285a71b5" : { "balance" : "23", - "code" : "{ [[ (PC) ]] (ADD 1 (CALL 500 0x095e7baea6a6c7c4c2dfeb977efac326af552d87 23 0 0 0 0)) (SUICIDE 0x0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6) } ", + "code" : "{ [[ (PC) ]] (ADD 1 (CALL 50000 0x095e7baea6a6c7c4c2dfeb977efac326af552d87 23 0 0 0 0)) (SUICIDE 0x0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6) } ", "nonce" : "0", "storage" : { } From 204f53c6ad8fd09884bc3023075f4534ce9bcd81 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sat, 14 Mar 2015 19:00:41 +0100 Subject: [PATCH 32/33] getData -> getCode. --- webthreestubclient.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webthreestubclient.h b/webthreestubclient.h index 687ebc491..e0ecd2eb3 100644 --- a/webthreestubclient.h +++ b/webthreestubclient.h @@ -197,12 +197,12 @@ class WebThreeStubClient : public jsonrpc::Client else throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); } - std::string eth_getData(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException) + std::string eth_getCode(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException) { Json::Value p; p.append(param1); p.append(param2); - Json::Value result = this->CallMethod("eth_getData",p); + Json::Value result = this->CallMethod("eth_getCode",p); if (result.isString()) return result.asString(); else From 1b09e5debba1e04627474ba8ec3b2b7d5bcd1fd6 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sat, 14 Mar 2015 19:59:07 +0100 Subject: [PATCH 33/33] Renaming getData -> getCode, remove getStorage, fix a bunch of JSONRPC methods with more expansive error handling. --- webthreestubclient.h | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/webthreestubclient.h b/webthreestubclient.h index e0ecd2eb3..4754bbbef 100644 --- a/webthreestubclient.h +++ b/webthreestubclient.h @@ -123,17 +123,6 @@ class WebThreeStubClient : public jsonrpc::Client else throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); } - Json::Value eth_getStorage(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException) - { - Json::Value p; - p.append(param1); - p.append(param2); - Json::Value result = this->CallMethod("eth_getStorage",p); - if (result.isObject()) - return result; - else - throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); - } std::string eth_getStorageAt(const std::string& param1, const std::string& param2, const std::string& param3) throw (jsonrpc::JsonRpcException) { Json::Value p;