From 60e17b8904ac42846b35d6394f9e5298a5fb8cef Mon Sep 17 00:00:00 2001 From: Dimitry Kh Date: Mon, 28 Oct 2019 19:58:57 +0300 Subject: [PATCH 1/4] testeth legacy blockchain tests suite --- test/tools/jsontests/BlockChainTests.cpp | 40 ++------------------- test/tools/jsontests/BlockChainTests.h | 46 ++++++++++++++++++++++++ test/tools/jsontests/LegacyTests.cpp | 31 ++++++++++++++++ test/tools/jsontests/LegacyTests.h | 40 +++++++++++++++++++++ 4 files changed, 119 insertions(+), 38 deletions(-) diff --git a/test/tools/jsontests/BlockChainTests.cpp b/test/tools/jsontests/BlockChainTests.cpp index 750b1a92f39..6be80f9c610 100644 --- a/test/tools/jsontests/BlockChainTests.cpp +++ b/test/tools/jsontests/BlockChainTests.cpp @@ -1047,42 +1047,6 @@ void checkBlocks(TestBlock const& _blockFromFields, TestBlock const& _blockFromR } } -class bcValidTestFixture -{ -public: - bcValidTestFixture() - { - test::BlockchainValidTestSuite suite; - string const casename = boost::unit_test::framework::current_test_case().p_name; - boost::filesystem::path suiteFillerPath = suite.getFullPathFiller(casename).parent_path(); - - //skip wallet test as it takes too much time (250 blocks) run it with --all flag - if (casename == "bcWalletTest" && !test::Options::get().all) - { - cnote << "Skipping " << casename << " because --all option is not specified.\n"; - test::TestOutputHelper::get().markTestFolderAsFinished(suiteFillerPath, casename); - return; - } - - suite.runAllTestsInFolder(casename); - test::TestOutputHelper::get().markTestFolderAsFinished(suiteFillerPath, casename); - } -}; - -class bcInvalidTestFixture -{ -public: - bcInvalidTestFixture() - { - test::BlockchainInvalidTestSuite suite; - string const casename = boost::unit_test::framework::current_test_case().p_name; - boost::filesystem::path suiteFillerPath = suite.getFullPathFiller(casename).parent_path(); - - suite.runAllTestsInFolder(casename); - test::TestOutputHelper::get().markTestFolderAsFinished(suiteFillerPath, casename); - } -}; - class bcTransitionFixture { public: bcTransitionFixture() @@ -1098,7 +1062,7 @@ class bcTransitionFixture { BOOST_AUTO_TEST_SUITE(BlockchainTests) // Tests that contain only valid blocks and check that import is correct -BOOST_FIXTURE_TEST_SUITE(ValidBlocks, bcValidTestFixture) +BOOST_FIXTURE_TEST_SUITE(ValidBlocks, bcValidTestFixture) BOOST_AUTO_TEST_CASE(bcBlockGasLimitTest) {} BOOST_AUTO_TEST_CASE(bcExploitTest) {} BOOST_AUTO_TEST_CASE(bcForkStressTest) {} @@ -1114,7 +1078,7 @@ BOOST_AUTO_TEST_CASE(bcWalletTest) {} BOOST_AUTO_TEST_SUITE_END() // Tests that might have invalid blocks and check that those are rejected -BOOST_FIXTURE_TEST_SUITE(InvalidBlocks, bcInvalidTestFixture) +BOOST_FIXTURE_TEST_SUITE(InvalidBlocks, bcInvalidTestFixture) BOOST_AUTO_TEST_CASE(bcBlockGasLimitTest) {} BOOST_AUTO_TEST_CASE(bcForgedTest) {} BOOST_AUTO_TEST_CASE(bcInvalidHeaderTest) {} diff --git a/test/tools/jsontests/BlockChainTests.h b/test/tools/jsontests/BlockChainTests.h index 9a34444c44c..1242a18400c 100644 --- a/test/tools/jsontests/BlockChainTests.h +++ b/test/tools/jsontests/BlockChainTests.h @@ -44,6 +44,52 @@ class bcGeneralTestsFixture : public StateTestFixtureBase +class bcValidTestFixture +{ +public: + bcValidTestFixture(std::set const& _execFlags = {}) + { + T suite; + if (_execFlags.count(TestExecution::NotRefillable) && + (Options::get().fillchain || Options::get().filltests)) + BOOST_FAIL("Tests are sealed and not refillable!"); + + string const casename = boost::unit_test::framework::current_test_case().p_name; + boost::filesystem::path suiteFillerPath = suite.getFullPathFiller(casename).parent_path(); + + // skip wallet test as it takes too much time (250 blocks) run it with --all flag + if (casename == "bcWalletTest" && !test::Options::get().all) + { + cnote << "Skipping " << casename << " because --all option is not specified.\n"; + test::TestOutputHelper::get().markTestFolderAsFinished(suiteFillerPath, casename); + return; + } + + suite.runAllTestsInFolder(casename); + test::TestOutputHelper::get().markTestFolderAsFinished(suiteFillerPath, casename); + } +}; + +template +class bcInvalidTestFixture +{ +public: + bcInvalidTestFixture(std::set const& _execFlags = {}) + { + T suite; + if (_execFlags.count(TestExecution::NotRefillable) && + (Options::get().fillchain || Options::get().filltests)) + BOOST_FAIL("Tests are sealed and not refillable!"); + + string const casename = boost::unit_test::framework::current_test_case().p_name; + boost::filesystem::path suiteFillerPath = suite.getFullPathFiller(casename).parent_path(); + + suite.runAllTestsInFolder(casename); + test::TestOutputHelper::get().markTestFolderAsFinished(suiteFillerPath, casename); + } +}; + class TransitionTestsSuite: public TestSuite { json_spirit::mValue doTests(json_spirit::mValue const& _input, bool _fillin) const override; diff --git a/test/tools/jsontests/LegacyTests.cpp b/test/tools/jsontests/LegacyTests.cpp index b682a84a486..1a8f5246963 100644 --- a/test/tools/jsontests/LegacyTests.cpp +++ b/test/tools/jsontests/LegacyTests.cpp @@ -150,5 +150,36 @@ BOOST_AUTO_TEST_CASE(stArgsZeroOneBalance) {} BOOST_AUTO_TEST_CASE(stTimeConsuming) {} BOOST_AUTO_TEST_SUITE_END() // BCGeneralStateTests Constantinople Legacy + +BOOST_AUTO_TEST_SUITE(BlockchainTests) +// Tests that contain only valid blocks and check that import is correct +BOOST_FIXTURE_TEST_SUITE(ValidBlocks, LegacyConstantinoplebcValidTestFixture) +BOOST_AUTO_TEST_CASE(bcBlockGasLimitTest) {} +BOOST_AUTO_TEST_CASE(bcExploitTest) {} +BOOST_AUTO_TEST_CASE(bcForkStressTest) {} +BOOST_AUTO_TEST_CASE(bcGasPricerTest) {} +BOOST_AUTO_TEST_CASE(bcMultiChainTest) {} +BOOST_AUTO_TEST_CASE(bcRandomBlockhashTest) {} +BOOST_AUTO_TEST_CASE(bcStateTests) {} +BOOST_AUTO_TEST_CASE(bcTotalDifficultyTest) {} +BOOST_AUTO_TEST_CASE(bcUncleSpecialTests) {} +BOOST_AUTO_TEST_CASE(bcUncleTest) {} +BOOST_AUTO_TEST_CASE(bcValidBlockTest) {} +BOOST_AUTO_TEST_CASE(bcWalletTest) {} +BOOST_AUTO_TEST_SUITE_END() + +// Tests that might have invalid blocks and check that those are rejected +BOOST_FIXTURE_TEST_SUITE(InvalidBlocks, LegacyConstantinoplebcInvalidTestFixture) +BOOST_AUTO_TEST_CASE(bcBlockGasLimitTest) {} +BOOST_AUTO_TEST_CASE(bcForgedTest) {} +BOOST_AUTO_TEST_CASE(bcInvalidHeaderTest) {} +BOOST_AUTO_TEST_CASE(bcMultiChainTest) {} +BOOST_AUTO_TEST_CASE(bcUncleHeaderValidity) {} +BOOST_AUTO_TEST_CASE(bcUncleSpecialTests) {} +BOOST_AUTO_TEST_CASE(bcUncleTest) {} +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() // BlockchainTests + + BOOST_AUTO_TEST_SUITE_END() // Constantinople BOOST_AUTO_TEST_SUITE_END() // LegacyTests diff --git a/test/tools/jsontests/LegacyTests.h b/test/tools/jsontests/LegacyTests.h index 966080ea557..2c71246fee6 100644 --- a/test/tools/jsontests/LegacyTests.h +++ b/test/tools/jsontests/LegacyTests.h @@ -37,6 +37,30 @@ class BCGeneralStateTestsSuiteLegacyConstantinople : public BCGeneralStateTestsS } }; +class BlockchainInvalidTestSuiteLegacyConstantinople : public BlockchainInvalidTestSuite +{ + boost::filesystem::path suiteFolder() const override + { + return "LegacyTests/Constantinople/BlockchainTests/InvalidBlocks"; + } + boost::filesystem::path suiteFillerFolder() const override + { + return "LegacyTests/Constantinople/BlockchainTestsFiller/InvalidBlocks"; + } +}; + +class BlockchainValidTestSuiteLegacyConstantinople : public BlockchainValidTestSuite +{ + boost::filesystem::path suiteFolder() const override + { + return "LegacyTests/Constantinople/BlockchainTests/ValidBlocks"; + } + boost::filesystem::path suiteFillerFolder() const override + { + return "LegacyTests/Constantinople/BlockchainTestsFiller/ValidBlocks"; + } +}; + class LegacyConstantinopleGeneralStateTestFixture : public StateTestFixtureBase @@ -56,6 +80,22 @@ class LegacyConstantinopleBCGeneralStateTestFixture {} }; +class LegacyConstantinoplebcInvalidTestFixture + : public bcInvalidTestFixture +{ +public: + LegacyConstantinoplebcInvalidTestFixture() + : bcInvalidTestFixture({TestExecution::NotRefillable}) + {} +}; + +class LegacyConstantinoplebcValidTestFixture + : public bcValidTestFixture +{ +public: + LegacyConstantinoplebcValidTestFixture() : bcValidTestFixture({TestExecution::NotRefillable}) {} +}; + } // namespace test } // namespace dev From c57272b9b106e4d87152f922b66cf3b017b818c7 Mon Sep 17 00:00:00 2001 From: Dimitry Kh Date: Mon, 28 Oct 2019 22:00:41 +0300 Subject: [PATCH 2/4] update tests subrepo head --- test/jsontests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/jsontests b/test/jsontests index b5eb9900ee2..f5afc396353 160000 --- a/test/jsontests +++ b/test/jsontests @@ -1 +1 @@ -Subproject commit b5eb9900ee2147b40d3e681fe86efa4fd693959a +Subproject commit f5afc3963535be4b8bc4a8086f2bfb3c911d6517 From 8e49ea92a7fa5a64c00c75f4d355118c1cfb2be5 Mon Sep 17 00:00:00 2001 From: Dimitry Kh Date: Mon, 28 Oct 2019 23:45:25 +0300 Subject: [PATCH 3/4] use LegacyTests fir GasPricer unittests --- test/unittests/libethereum/GasPricer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unittests/libethereum/GasPricer.cpp b/test/unittests/libethereum/GasPricer.cpp index c3199b7c6b0..0a8af6dc8a7 100644 --- a/test/unittests/libethereum/GasPricer.cpp +++ b/test/unittests/libethereum/GasPricer.cpp @@ -19,8 +19,8 @@ using namespace dev::eth; using namespace dev::test; namespace fs = boost::filesystem; -const string c_pathToValidBlocks = "/BlockchainTests/ValidBlocks/"; -const string c_pathToInValidBlocks = "/BlockchainTests/InvalidBlocks/"; +const string c_pathToValidBlocks = "/LegacyTests/Constantinople/BlockchainTests/ValidBlocks/"; +const string c_pathToInValidBlocks = "/LegacyTests/Constantinople/BlockchainTests/InvalidBlocks/"; namespace dev { namespace test { From e3a4ca1ec9ca2772b40217c9a56bc0a254c12060 Mon Sep 17 00:00:00 2001 From: Dimitry Kh Date: Sun, 3 Nov 2019 18:35:10 +0300 Subject: [PATCH 4/4] adress Andrey's comments --- CHANGELOG.md | 1 + test/tools/jsontests/BlockChainTests.cpp | 4 ++-- test/tools/jsontests/BlockChainTests.h | 25 +++--------------------- test/tools/jsontests/LegacyTests.h | 12 ++++++------ 4 files changed, 12 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a5ecf0f928..c93111cefcc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Added: [#5699](https://github.com/ethereum/aleth/pull/5699) EIP 2046: Reduced gas cost for static calls made to precompiles. - Added: [#5752](https://github.com/ethereum/aleth/pull/5752) [#5753](https://github.com/ethereum/aleth/pull/5753) Implement EIP1380 (reduced gas costs for call-to-self). +- Changed: [#5801](https://github.com/ethereum/aleth/pull/5801) `testeth -t BlockchainTests` command now doesn't run the tests for the forks before Istanbul. To run those tests use a separate LegacyTests suite with command `testeth -t LegacyTests/Constantinople/BlockchainTests`. - Changed: [#5807](https://github.com/ethereum/aleth/pull/5807) Optimize selfdestruct opcode in LegacyVM by reducing state accesses in certain out-of-gas scenarios. - Removed: [#5760](https://github.com/ethereum/aleth/pull/5760) Official support for Visual Studio 2015 has been dropped. Compilation with this compiler is expected to stop working after migration to C++14. - Fixed: [#5792](https://github.com/ethereum/aleth/pull/5792) Faster and cheaper execution of RPC functions which query blockchain state (e.g. getBalance). diff --git a/test/tools/jsontests/BlockChainTests.cpp b/test/tools/jsontests/BlockChainTests.cpp index 6be80f9c610..3c285b260bd 100644 --- a/test/tools/jsontests/BlockChainTests.cpp +++ b/test/tools/jsontests/BlockChainTests.cpp @@ -1062,7 +1062,7 @@ class bcTransitionFixture { BOOST_AUTO_TEST_SUITE(BlockchainTests) // Tests that contain only valid blocks and check that import is correct -BOOST_FIXTURE_TEST_SUITE(ValidBlocks, bcValidTestFixture) +BOOST_FIXTURE_TEST_SUITE(ValidBlocks, bcTestFixture) BOOST_AUTO_TEST_CASE(bcBlockGasLimitTest) {} BOOST_AUTO_TEST_CASE(bcExploitTest) {} BOOST_AUTO_TEST_CASE(bcForkStressTest) {} @@ -1078,7 +1078,7 @@ BOOST_AUTO_TEST_CASE(bcWalletTest) {} BOOST_AUTO_TEST_SUITE_END() // Tests that might have invalid blocks and check that those are rejected -BOOST_FIXTURE_TEST_SUITE(InvalidBlocks, bcInvalidTestFixture) +BOOST_FIXTURE_TEST_SUITE(InvalidBlocks, bcTestFixture) BOOST_AUTO_TEST_CASE(bcBlockGasLimitTest) {} BOOST_AUTO_TEST_CASE(bcForgedTest) {} BOOST_AUTO_TEST_CASE(bcInvalidHeaderTest) {} diff --git a/test/tools/jsontests/BlockChainTests.h b/test/tools/jsontests/BlockChainTests.h index 1242a18400c..a9fc6cb6e2f 100644 --- a/test/tools/jsontests/BlockChainTests.h +++ b/test/tools/jsontests/BlockChainTests.h @@ -45,10 +45,10 @@ class bcGeneralTestsFixture : public StateTestFixtureBase -class bcValidTestFixture +class bcTestFixture { public: - bcValidTestFixture(std::set const& _execFlags = {}) + bcTestFixture(std::set const& _execFlags = {}) { T suite; if (_execFlags.count(TestExecution::NotRefillable) && @@ -56,7 +56,7 @@ class bcValidTestFixture BOOST_FAIL("Tests are sealed and not refillable!"); string const casename = boost::unit_test::framework::current_test_case().p_name; - boost::filesystem::path suiteFillerPath = suite.getFullPathFiller(casename).parent_path(); + boost::filesystem::path const suiteFillerPath = suite.getFullPathFiller(casename).parent_path(); // skip wallet test as it takes too much time (250 blocks) run it with --all flag if (casename == "bcWalletTest" && !test::Options::get().all) @@ -71,25 +71,6 @@ class bcValidTestFixture } }; -template -class bcInvalidTestFixture -{ -public: - bcInvalidTestFixture(std::set const& _execFlags = {}) - { - T suite; - if (_execFlags.count(TestExecution::NotRefillable) && - (Options::get().fillchain || Options::get().filltests)) - BOOST_FAIL("Tests are sealed and not refillable!"); - - string const casename = boost::unit_test::framework::current_test_case().p_name; - boost::filesystem::path suiteFillerPath = suite.getFullPathFiller(casename).parent_path(); - - suite.runAllTestsInFolder(casename); - test::TestOutputHelper::get().markTestFolderAsFinished(suiteFillerPath, casename); - } -}; - class TransitionTestsSuite: public TestSuite { json_spirit::mValue doTests(json_spirit::mValue const& _input, bool _fillin) const override; diff --git a/test/tools/jsontests/LegacyTests.h b/test/tools/jsontests/LegacyTests.h index 2c71246fee6..106d9386ed3 100644 --- a/test/tools/jsontests/LegacyTests.h +++ b/test/tools/jsontests/LegacyTests.h @@ -37,7 +37,7 @@ class BCGeneralStateTestsSuiteLegacyConstantinople : public BCGeneralStateTestsS } }; -class BlockchainInvalidTestSuiteLegacyConstantinople : public BlockchainInvalidTestSuite +class LegacyConstantinopleBlockchainInvalidTestSuite : public BlockchainInvalidTestSuite { boost::filesystem::path suiteFolder() const override { @@ -49,7 +49,7 @@ class BlockchainInvalidTestSuiteLegacyConstantinople : public BlockchainInvalidT } }; -class BlockchainValidTestSuiteLegacyConstantinople : public BlockchainValidTestSuite +class LegacyConstantinopleBlockchainValidTestSuite : public BlockchainValidTestSuite { boost::filesystem::path suiteFolder() const override { @@ -81,19 +81,19 @@ class LegacyConstantinopleBCGeneralStateTestFixture }; class LegacyConstantinoplebcInvalidTestFixture - : public bcInvalidTestFixture + : public bcTestFixture { public: LegacyConstantinoplebcInvalidTestFixture() - : bcInvalidTestFixture({TestExecution::NotRefillable}) + : bcTestFixture({TestExecution::NotRefillable}) {} }; class LegacyConstantinoplebcValidTestFixture - : public bcValidTestFixture + : public bcTestFixture { public: - LegacyConstantinoplebcValidTestFixture() : bcValidTestFixture({TestExecution::NotRefillable}) {} + LegacyConstantinoplebcValidTestFixture() : bcTestFixture({TestExecution::NotRefillable}) {} };