-
Notifications
You must be signed in to change notification settings - Fork 2.1k
split BlockchainTests into Valid and Invalid #5648
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,7 +59,8 @@ namespace test { | |
| eth::Network ChainBranch::s_tempBlockchainNetwork = eth::Network::MainNetwork; | ||
| eth::Network TestBlockChain::s_sealEngineNetwork = eth::Network::FrontierTest; | ||
|
|
||
| json_spirit::mValue BlockchainTestSuite::doTests(json_spirit::mValue const& _input, bool _fillin) const | ||
| json_spirit::mValue doBCTest( | ||
| json_spirit::mValue const& _input, bool _fillin, bool _allowInvalidBlocks) | ||
| { | ||
| json_spirit::mObject tests; | ||
| for (auto const& i : _input.get_obj()) | ||
|
|
@@ -122,7 +123,7 @@ json_spirit::mValue BlockchainTestSuite::doTests(json_spirit::mValue const& _inp | |
| std::cout << "Filling " << newtestname << std::endl; | ||
|
|
||
| TestOutputHelper::get().setCurrentTestName(newtestname); | ||
| jObjOutput = fillBCTest(jObjOutput); | ||
| jObjOutput = fillBCTest(jObjOutput, _allowInvalidBlocks); | ||
| jObjOutput["network"] = test::netIdToString(network); | ||
| if (inputTest.count("_info")) | ||
| jObjOutput["_info"] = inputTest.at("_info"); | ||
|
|
@@ -161,13 +162,34 @@ json_spirit::mValue BlockchainTestSuite::doTests(json_spirit::mValue const& _inp | |
|
|
||
| return tests; | ||
| } | ||
| fs::path BlockchainTestSuite::suiteFolder() const | ||
|
|
||
| json_spirit::mValue BlockchainValidTestSuite::doTests( | ||
| json_spirit::mValue const& _input, bool _fillin) const | ||
| { | ||
| return doBCTest(_input, _fillin, false); | ||
| } | ||
|
|
||
| json_spirit::mValue BlockchainInvalidTestSuite::doTests( | ||
| json_spirit::mValue const& _input, bool _fillin) const | ||
| { | ||
| return doBCTest(_input, _fillin, true); | ||
| } | ||
|
|
||
| fs::path BlockchainInvalidTestSuite::suiteFolder() const | ||
| { | ||
| return "BlockchainTests"; | ||
| return fs::path("BlockchainTests") / "InvalidBlocks"; | ||
| } | ||
| fs::path BlockchainTestSuite::suiteFillerFolder() const | ||
| fs::path BlockchainInvalidTestSuite::suiteFillerFolder() const | ||
| { | ||
| return "BlockchainTestsFiller"; | ||
| return fs::path("BlockchainTestsFiller") / "InvalidBlocks"; | ||
| } | ||
| fs::path BlockchainValidTestSuite::suiteFolder() const | ||
| { | ||
| return fs::path("BlockchainTests") / "ValidBlocks"; | ||
| } | ||
| fs::path BlockchainValidTestSuite::suiteFillerFolder() const | ||
| { | ||
| return fs::path("BlockchainTestsFiller") / "ValidBlocks"; | ||
| } | ||
| fs::path BCGeneralStateTestsSuite::suiteFolder() const | ||
| { | ||
|
|
@@ -253,7 +275,7 @@ void ChainBranch::resetBlockchain() | |
| dev::test::TestBlockChain::s_sealEngineNetwork = s_tempBlockchainNetwork; | ||
| } | ||
|
|
||
| json_spirit::mObject fillBCTest(json_spirit::mObject const& _input) | ||
| json_spirit::mObject fillBCTest(json_spirit::mObject const& _input, bool _allowInvalidBlocks) | ||
| { | ||
| json_spirit::mObject output; | ||
| string const& testName = TestOutputHelper::get().testName(); | ||
|
|
@@ -389,6 +411,7 @@ json_spirit::mObject fillBCTest(json_spirit::mObject const& _input) | |
| blObj["uncleHeaders"] = aUncleList; | ||
| blObj["transactions"] = writeTransactionsToJson(alterBlock.transactionQueue()); | ||
|
|
||
| bool blockImportExceptionHappen = false; | ||
| compareBlocks(block, alterBlock); | ||
| try | ||
| { | ||
|
|
@@ -416,19 +439,25 @@ json_spirit::mObject fillBCTest(json_spirit::mObject const& _input) | |
| cnote << testName + "block import throw an exception: " << diagnostic_information(_e); | ||
| checkExpectedException(blObj, _e); | ||
| eraseJsonSectionForInvalidBlock(blObj); | ||
| blockImportExceptionHappen = true; | ||
| } | ||
| catch (std::exception const& _e) | ||
| { | ||
| cnote << testName + "block import throw an exception: " << _e.what(); | ||
| cout << testName + "block import thrown std exeption\n"; | ||
| eraseJsonSectionForInvalidBlock(blObj); | ||
| blockImportExceptionHappen = true; | ||
| } | ||
| catch (...) | ||
| { | ||
| cout << testName + "block import thrown unknown exeption\n"; | ||
| eraseJsonSectionForInvalidBlock(blObj); | ||
| blockImportExceptionHappen = true; | ||
| } | ||
|
|
||
| if (!_allowInvalidBlocks && blockImportExceptionHappen) | ||
| BOOST_ERROR("Mined block expected to be valid! " + testName); | ||
|
|
||
| blArray.push_back(blObj); //json data | ||
| }//each blocks | ||
|
|
||
|
|
@@ -1003,11 +1032,12 @@ void checkBlocks(TestBlock const& _blockFromFields, TestBlock const& _blockFromR | |
| } | ||
| } | ||
|
|
||
| class bcTestFixture { | ||
| class bcValidTestFixture | ||
| { | ||
| public: | ||
| bcTestFixture() | ||
| bcValidTestFixture() | ||
| { | ||
| test::BlockchainTestSuite suite; | ||
| test::BlockchainValidTestSuite suite; | ||
| string const casename = boost::unit_test::framework::current_test_case().p_name; | ||
| boost::filesystem::path suiteFillerPath = suite.getFullPathFiller(casename).parent_path(); | ||
|
|
||
|
|
@@ -1024,6 +1054,20 @@ class bcTestFixture { | |
| } | ||
| }; | ||
|
|
||
| class bcInvalidTestFixture | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This class is almost identical to the one above, it looks like you could have a base class common for both to avoid code repetition. Just a suggestion.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a plan for malicious block blockchain testsing, when the test tool will produce invlid block rlps and try to import. |
||
| { | ||
| 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() | ||
|
|
@@ -1057,34 +1101,44 @@ class bcGeneralTestsFixture | |
| } | ||
| }; | ||
|
|
||
| BOOST_FIXTURE_TEST_SUITE(BlockchainTests, bcTestFixture) | ||
|
|
||
| BOOST_AUTO_TEST_CASE(bcStateTests){} | ||
| BOOST_AUTO_TEST_CASE(bcBlockGasLimitTest){} | ||
| BOOST_AUTO_TEST_CASE(bcGasPricerTest){} | ||
| BOOST_AUTO_TEST_CASE(bcInvalidHeaderTest){} | ||
| BOOST_AUTO_TEST_CASE(bcUncleHeaderValidity){} | ||
| BOOST_AUTO_TEST_CASE(bcUncleTest){} | ||
| BOOST_AUTO_TEST_CASE(bcValidBlockTest){} | ||
| BOOST_AUTO_TEST_CASE(bcWalletTest){} | ||
| BOOST_AUTO_TEST_CASE(bcTotalDifficultyTest){} | ||
| BOOST_AUTO_TEST_CASE(bcMultiChainTest){} | ||
| BOOST_AUTO_TEST_CASE(bcForkStressTest){} | ||
| BOOST_AUTO_TEST_CASE(bcForgedTest){} | ||
| BOOST_AUTO_TEST_CASE(bcRandomBlockhashTest){} | ||
| BOOST_AUTO_TEST_CASE(bcExploitTest){} | ||
| BOOST_AUTO_TEST_CASE(bcUncleSpecialTests){} | ||
|
|
||
| BOOST_AUTO_TEST_SUITE(BlockchainTests) | ||
|
|
||
| // Tests that contain only valid blocks and check that import is correct | ||
| BOOST_FIXTURE_TEST_SUITE(ValidBlocks, bcValidTestFixture) | ||
| 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() | ||
|
|
||
| //Transition from fork to fork tests | ||
| BOOST_FIXTURE_TEST_SUITE(TransitionTests, bcTransitionFixture) | ||
| // Tests that might have invalid blocks and check that those are rejected | ||
| BOOST_FIXTURE_TEST_SUITE(InvalidBlocks, bcInvalidTestFixture) | ||
| 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_CASE(bcFrontierToHomestead){} | ||
| BOOST_AUTO_TEST_CASE(bcHomesteadToDao){} | ||
| BOOST_AUTO_TEST_CASE(bcHomesteadToEIP150){} | ||
| BOOST_AUTO_TEST_CASE(bcEIP158ToByzantium){} | ||
| // Transition from fork to fork tests | ||
| BOOST_FIXTURE_TEST_SUITE(TransitionTests, bcTransitionFixture) | ||
| BOOST_AUTO_TEST_CASE(bcByzantiumToConstantinopleFix) {} | ||
| BOOST_AUTO_TEST_CASE(bcEIP158ToByzantium) {} | ||
| BOOST_AUTO_TEST_CASE(bcFrontierToHomestead) {} | ||
| BOOST_AUTO_TEST_CASE(bcHomesteadToDao) {} | ||
| BOOST_AUTO_TEST_CASE(bcHomesteadToEIP150) {} | ||
| BOOST_AUTO_TEST_SUITE_END() | ||
|
|
||
| BOOST_AUTO_TEST_SUITE_END() | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,6 +60,7 @@ class TestOutputHelper | |
| TestOutputHelper() {} | ||
| void checkUnfinishedTestFolders(); // Checkup that all test folders are active during the test | ||
| // run | ||
| std::string detectFilterForMinusTArgument(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is not needed anymore? |
||
| Timer m_timer; | ||
| size_t m_currTest; | ||
| size_t m_maxTests; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -95,95 +95,95 @@ BOOST_AUTO_TEST_CASE(basicGasPricer_RPC_API_Test_Frontier) | |
| { | ||
| u256 _expectedAsk = 16056883295; | ||
| u256 _expectedBid = 1; | ||
| dev::test::executeGasPricerTest("RPC_API_Test_Frontier", 30.679, 15.0, "/BlockchainTests/bcGasPricerTest/RPC_API_Test.json", TransactionPriority::Medium, _expectedAsk, _expectedBid, eth::Network::FrontierTest); | ||
| dev::test::executeGasPricerTest("RPC_API_Test_Frontier", 30.679, 15.0, "/BlockchainTests/ValidBlocks/bcGasPricerTest/RPC_API_Test.json", TransactionPriority::Medium, _expectedAsk, _expectedBid, eth::Network::FrontierTest); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be better to get rid of repetition here, moving
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or by moving it inside |
||
| } | ||
|
|
||
| BOOST_AUTO_TEST_CASE(basicGasPricer_RPC_API_Test_Homestead) | ||
| { | ||
| u256 _expectedAsk = 16056864311; | ||
| u256 _expectedBid = 1; | ||
| dev::test::executeGasPricerTest("RPC_API_Test_Homestead", 30.679, 15.0, "/BlockchainTests/bcGasPricerTest/RPC_API_Test.json", TransactionPriority::Medium, _expectedAsk, _expectedBid, eth::Network::HomesteadTest); | ||
| dev::test::executeGasPricerTest("RPC_API_Test_Homestead", 30.679, 15.0, "/BlockchainTests/ValidBlocks/bcGasPricerTest/RPC_API_Test.json", TransactionPriority::Medium, _expectedAsk, _expectedBid, eth::Network::HomesteadTest); | ||
| } | ||
|
|
||
| BOOST_AUTO_TEST_CASE(basicGasPricer_bcValidBlockTest) | ||
| { | ||
| dev::test::executeGasPricerTest("SimpleTx_Frontier", 30.679, 15.0, "/BlockchainTests/bcValidBlockTest/SimpleTx.json", TransactionPriority::Medium, 155632494086, 10); | ||
| dev::test::executeGasPricerTest("SimpleTx_Frontier", 30.679, 15.0, "/BlockchainTests/ValidBlocks/bcValidBlockTest/SimpleTx.json", TransactionPriority::Medium, 155632494086, 10); | ||
| } | ||
|
|
||
| BOOST_AUTO_TEST_CASE(basicGasPricer_bcUncleTest_Frontier) | ||
| { | ||
| u256 _expectedAsk = 155632494086; | ||
| u256 _expectedBid = 1; | ||
| dev::test::executeGasPricerTest("twoUncle_Frontier", 30.679, 15.0, "/BlockchainTests/bcUncleTest/twoUncle.json", TransactionPriority::Medium, _expectedAsk, _expectedBid, eth::Network::FrontierTest); | ||
| dev::test::executeGasPricerTest("twoUncle_Frontier", 30.679, 15.0, "/BlockchainTests/ValidBlocks/bcUncleTest/twoUncle.json", TransactionPriority::Medium, _expectedAsk, _expectedBid, eth::Network::FrontierTest); | ||
| } | ||
|
|
||
| BOOST_AUTO_TEST_CASE(basicGasPricer_bcUncleTest_Homestead) | ||
| { | ||
| u256 _expectedAsk = 155632494086; | ||
| u256 _expectedBid = 1; | ||
| dev::test::executeGasPricerTest("twoUncle_Homestead", 30.679, 15.0, "/BlockchainTests/bcUncleTest/twoUncle.json", TransactionPriority::Medium, _expectedAsk, _expectedBid, eth::Network::HomesteadTest); | ||
| dev::test::executeGasPricerTest("twoUncle_Homestead", 30.679, 15.0, "/BlockchainTests/ValidBlocks/bcUncleTest/twoUncle.json", TransactionPriority::Medium, _expectedAsk, _expectedBid, eth::Network::HomesteadTest); | ||
| } | ||
|
|
||
| BOOST_AUTO_TEST_CASE(basicGasPricer_bcUncleHeaderValidity_Frontier) | ||
| { | ||
| u256 _expectedAsk = 155632494086; | ||
| u256 _expectedBid = 1; | ||
| dev::test::executeGasPricerTest("correct_Frontier", 30.679, 15.0, "/BlockchainTests/bcUncleHeaderValidity/correct.json", TransactionPriority::Medium, _expectedAsk, _expectedBid, eth::Network::FrontierTest); | ||
| dev::test::executeGasPricerTest("correct_Frontier", 30.679, 15.0, "/BlockchainTests/InvalidBlocks/bcUncleHeaderValidity/correct.json", TransactionPriority::Medium, _expectedAsk, _expectedBid, eth::Network::FrontierTest); | ||
| } | ||
|
|
||
| BOOST_AUTO_TEST_CASE(basicGasPricer_bcUncleHeaderValidity_Homestead) | ||
| { | ||
| u256 _expectedAsk = 155633980282; | ||
| u256 _expectedBid = 1; | ||
| dev::test::executeGasPricerTest("correct_Homestead", 30.679, 15.0, "/BlockchainTests/bcUncleHeaderValidity/correct.json", TransactionPriority::Medium, _expectedAsk, _expectedBid, eth::Network::HomesteadTest); | ||
| dev::test::executeGasPricerTest("correct_Homestead", 30.679, 15.0, "/BlockchainTests/InvalidBlocks/bcUncleHeaderValidity/correct.json", TransactionPriority::Medium, _expectedAsk, _expectedBid, eth::Network::HomesteadTest); | ||
| } | ||
|
|
||
| BOOST_AUTO_TEST_CASE(basicGasPricer_notxs_frontier) | ||
| { | ||
| u256 _expectedAsk = 155632494086; | ||
| u256 _expectedBid = 155632494086; | ||
| dev::test::executeGasPricerTest("notxs_Frontier", 30.679, 15.0, "/BlockchainTests/bcGasPricerTest/notxs.json", TransactionPriority::Medium, _expectedAsk, _expectedBid, eth::Network::FrontierTest); | ||
| dev::test::executeGasPricerTest("notxs_Frontier", 30.679, 15.0, "/BlockchainTests/ValidBlocks/bcGasPricerTest/notxs.json", TransactionPriority::Medium, _expectedAsk, _expectedBid, eth::Network::FrontierTest); | ||
| } | ||
|
|
||
| BOOST_AUTO_TEST_CASE(basicGasPricer_notxs_homestead) | ||
| { | ||
| u256 _expectedAsk = 155632494086; | ||
| u256 _expectedBid = 155632494086; | ||
| dev::test::executeGasPricerTest("notxs_Homestead", 30.679, 15.0, "/BlockchainTests/bcGasPricerTest/notxs.json", TransactionPriority::Medium, _expectedAsk, _expectedBid, eth::Network::HomesteadTest); | ||
| dev::test::executeGasPricerTest("notxs_Homestead", 30.679, 15.0, "/BlockchainTests/ValidBlocks/bcGasPricerTest/notxs.json", TransactionPriority::Medium, _expectedAsk, _expectedBid, eth::Network::HomesteadTest); | ||
| } | ||
|
|
||
| BOOST_AUTO_TEST_CASE(basicGasPricer_highGasUsage_LowestPrio) | ||
| { | ||
| u256 _expectedAsk = 15731408053; | ||
| u256 _expectedBid = 10000000000000; | ||
| dev::test::executeGasPricerTest("highGasUsage_Frontier", 30.679, 15.0, "/BlockchainTests/bcGasPricerTest/highGasUsage.json", TransactionPriority::Lowest, _expectedAsk, _expectedBid, eth::Network::FrontierTest); | ||
| dev::test::executeGasPricerTest("highGasUsage_Frontier", 30.679, 15.0, "/BlockchainTests/ValidBlocks/bcGasPricerTest/highGasUsage.json", TransactionPriority::Lowest, _expectedAsk, _expectedBid, eth::Network::FrontierTest); | ||
| } | ||
|
|
||
| BOOST_AUTO_TEST_CASE(basicGasPricer_highGasUsage_LowPrio) | ||
| { | ||
| u256 _expectedAsk = 15731408053; | ||
| u256 _expectedBid = 15734152261884; | ||
| dev::test::executeGasPricerTest("highGasUsage_Frontier", 30.679, 15.0, "/BlockchainTests/bcGasPricerTest/highGasUsage.json", TransactionPriority::Low, _expectedAsk, _expectedBid, eth::Network::FrontierTest); | ||
| dev::test::executeGasPricerTest("highGasUsage_Frontier", 30.679, 15.0, "/BlockchainTests/ValidBlocks/bcGasPricerTest/highGasUsage.json", TransactionPriority::Low, _expectedAsk, _expectedBid, eth::Network::FrontierTest); | ||
| } | ||
|
|
||
| BOOST_AUTO_TEST_CASE(basicGasPricer_highGasUsage_MediumPrio) | ||
| { | ||
| u256 _expectedAsk = 15731408053; | ||
| u256 _expectedBid = 20000000000000; | ||
| dev::test::executeGasPricerTest("highGasUsage_Frontier", 30.679, 15.0, "/BlockchainTests/bcGasPricerTest/highGasUsage.json", TransactionPriority::Medium, _expectedAsk, _expectedBid, eth::Network::FrontierTest); | ||
| dev::test::executeGasPricerTest("highGasUsage_Frontier", 30.679, 15.0, "/BlockchainTests/ValidBlocks/bcGasPricerTest/highGasUsage.json", TransactionPriority::Medium, _expectedAsk, _expectedBid, eth::Network::FrontierTest); | ||
| } | ||
|
|
||
| BOOST_AUTO_TEST_CASE(basicGasPricer_highGasUsage_HighPrio) | ||
| { | ||
| u256 _expectedAsk = 15731408053; | ||
| u256 _expectedBid = 24265847738115; | ||
| dev::test::executeGasPricerTest("highGasUsage_Frontier", 30.679, 15.0, "/BlockchainTests/bcGasPricerTest/highGasUsage.json", TransactionPriority::High, _expectedAsk, _expectedBid, eth::Network::FrontierTest); | ||
| dev::test::executeGasPricerTest("highGasUsage_Frontier", 30.679, 15.0, "/BlockchainTests/ValidBlocks/bcGasPricerTest/highGasUsage.json", TransactionPriority::High, _expectedAsk, _expectedBid, eth::Network::FrontierTest); | ||
| } | ||
|
|
||
| BOOST_AUTO_TEST_CASE(basicGasPricer_highGasUsage_HighestPrio) | ||
| { | ||
| u256 _expectedAsk = 15731408053; | ||
| u256 _expectedBid = 30000000000000; | ||
| dev::test::executeGasPricerTest("highGasUsage_Frontier", 30.679, 15.0, "/BlockchainTests/bcGasPricerTest/highGasUsage.json", TransactionPriority::Highest, _expectedAsk, _expectedBid, eth::Network::FrontierTest); | ||
| dev::test::executeGasPricerTest("highGasUsage_Frontier", 30.679, 15.0, "/BlockchainTests/ValidBlocks/bcGasPricerTest/highGasUsage.json", TransactionPriority::Highest, _expectedAsk, _expectedBid, eth::Network::FrontierTest); | ||
| } | ||
| BOOST_AUTO_TEST_SUITE_END() | ||
Uh oh!
There was an error while loading. Please reload this page.