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
Browse files Browse the repository at this point in the history
  • Loading branch information
winsvega authored and gumb0 committed Nov 5, 2019
1 parent 0a311f1 commit 60e17b8
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 38 deletions.
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, bcValidTestFixture<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, bcInvalidTestFixture<test::BlockchainInvalidTestSuite>)
BOOST_AUTO_TEST_CASE(bcBlockGasLimitTest) {}
BOOST_AUTO_TEST_CASE(bcForgedTest) {}
BOOST_AUTO_TEST_CASE(bcInvalidHeaderTest) {}
Expand Down
46 changes: 46 additions & 0 deletions test/tools/jsontests/BlockChainTests.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,52 @@ class bcGeneralTestsFixture : public StateTestFixtureBase<BCGeneralStateTestsSui
bcGeneralTestsFixture() : StateTestFixtureBase({TestExecution::RequireOptionAll}) {}
};

template <class T>
class bcValidTestFixture
{
public:
bcValidTestFixture(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 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 T>
class bcInvalidTestFixture
{
public:
bcInvalidTestFixture(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 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;
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 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<StateTestSuiteLegacyConstantinople>
Expand All @@ -56,6 +80,22 @@ class LegacyConstantinopleBCGeneralStateTestFixture
{}
};

class LegacyConstantinoplebcInvalidTestFixture
: public bcInvalidTestFixture<BlockchainInvalidTestSuiteLegacyConstantinople>
{
public:
LegacyConstantinoplebcInvalidTestFixture()
: bcInvalidTestFixture({TestExecution::NotRefillable})
{}
};

class LegacyConstantinoplebcValidTestFixture
: public bcValidTestFixture<BlockchainValidTestSuiteLegacyConstantinople>
{
public:
LegacyConstantinoplebcValidTestFixture() : bcValidTestFixture({TestExecution::NotRefillable}) {}
};


} // namespace test
} // namespace dev

0 comments on commit 60e17b8

Please sign in to comment.