From ed2b4cff41a23e81e706c47b0187a18f5c7ea8d2 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Mon, 19 Jan 2015 11:02:13 +0100 Subject: [PATCH 01/10] test with sha3 and gas = 2**32 --- vmSha3TestFiller.json | 86 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 1 deletion(-) diff --git a/vmSha3TestFiller.json b/vmSha3TestFiller.json index 7ed729520..d594d4fe9 100644 --- a/vmSha3TestFiller.json +++ b/vmSha3TestFiller.json @@ -193,5 +193,89 @@ "gasPrice" : "100000000000000", "gas" : "10000" } - } + }, + + "sha3_bigSize": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "1000000", + "currentDifficulty" : "256", + "currentTimestamp" : 1, + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "nonce" : 0, + "code" : "{ [[ 0 ]] (SHA3 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)}", + "storage": {} + } + }, + "exec" : { + "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "value" : "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "data" : "", + "gasPrice" : "1", + "gas" : "0x10000000000" + } + }, + + "sha3_bigOffset": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "1000000", + "currentDifficulty" : "256", + "currentTimestamp" : 1, + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "nonce" : 0, + "code" : "{ [[ 0 ]] (SHA3 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 2)}", + "storage": {} + } + }, + "exec" : { + "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "value" : "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "data" : "", + "gasPrice" : "1", + "gas" : "0x10000000000" + } + }, + + "sha3_bigOffset2": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "1000000", + "currentDifficulty" : "256", + "currentTimestamp" : 1, + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "nonce" : 0, + "code" : "{ [[ 0 ]] (SHA3 0x100000000 2)}", + "storage": {} + } + }, + "exec" : { + "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "value" : "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "data" : "", + "gasPrice" : "1", + "gas" : "0x10000000000" + } + } } From cbfd094a17212da0d81d10b99416e240c5e7c625 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Tue, 3 Feb 2015 01:25:41 +0100 Subject: [PATCH 02/10] add refundoverflow test --- stRefundTestFiller.json | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/stRefundTestFiller.json b/stRefundTestFiller.json index 6b2b2fc15..6749fd3dd 100644 --- a/stRefundTestFiller.json +++ b/stRefundTestFiller.json @@ -303,6 +303,34 @@ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "data" : "" } - } + }, + "RefundOverflow" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "45678256", + "currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "400", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : { + "data" : "", + "gasLimit" : "5789604461865809771178549250434395392663499233282028201972879200395656482016", + "gasPrice" : "20", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "value" : "" + } + } } From d3dd2972c169eb368be43d77a2db7c2540e5a3ce Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Thu, 5 Feb 2015 15:45:13 +0100 Subject: [PATCH 03/10] separated libnatspec --- CMakeLists.txt | 1 + natspec.cpp | 124 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+) create mode 100644 natspec.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 764bf928e..36876eea6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,7 @@ target_link_libraries(testeth ethcore) target_link_libraries(testeth secp256k1) target_link_libraries(testeth solidity) target_link_libraries(testeth webthree) +target_link_libraries(testeth natspec) if (JSONRPC) target_link_libraries(testeth web3jsonrpc) diff --git a/natspec.cpp b/natspec.cpp new file mode 100644 index 000000000..9ce8e39c6 --- /dev/null +++ b/natspec.cpp @@ -0,0 +1,124 @@ +/* + 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 natspec.cpp + * @author Marek Kotewicz + * @date 2015 + */ + +#include +#include +#include + +using namespace std; + +BOOST_AUTO_TEST_SUITE(natspec) + +BOOST_AUTO_TEST_CASE(natspec_eval_function_exists) +{ + cnote << "testing existance of evaluateExpression function"; + + // given + NatspecExpressionEvaluator e; + + // when + string result = e.evalExpression("`typeof evaluateExpression`").toStdString(); + + // then + BOOST_CHECK_EQUAL(result, "function"); +} + +BOOST_AUTO_TEST_CASE(natspec_js_eval) +{ + cnote << "testing natspec basic eval"; + + // given + NatspecExpressionEvaluator e; + + // when + string result = e.evalExpression("`1 + 2`").toStdString(); + + // then + BOOST_CHECK_EQUAL(result, "3"); +} + +BOOST_AUTO_TEST_CASE(natspec_create_custom_function) +{ + cnote << "testing creation and usage of custom js function"; + + // given + NatspecExpressionEvaluator e; + + + // when + auto x = e.evalExpression("`test = function (x) { return x + 'ok'; }`"); // ommit var, make it global + string result = e.evalExpression("`test(5)`").toStdString(); + string result2 = e.evalExpression("`typeof test`").toStdString(); + + // then + BOOST_CHECK_EQUAL(result, "5ok"); + BOOST_CHECK_EQUAL(result2, "function"); +} + +BOOST_AUTO_TEST_CASE(natspec_js_eval_separated_expressions) +{ + cnote << "testing natspec evaluation of separated expresioons"; + + // given + NatspecExpressionEvaluator e; + + // when + string result = e.evalExpression("`x = 1` + `y = 2` will be equal `x + y`").toStdString(); + + // then + BOOST_CHECK_EQUAL(result, "1 + 2 will be equal 3"); +} + +BOOST_AUTO_TEST_CASE(natspec_js_eval_input_params) +{ + cnote << "testing natspec evaluation of input params"; + + // given + char const* abi = R"([ + { + "name": "f", + "constant": false, + "type": "function", + "inputs": [ + { + "name": "a", + "type": "uint256" + } + ], + "outputs": [ + { + "name": "d", + "type": "uint256" + } + ] + } + ])"; + + NatspecExpressionEvaluator e(abi, "'f'", "[4]"); + + // when + string result = e.evalExpression("Will multiply `a` by 7 and return `a * 7`.").toStdString(); + + // then + BOOST_CHECK_EQUAL(result, "Will multiply 4 by 7 and return 28."); +} + +BOOST_AUTO_TEST_SUITE_END() From 1954c0686d05c26e98c3da2cc009f93c3a6f8af2 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Thu, 5 Feb 2015 18:45:37 +0100 Subject: [PATCH 04/10] fixed natspec evaluator result on error --- natspec.cpp | 51 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/natspec.cpp b/natspec.cpp index 9ce8e39c6..73e70fc59 100644 --- a/natspec.cpp +++ b/natspec.cpp @@ -1,16 +1,16 @@ /* 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 . */ @@ -30,13 +30,13 @@ BOOST_AUTO_TEST_SUITE(natspec) BOOST_AUTO_TEST_CASE(natspec_eval_function_exists) { cnote << "testing existance of evaluateExpression function"; - + // given NatspecExpressionEvaluator e; - + // when string result = e.evalExpression("`typeof evaluateExpression`").toStdString(); - + // then BOOST_CHECK_EQUAL(result, "function"); } @@ -44,13 +44,13 @@ BOOST_AUTO_TEST_CASE(natspec_eval_function_exists) BOOST_AUTO_TEST_CASE(natspec_js_eval) { cnote << "testing natspec basic eval"; - + // given NatspecExpressionEvaluator e; - + // when string result = e.evalExpression("`1 + 2`").toStdString(); - + // then BOOST_CHECK_EQUAL(result, "3"); } @@ -58,16 +58,15 @@ BOOST_AUTO_TEST_CASE(natspec_js_eval) BOOST_AUTO_TEST_CASE(natspec_create_custom_function) { cnote << "testing creation and usage of custom js function"; - + // given NatspecExpressionEvaluator e; - - + // when auto x = e.evalExpression("`test = function (x) { return x + 'ok'; }`"); // ommit var, make it global string result = e.evalExpression("`test(5)`").toStdString(); string result2 = e.evalExpression("`typeof test`").toStdString(); - + // then BOOST_CHECK_EQUAL(result, "5ok"); BOOST_CHECK_EQUAL(result2, "function"); @@ -76,13 +75,13 @@ BOOST_AUTO_TEST_CASE(natspec_create_custom_function) BOOST_AUTO_TEST_CASE(natspec_js_eval_separated_expressions) { cnote << "testing natspec evaluation of separated expresioons"; - + // given NatspecExpressionEvaluator e; - + // when string result = e.evalExpression("`x = 1` + `y = 2` will be equal `x + y`").toStdString(); - + // then BOOST_CHECK_EQUAL(result, "1 + 2 will be equal 3"); } @@ -90,7 +89,7 @@ BOOST_AUTO_TEST_CASE(natspec_js_eval_separated_expressions) BOOST_AUTO_TEST_CASE(natspec_js_eval_input_params) { cnote << "testing natspec evaluation of input params"; - + // given char const* abi = R"([ { @@ -111,9 +110,9 @@ BOOST_AUTO_TEST_CASE(natspec_js_eval_input_params) ] } ])"; - + NatspecExpressionEvaluator e(abi, "'f'", "[4]"); - + // when string result = e.evalExpression("Will multiply `a` by 7 and return `a * 7`.").toStdString(); @@ -121,4 +120,18 @@ BOOST_AUTO_TEST_CASE(natspec_js_eval_input_params) BOOST_CHECK_EQUAL(result, "Will multiply 4 by 7 and return 28."); } +BOOST_AUTO_TEST_CASE(natspec_js_eval_error) +{ + cnote << "testing natspec evaluation of incorrect input"; + + // given + NatspecExpressionEvaluator e; + + // when + string result = e.evalExpression("`test(`").toStdString(); + + // then + BOOST_CHECK_EQUAL(result, "`test(`"); +} + BOOST_AUTO_TEST_SUITE_END() From 630681094e84f46f54660dc5895fb4576865077f Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Thu, 5 Feb 2015 22:42:17 +0100 Subject: [PATCH 05/10] test block gas limit --- stTransactionTestFiller.json | 64 +++++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/stTransactionTestFiller.json b/stTransactionTestFiller.json index cd42af795..a5092b60b 100644 --- a/stTransactionTestFiller.json +++ b/stTransactionTestFiller.json @@ -169,7 +169,7 @@ }, "pre" : { - "b94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { "balance" : "1000", "code" : "", "nonce" : "0", @@ -189,6 +189,68 @@ } }, + "TransactionFromCoinbaseHittingBlockGasLimit" : { + "env" : { + "currentCoinbase" : "a94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "currentDifficulty" : "45678256", + "currentGasLimit" : "1100", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "pre" : + { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "1000000", + "code" : "", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : + { + "data" : "", + "gasLimit" : "1100", + "gasPrice" : "1", + "nonce" : "", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "value" : "10" + } + }, + + "TransactionFromCoinbaseHittingBlockGasLimit1" : { + "env" : { + "currentCoinbase" : "a94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "currentDifficulty" : "45678256", + "currentGasLimit" : "1100", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "pre" : + { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "100000", + "code" : "", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : + { + "data" : "", + "gasLimit" : "1101", + "gasPrice" : "1", + "nonce" : "", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "value" : "10" + } + }, + "ContractStoreClearsSuccess" : { "env" : { "currentCoinbase" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", From aea7de95565260c9f09c65007ea5e9629080b566 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Fri, 6 Feb 2015 13:38:28 +0100 Subject: [PATCH 06/10] removed output messages in tests && spaces --- natspec.cpp | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/natspec.cpp b/natspec.cpp index 73e70fc59..827f96625 100644 --- a/natspec.cpp +++ b/natspec.cpp @@ -29,44 +29,32 @@ BOOST_AUTO_TEST_SUITE(natspec) BOOST_AUTO_TEST_CASE(natspec_eval_function_exists) { - cnote << "testing existance of evaluateExpression function"; - // given NatspecExpressionEvaluator e; - // when string result = e.evalExpression("`typeof evaluateExpression`").toStdString(); - // then BOOST_CHECK_EQUAL(result, "function"); } BOOST_AUTO_TEST_CASE(natspec_js_eval) { - cnote << "testing natspec basic eval"; - // given NatspecExpressionEvaluator e; - // when string result = e.evalExpression("`1 + 2`").toStdString(); - // then BOOST_CHECK_EQUAL(result, "3"); } BOOST_AUTO_TEST_CASE(natspec_create_custom_function) { - cnote << "testing creation and usage of custom js function"; - // given NatspecExpressionEvaluator e; - // when auto x = e.evalExpression("`test = function (x) { return x + 'ok'; }`"); // ommit var, make it global string result = e.evalExpression("`test(5)`").toStdString(); string result2 = e.evalExpression("`typeof test`").toStdString(); - // then BOOST_CHECK_EQUAL(result, "5ok"); BOOST_CHECK_EQUAL(result2, "function"); @@ -74,22 +62,16 @@ BOOST_AUTO_TEST_CASE(natspec_create_custom_function) BOOST_AUTO_TEST_CASE(natspec_js_eval_separated_expressions) { - cnote << "testing natspec evaluation of separated expresioons"; - // given NatspecExpressionEvaluator e; - // when string result = e.evalExpression("`x = 1` + `y = 2` will be equal `x + y`").toStdString(); - // then BOOST_CHECK_EQUAL(result, "1 + 2 will be equal 3"); } BOOST_AUTO_TEST_CASE(natspec_js_eval_input_params) { - cnote << "testing natspec evaluation of input params"; - // given char const* abi = R"([ { @@ -110,26 +92,19 @@ BOOST_AUTO_TEST_CASE(natspec_js_eval_input_params) ] } ])"; - NatspecExpressionEvaluator e(abi, "'f'", "[4]"); - // when string result = e.evalExpression("Will multiply `a` by 7 and return `a * 7`.").toStdString(); - // then BOOST_CHECK_EQUAL(result, "Will multiply 4 by 7 and return 28."); } BOOST_AUTO_TEST_CASE(natspec_js_eval_error) { - cnote << "testing natspec evaluation of incorrect input"; - // given NatspecExpressionEvaluator e; - // when string result = e.evalExpression("`test(`").toStdString(); - // then BOOST_CHECK_EQUAL(result, "`test(`"); } From 5bedf7f81612767f2f60ea57a1c38c34973465ec Mon Sep 17 00:00:00 2001 From: Christian Date: Fri, 6 Feb 2015 13:38:10 +0100 Subject: [PATCH 07/10] Some fixes for the ether units parser. --- SolidityNameAndTypeResolution.cpp | 22 ++++++++++++++++++++++ SolidityParser.cpp | 13 +++++++++++++ 2 files changed, 35 insertions(+) diff --git a/SolidityNameAndTypeResolution.cpp b/SolidityNameAndTypeResolution.cpp index 742d2ee2a..05ce6ed66 100644 --- a/SolidityNameAndTypeResolution.cpp +++ b/SolidityNameAndTypeResolution.cpp @@ -910,6 +910,28 @@ BOOST_AUTO_TEST_CASE(disallow_declaration_of_void_type) BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError); } +BOOST_AUTO_TEST_CASE(overflow_caused_by_ether_units) +{ + char const* sourceCodeFine = R"( + contract c { + function c () + { + a = 115792089237316195423570985008687907853269984665640564039458; + } + uint256 a; + })"; + BOOST_CHECK_NO_THROW(parseTextAndResolveNames(sourceCodeFine)); + char const* sourceCode = R"( + contract c { + function c () + { + a = 115792089237316195423570985008687907853269984665640564039458 ether; + } + uint256 a; + })"; + BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError); +} + BOOST_AUTO_TEST_SUITE_END() } diff --git a/SolidityParser.cpp b/SolidityParser.cpp index b6837866c..7af99567b 100644 --- a/SolidityParser.cpp +++ b/SolidityParser.cpp @@ -679,6 +679,19 @@ BOOST_AUTO_TEST_CASE(literal_constants_with_ether_subdenominations) BOOST_CHECK_NO_THROW(parseTextExplainError(text)); } +BOOST_AUTO_TEST_CASE(literal_constants_with_ether_subdenominations_in_expressions) +{ + char const* text = R"( + contract c { + function c () + { + a = 1 wei * 100 wei + 7 szabo - 3; + } + uint256 a; + })"; + BOOST_CHECK_NO_THROW(parseTextExplainError(text)); +} + BOOST_AUTO_TEST_SUITE_END() } From 6b803670103018d08f3d4cf6c9a4d27e21964582 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Feb 2015 15:40:07 +0100 Subject: [PATCH 08/10] failing tests from random simulation as state tests and transaction tests --- stSystemOperationsTestFiller.json | 70 +++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/stSystemOperationsTestFiller.json b/stSystemOperationsTestFiller.json index 253ba0a8a..6a4b83e34 100644 --- a/stSystemOperationsTestFiller.json +++ b/stSystemOperationsTestFiller.json @@ -33,6 +33,76 @@ } }, + "testRandomTest": { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "115792089237316195423570985008687907853269984665640564039457584007913129639935", + "currentGasLimit" : "1000000", + "currentNumber" : "300", + "currentTimestamp" : "2", + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "code" : "0x424443444243434383f0155af055", + "nonce" : "0", + "storage" : { + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "1000000000000000000", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : { + "data" : "", + "gasLimit" : "10000", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "100000" + } + }, + + "createWithInvalidOpcode": { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "115792089237316195423570985008687907853269984665640564039457584007913129639935", + "currentGasLimit" : "1000000", + "currentNumber" : "300", + "currentTimestamp" : "2", + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "pre" : { + "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { + "balance" : "1000000000000000000", + "nonce" : 0, + "code" : "0x444242424245434253f0", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "1000000000000000000", + "nonce" : 0, + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "10000", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "100000", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + "createNameRegistratorOOG_MemExpansionInsufficientBalance": { "env" : { "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", From d78e171ef44db2cfa141ca1c4b3873b2d6d84cf5 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Feb 2015 17:37:56 +0100 Subject: [PATCH 09/10] sha3 performance test --- vmSha3TestFiller.json | 50 +++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/vmSha3TestFiller.json b/vmSha3TestFiller.json index d594d4fe9..851b7aab9 100644 --- a/vmSha3TestFiller.json +++ b/vmSha3TestFiller.json @@ -251,31 +251,31 @@ } }, - "sha3_bigOffset2": { - "env" : { - "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", - "currentNumber" : "0", - "currentGasLimit" : "1000000", - "currentDifficulty" : "256", - "currentTimestamp" : 1, - "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" - }, - "pre" : { - "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", - "nonce" : 0, - "code" : "{ [[ 0 ]] (SHA3 0x100000000 2)}", - "storage": {} - } - }, - "exec" : { - "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", - "value" : "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", - "data" : "", - "gasPrice" : "1", - "gas" : "0x10000000000" + "sha3_bigOffset2": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "1000000", + "currentDifficulty" : "256", + "currentTimestamp" : 1, + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "nonce" : 0, + "code" : "{ [[ 0 ]] (SHA3 0x1000000 2)}", + "storage": {} } + }, + "exec" : { + "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "value" : "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "data" : "", + "gasPrice" : "1", + "gas" : "0x100000000" } + } } From 99ff79159323d8c2129310731d79bac4aeee824e Mon Sep 17 00:00:00 2001 From: Christian Date: Fri, 6 Feb 2015 19:57:08 +0100 Subject: [PATCH 10/10] Accessors for structs. --- SolidityEndToEndTest.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/SolidityEndToEndTest.cpp b/SolidityEndToEndTest.cpp index f248a5a07..301cc06ef 100644 --- a/SolidityEndToEndTest.cpp +++ b/SolidityEndToEndTest.cpp @@ -959,6 +959,24 @@ BOOST_AUTO_TEST_CASE(complex_accessors) BOOST_CHECK(callContractFunction("to_multiple_map(uint256,uint256)", 42, 23) == encodeArgs(31)); } +BOOST_AUTO_TEST_CASE(struct_accessor) +{ + char const* sourceCode = R"( + contract test { + struct Data { uint a; uint8 b; mapping(uint => uint) c; bool d; } + mapping(uint => Data) public data; + function test() { + data[7].a = 1; + data[7].b = 2; + data[7].c[0] = 3; + data[7].d = true; + } + } + )"; + compileAndRun(sourceCode); + BOOST_CHECK(callContractFunction("data(uint256)", 7) == encodeArgs(1, 2, true)); +} + BOOST_AUTO_TEST_CASE(balance) { char const* sourceCode = "contract test {\n"