Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

testeth legacy blockchain tests suite #5801

Merged
merged 4 commits into from
Nov 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
2 changes: 1 addition & 1 deletion test/jsontests
Submodule jsontests updated 1220 files
40 changes: 2 additions & 38 deletions test/tools/jsontests/BlockChainTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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, bcTestFixture<test::BlockchainValidTestSuite>)
BOOST_AUTO_TEST_CASE(bcBlockGasLimitTest) {}
BOOST_AUTO_TEST_CASE(bcExploitTest) {}
BOOST_AUTO_TEST_CASE(bcForkStressTest) {}
Expand All @@ -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, bcTestFixture<test::BlockchainInvalidTestSuite>)
BOOST_AUTO_TEST_CASE(bcBlockGasLimitTest) {}
BOOST_AUTO_TEST_CASE(bcForgedTest) {}
BOOST_AUTO_TEST_CASE(bcInvalidHeaderTest) {}
Expand Down
27 changes: 27 additions & 0 deletions test/tools/jsontests/BlockChainTests.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,33 @@ class bcGeneralTestsFixture : public StateTestFixtureBase<BCGeneralStateTestsSui
bcGeneralTestsFixture() : StateTestFixtureBase({TestExecution::RequireOptionAll}) {}
};

template <class T>
Copy link
Member

@gumb0 gumb0 Oct 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can easy get rid of duplication here like this

template <class T>
class BlockChainTestFixture
{
public:
    BlockChainTestFixture(std::set<TestExecution> const& _execFlags = {}, std::vector<std::string> const& _timeConsumingCases)
    {
        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 const suiteFillerPath = suite.getFullPathFiller(casename).parent_path();

        // skip time consuming tests, unless --all option is given
        if (!test::Options::get().all && contains(_timeConsumingCases, casename))
        {
            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 BlockChainValidBlocksTestFixture
  : public BlockChainTestFixture<BlockchainValidTestSuite>
{
public:
    BlockChainValidBlocksTestFixture()
      : BlockChainValidBlocksTestFixture({TestExecution::NotRefillable}, {"bcWalletTest"})
    {}
};

Copy link
Member

@gumb0 gumb0 Oct 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, if stWallet exists in only in either valid or invalid suite, you can use the exact same code with stWallet check for both suites (it won't skip stWallet if it doesn't exist there)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is ok to use just one fixture class in this case

class bcTestFixture
{
public:
bcTestFixture(std::set<TestExecution> 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 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)
{
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 TransitionTestsSuite: public TestSuite
{
json_spirit::mValue doTests(json_spirit::mValue const& _input, bool _fillin) const override;
Expand Down
31 changes: 31 additions & 0 deletions test/tools/jsontests/LegacyTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
40 changes: 40 additions & 0 deletions test/tools/jsontests/LegacyTests.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,30 @@ class BCGeneralStateTestsSuiteLegacyConstantinople : public BCGeneralStateTestsS
}
};

class LegacyConstantinopleBlockchainInvalidTestSuite : 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 LegacyConstantinopleBlockchainValidTestSuite : 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<StateTestSuiteLegacyConstantinople>
Expand All @@ -56,6 +80,22 @@ class LegacyConstantinopleBCGeneralStateTestFixture
{}
};

class LegacyConstantinoplebcInvalidTestFixture
: public bcTestFixture<LegacyConstantinopleBlockchainInvalidTestSuite>
{
public:
LegacyConstantinoplebcInvalidTestFixture()
: bcTestFixture({TestExecution::NotRefillable})
{}
};

class LegacyConstantinoplebcValidTestFixture
: public bcTestFixture<LegacyConstantinopleBlockchainValidTestSuite>
{
public:
LegacyConstantinoplebcValidTestFixture() : bcTestFixture({TestExecution::NotRefillable}) {}
};


} // namespace test
} // namespace dev
4 changes: 2 additions & 2 deletions test/unittests/libethereum/GasPricer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down