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

Commit

Permalink
StateTests:
Browse files Browse the repository at this point in the history
run BCFiller.json as blockchain
fill BCFiller.json only as blockchain
  • Loading branch information
winsvega committed Jun 1, 2017
1 parent 6cd51fd commit f69de9a
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 16 deletions.
2 changes: 1 addition & 1 deletion test/jsontests
Submodule jsontests updated 2719 files
20 changes: 16 additions & 4 deletions test/tools/jsontests/BlockChainTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,28 @@ void checkBlocks(TestBlock const& _blockFromFields, TestBlock const& _blockFromR

void doBlockchainTests(json_spirit::mValue& _v, bool _fillin)
{
if (!Options::get().fillchain) //fill blockchain through state tests
//fill blockchain through state tests
bool isRunFromStateTests = true;
if (Options::get().rCurrentTestSuite.find("StateTests") == string::npos)
{
isRunFromStateTests = false;
TestOutputHelper::initTest(_v);
}

for (auto& i: _v.get_obj())
{
string testname = i.first;
json_spirit::mObject& o = i.second.get_obj();

if (!Options::get().fillchain)
if (!TestOutputHelper::passTest(o, testname))
continue;
//Disable name selection when run from StateTests
//(cause 1 state test = many blockchain tests with dynamic names)
if (!isRunFromStateTests)
{
if (!TestOutputHelper::passTest(o, testname))
continue;
}
else
TestOutputHelper::setCurrentTestName(testname);

BOOST_REQUIRE(o.count("genesisBlockHeader"));
BOOST_REQUIRE(o.count("pre"));
Expand Down
43 changes: 34 additions & 9 deletions test/tools/jsontests/StateTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ using namespace std;
using namespace json_spirit;
using namespace dev;
using namespace dev::eth;
using namespace dev::test;

namespace dev { namespace test {

Expand Down Expand Up @@ -115,25 +116,49 @@ class generaltestfixture

void fillAllFilesInFolder(string _folder)
{
std::string fillersPath = dev::test::getTestPath() + "/src/GeneralStateTestsFiller/" + _folder;
std::string fillersPath = getTestPath() + "/src/GeneralStateTestsFiller/" + _folder;
using dirIt = boost::filesystem::directory_iterator;

boost::filesystem::directory_iterator iterator_tmp(fillersPath);
dirIt iterator_tmp(fillersPath);
int fileCount = 0;
for(; iterator_tmp != boost::filesystem::directory_iterator(); ++iterator_tmp)
for(; iterator_tmp != dirIt(); ++iterator_tmp)
if (boost::filesystem::is_regular_file(iterator_tmp->path()) && iterator_tmp->path().extension() == ".json")
fileCount++;
if (dev::test::Options::get().filltests)
if (Options::get().filltests)
fileCount *= 2; //tests are checked when filled and after they been filled
dev::test::TestOutputHelper::initTest(fileCount);
TestOutputHelper::initTest(fileCount);

boost::filesystem::directory_iterator iterator(fillersPath);
for(; iterator != boost::filesystem::directory_iterator(); ++iterator)
dirIt iterator(fillersPath);
for(; iterator != dirIt(); ++iterator)
if (boost::filesystem::is_regular_file(iterator->path()) && iterator->path().extension() == ".json")
{
string fileboost = iterator->path().filename().string();
dev::test::executeTests(fileboost, "/GeneralStateTests/"+_folder, "/GeneralStateTestsFiller/"+_folder, dev::test::doStateTests);
if (fileboost.rfind("BCFiller.json") != std::string::npos)
{
//Skip filling this tests as state tests
if (Options::get().filltests && !Options::get().fillchain)
{
TestOutputHelper::incTestCount(2);
continue;
}

//Fill this tests only as blockchain
if (Options::get().filltests && Options::get().fillchain)
executeTests(fileboost, "/GeneralStateTests/"+_folder, "/GeneralStateTestsFiller/"+_folder, doStateTests);
else
{
TestOutputHelper::incTestCount();
TestOutputHelper::setCurrentTestFileName(fileboost);
//run this tests as Blockchain when runnning state tests
executeTests(fileboost,
"/BlockchainTests/GeneralStateTests/" + TestOutputHelper::caseName(),
"/GenStateTestAsBcTemp/" + TestOutputHelper::caseName(), doBlockchainTests);
}
}
else
executeTests(fileboost, "/GeneralStateTests/"+_folder, "/GeneralStateTestsFiller/"+_folder, doStateTests);
}
dev::test::TestOutputHelper::finishTest();
TestOutputHelper::finishTest();
}
};

Expand Down
2 changes: 1 addition & 1 deletion test/tools/libtesteth/ImportTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ bytes ImportTest::executeTest()
json_spirit::mObject obj = fillJsonWithState(search2->second.first, search2->second.second);
for (auto& adr: obj)
{
if (adr.first == toString(m_envInfo.author()))
if (adr.first == toString(m_envInfo.author()) || adr.first == "0x" + toString(m_envInfo.author()))
{
if (adr.second.get_obj().count("balance"))
{
Expand Down
4 changes: 3 additions & 1 deletion test/tools/libtesteth/TestOutputHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ class TestOutputHelper
static void initTest(json_spirit::mValue& _v);
static bool passTest(json_spirit::mObject& _o, std::string& _testName);
static void setMaxTests(int _count) { m_maxTests = _count; }
static void setCurrentTestFileName(std::string _name) { m_currentTestFileName = _name; }
static void setCurrentTestFileName(std::string const& _name) { m_currentTestFileName = _name; }
static void setCurrentTestName(std::string const& _name) { m_currentTestName = _name; }
static std::string const& testName() { return m_currentTestName; }
static std::string const& caseName() { return m_currentTestCaseName; }
static std::string const& testFileName() { return m_currentTestFileName; }
static void finishTest();
static void incTestCount(int _times = 1) { m_currTest += _times; }
static void printTestExecStats();
~TestOutputHelper() { TestOutputHelper::finishTest(); }
private:
Expand Down

0 comments on commit f69de9a

Please sign in to comment.