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

Commit

Permalink
testeth legacy blockchain tests suite (#5801)
Browse files Browse the repository at this point in the history
testeth legacy blockchain tests suite
  • Loading branch information
gumb0 authored Nov 6, 2019
2 parents 99b069c + e3a4ca1 commit 39faebc
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 41 deletions.
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.
- Changed: [#5806](https://github.com/ethereum/aleth/pull/5806) Optimize selfdestruct opcode in aleth-interpreter 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.
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>
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

0 comments on commit 39faebc

Please sign in to comment.