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

Commit 8fb57c5

Browse files
author
Dimitry
committed
fix --filltests for blockchain
1 parent 619a643 commit 8fb57c5

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

test/tools/jsontests/BlockChainTests.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,15 @@ json_spirit::mValue BlockchainTestSuite::doTests(json_spirit::mValue const& _inp
7070
if (_fillin)
7171
{
7272
BOOST_REQUIRE(inputTest.count("expect") > 0);
73-
set<eth::Network> allnetworks =
74-
ImportTest::getAllNetworksFromExpectSections(inputTest.at("expect").get_array());
73+
set<eth::Network> allnetworks = ImportTest::getAllNetworksFromExpectSections(
74+
inputTest.at("expect").get_array(), ImportTest::testType::BlockchainTest);
7575

7676
//create a blockchain test for each network
7777
for (auto& network : allnetworks)
7878
{
79-
if (!Options::get().singleTestNet.empty() && Options::get().singleTestNet != test::netIdToString(network))
79+
if (test::isDisabledNetwork(network))
80+
continue;
81+
if (!Options::get().singleTestNet.empty() && Options::get().singleTestNet != test::netIdToString(network))
8082
continue;
8183

8284
dev::test::TestBlockChain::s_sealEngineNetwork = network;

test/tools/libtesteth/ImportTest.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,19 @@ void ImportTest::makeBlockchainTestFromStateTest(set<eth::Network> const& _netwo
164164
}
165165

166166
/// returns all networks that are defined in all expect sections
167-
set<eth::Network> ImportTest::getAllNetworksFromExpectSections(json_spirit::mArray const& _expects)
167+
set<eth::Network> ImportTest::getAllNetworksFromExpectSections(
168+
json_spirit::mArray const& _expects, testType _testType)
168169
{
169170
set<string> allNetworks;
170171
for (auto const& exp : _expects)
171172
{
172-
requireJsonFields(exp.get_obj(), "expect",
173-
{{"indexes", jsonVType::obj_type}, {"network", jsonVType::array_type},
174-
{"result", jsonVType::obj_type}});
173+
if (_testType == testType::BlockchainTest)
174+
requireJsonFields(exp.get_obj(), "expect",
175+
{{"network", jsonVType::str_type}, {"result", jsonVType::obj_type}});
176+
else if (_testType == testType::StateTest)
177+
requireJsonFields(exp.get_obj(), "expect",
178+
{{"indexes", jsonVType::obj_type}, {"network", jsonVType::array_type},
179+
{"result", jsonVType::obj_type}});
175180
ImportTest::parseJsonStrValueIntoSet(exp.get_obj().at("network"), allNetworks);
176181
}
177182

@@ -192,7 +197,8 @@ bytes ImportTest::executeTest(bool _isFilling)
192197
{
193198
// Run tests only on networks from expect sections
194199
BOOST_REQUIRE(m_testInputObject.count("expect") > 0);
195-
networks = getAllNetworksFromExpectSections(m_testInputObject.at("expect").get_array());
200+
networks = getAllNetworksFromExpectSections(
201+
m_testInputObject.at("expect").get_array(), testType::StateTest);
196202
}
197203
else
198204
{

test/tools/libtesteth/ImportTest.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,15 @@ class ImportTest
4343
static json_spirit::mObject makeAllFieldsHex(json_spirit::mObject const& _o, bool _isHeader = false);
4444
static void parseJsonStrValueIntoSet(
4545
json_spirit::mValue const& _json, std::set<std::string>& _out);
46+
47+
enum testType
48+
{
49+
StateTest,
50+
BlockchainTest
51+
};
4652
static std::set<eth::Network> getAllNetworksFromExpectSections(
47-
json_spirit::mArray const& _expects);
53+
json_spirit::mArray const& _expects, testType _testType);
54+
4855

4956
//check functions
5057
//check that networks in the vector are allowed

0 commit comments

Comments
 (0)