From 3d199bf4d50206077c0d84122ff0ef70fc174d10 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Tue, 7 Apr 2015 16:56:27 +0200 Subject: [PATCH 01/14] remove wrong stateroot uncle header test --- bcUncleHeaderValiditiyFiller.json | 96 +------------------------------ 1 file changed, 1 insertion(+), 95 deletions(-) diff --git a/bcUncleHeaderValiditiyFiller.json b/bcUncleHeaderValiditiyFiller.json index 9725a3241..edcd298bc 100644 --- a/bcUncleHeaderValiditiyFiller.json +++ b/bcUncleHeaderValiditiyFiller.json @@ -656,101 +656,7 @@ ] }, - "wrongStateRoot" : { - "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "231072", - "extraData" : "0x42", - "gasLimit" : "3141592", - "gasUsed" : "0", - "number" : "0", - "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", - "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", - "timestamp" : "0x54c98c81", - "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "nonce" : "0x0102030405060708", - "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - }, - "pre" : { - "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000000000000", - "nonce" : "0", - "code" : "", - "storage": {} - } - }, - "blocks" : [ - { - "transactions" : [ - { - "data" : "", - "gasLimit" : "314159", - "gasPrice" : "1", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "", - "gasLimit" : "314159", - "gasPrice" : "1", - "nonce" : "1", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "", - "gasLimit" : "314159", - "gasPrice" : "1", - "nonce" : "2", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "10" - } - ], - "uncleHeaders" : [ - { - "overwriteAndRedoPoW" : "stateRoot", - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "coinbase" : "acde5374fce5edbc8e2a8697c15331677e6ebf0b", - "difficulty" : "230848", - "extraData" : "0x", - "gasLimit" : "4141592", - "gasUsed" : "150000", - "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", - "mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", - "nonce" : "18a524c1790fa83b", - "number" : "2", - "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", - "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "stateRoot" : "bad40b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", - "timestamp" : "1528353694", - "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - } - ] - } - ] - }, - - "timestampTooLow" : { + "timestampTooLow" : { "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", From 1b0291c9ee1a3347ea8d668b548508e2bbcecf93 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Thu, 30 Apr 2015 17:34:06 +0200 Subject: [PATCH 02/14] add wallet test From ebef9d43d4b775699a5bfdb0823900cd925d8d1e Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Sat, 2 May 2015 08:55:05 +0200 Subject: [PATCH 03/14] first wallet tests From b7432b8140891f3370d67aa57b9015eceff9c121 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Tue, 5 May 2015 08:00:33 +0200 Subject: [PATCH 04/14] tests for contract multiowned From 6bd430baa1580087b5640af1782cd060a0ea6862 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Tue, 5 May 2015 10:13:41 +0200 Subject: [PATCH 05/14] add day limit tests From dc0c5b74f95c95a14c66c8d6f931d13ae408ddf7 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Tue, 5 May 2015 11:01:06 +0200 Subject: [PATCH 06/14] finish wallet state tests From 76e1df6c9be1e81ae7a251c1d88a6c3279212d7b Mon Sep 17 00:00:00 2001 From: winsvega Date: Tue, 5 May 2015 14:47:36 +0300 Subject: [PATCH 07/14] Solidity: Cryptographic funcs fix From 75982d444f52e864e56daf6054c2f13835b3a961 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Tue, 5 May 2015 15:31:43 +0200 Subject: [PATCH 08/14] add bc wallet test From d2457abb98cbb28037387cb31da8874834a59e4d Mon Sep 17 00:00:00 2001 From: winsvega Date: Tue, 5 May 2015 16:46:01 +0300 Subject: [PATCH 09/14] Specifing concrete test when filling testsuite --- TestHelper.cpp | 6 ++++++ TestHelper.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/TestHelper.cpp b/TestHelper.cpp index eecf6f80d..9e997c495 100644 --- a/TestHelper.cpp +++ b/TestHelper.cpp @@ -741,6 +741,12 @@ Options::Options() inputLimits = true; bigData = true; } + else if (arg.compare(0, 12, "--singletest") == 0) + { + singletest = true; + if (arg.size() > 12) + singletestName = arg.substr(13); // skip '=' char + } } } diff --git a/TestHelper.h b/TestHelper.h index 10e76aa96..6d234abea 100644 --- a/TestHelper.h +++ b/TestHelper.h @@ -188,6 +188,8 @@ public: /// Test selection /// @{ + bool singletest = false; + std::string singletestName; bool performance = false; bool quadratic = false; bool memory = false; From ce40f285f301d70e125020b486b0e9ffdf82d349 Mon Sep 17 00:00:00 2001 From: winsvega Date: Tue, 5 May 2015 18:15:26 +0300 Subject: [PATCH 10/14] Solidity: cryptographic ecrecover test --- TestHelper.cpp | 12 +++++------- TestHelper.h | 4 ++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/TestHelper.cpp b/TestHelper.cpp index 9e997c495..144a1a286 100644 --- a/TestHelper.cpp +++ b/TestHelper.cpp @@ -715,11 +715,10 @@ Options::Options() vmtrace = true; else if (arg == "--filltests") fillTests = true; - else if (arg.compare(0, 7, "--stats") == 0) + else if (arg == "--stats" && i + 1 < argc) { stats = true; - if (arg.size() > 7) - statsOutFile = arg.substr(8); // skip '=' char + statsOutFile = argv[i + 1]; } else if (arg == "--performance") performance = true; @@ -741,11 +740,10 @@ Options::Options() inputLimits = true; bigData = true; } - else if (arg.compare(0, 12, "--singletest") == 0) + else if (arg == "--singletest" && i + 1 < argc) { - singletest = true; - if (arg.size() > 12) - singletestName = arg.substr(13); // skip '=' char + singleTest = true; + singleTestName = argv[i + 1]; } } } diff --git a/TestHelper.h b/TestHelper.h index 6d234abea..02f509e4c 100644 --- a/TestHelper.h +++ b/TestHelper.h @@ -188,8 +188,8 @@ public: /// Test selection /// @{ - bool singletest = false; - std::string singletestName; + bool singleTest = false; + std::string singleTestName; bool performance = false; bool quadratic = false; bool memory = false; From b5127a90de014e22a1f7ef1b4baed0070da733a7 Mon Sep 17 00:00:00 2001 From: winsvega Date: Tue, 5 May 2015 21:43:26 +0300 Subject: [PATCH 11/14] singletest when refill Solidity Contract Inheritance Test From 60f335b40091231dde9e63b2b414e49aff8a7e5c Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 6 May 2015 10:43:59 +0200 Subject: [PATCH 12/14] Structural gas estimator. --- GasMeter.cpp | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 GasMeter.cpp diff --git a/GasMeter.cpp b/GasMeter.cpp new file mode 100644 index 000000000..0ffe41712 --- /dev/null +++ b/GasMeter.cpp @@ -0,0 +1,98 @@ +/* + 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 . +*/ +/** + * @author Christian + * @date 2015 + * Unit tests for the gas estimator. + */ + +#include +#include +#include +#include + +using namespace std; +using namespace dev::eth; +using namespace dev::solidity; + +namespace dev +{ +namespace solidity +{ +namespace test +{ + +class GasMeterTestFramework: public ExecutionFramework +{ +public: + GasMeterTestFramework() { } + void compile(string const& _sourceCode) + { + m_compiler.setSource(_sourceCode); + ETH_TEST_REQUIRE_NO_THROW(m_compiler.compile(), "Compiling contract failed"); + + StructuralGasEstimator estimator; + AssemblyItems const* items = m_compiler.getRuntimeAssemblyItems(""); + ASTNode const& sourceUnit = m_compiler.getAST(); + BOOST_REQUIRE(items != nullptr); + m_gasCosts = estimator.breakToStatementLevel( + estimator.performEstimation(*items, vector({&sourceUnit})), + {&sourceUnit} + ); + } + +protected: + dev::solidity::CompilerStack m_compiler; + map m_gasCosts; +}; + +BOOST_FIXTURE_TEST_SUITE(GasMeterTests, GasMeterTestFramework) + +BOOST_AUTO_TEST_CASE(non_overlapping_filtered_costs) +{ + char const* sourceCode = R"( + contract test { + bytes x; + function f(uint a) returns (uint b) { + x.length = a; + for (; a < 200; ++a) { + x[a] = 9; + b = a * a; + } + return f(a - 1); + } + } + )"; + compile(sourceCode); + for (auto first = m_gasCosts.cbegin(); first != m_gasCosts.cend(); ++first) + { + auto second = first; + for (++second; second != m_gasCosts.cend(); ++second) + if (first->first->getLocation().intersects(second->first->getLocation())) + { + BOOST_CHECK_MESSAGE(false, "Source locations should not overlap!"); + SourceReferenceFormatter::printSourceLocation(cout, first->first->getLocation(), m_compiler.getScanner()); + SourceReferenceFormatter::printSourceLocation(cout, second->first->getLocation(), m_compiler.getScanner()); + } + } +} + +BOOST_AUTO_TEST_SUITE_END() + +} +} +} From ef50b08910d807aa03b0104df637e6c03841a6ed Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 6 May 2015 15:54:47 +0200 Subject: [PATCH 13/14] Initial stab at KeyManager. From d4cf0a54380e980dd850fca7ec45476fc652d353 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Thu, 7 May 2015 11:01:56 +0200 Subject: [PATCH 14/14] gasPrice 0 test