23 #include <boost/filesystem/operations.hpp> 24 #include <boost/test/unit_test.hpp> 40 namespace dev {
namespace test {
46 string testname = i.first;
49 if (!TestOutputHelper::passTest(o, testname))
53 if (_fillin ==
false && Options::get().fillchain)
56 BOOST_REQUIRE_MESSAGE(o.count(
"env") > 0, testname +
"env not set!");
57 BOOST_REQUIRE_MESSAGE(o.count(
"pre") > 0, testname +
"pre not set!");
58 BOOST_REQUIRE_MESSAGE(o.count(
"transaction") > 0, testname +
"transaction not set!");
60 ImportTest importer(o, _fillin, testType::GeneralStateTest);
61 const State importedStatePost = importer.m_statePost;
64 importer.executeTest();
65 if (Options::get().fillchain)
71 if (importer.exportTest(
bytes()))
72 cerr << testname << endl;
74 BOOST_THROW_EXCEPTION(
Exception() <<
errinfo_comment(testname +
"You can not fill tests when FATDB is switched off"));
79 BOOST_REQUIRE(o.count(
"post") > 0);
82 mObject post = o[
"post"].get_obj();
83 vector<size_t> wrongTransactionsIndexes;
84 for (mObject::const_iterator i = post.begin(); i != post.end(); ++i)
86 for (
auto const& exp: i->second.get_array())
88 if (!Options::get().singleTestNet.empty() && i->first != Options::get().singleTestNet)
90 importer.checkGeneralTestSection(exp.get_obj(), wrongTransactionsIndexes, i->first);
103 string casename = boost::unit_test::framework::current_test_case().p_name;
104 if (casename ==
"stBoundsTest" && !test::Options::get().memory)
106 if (casename ==
"stMemoryStressTest" && !test::Options::get().memory)
108 if (casename ==
"stQuadraticComplexityTest" && !test::Options::get().quadratic)
110 fillAllFilesInFolder(casename);
117 boost::filesystem::directory_iterator iterator_tmp(fillersPath);
119 for(; iterator_tmp != boost::filesystem::directory_iterator(); ++iterator_tmp)
120 if (boost::filesystem::is_regular_file(iterator_tmp->path()) && iterator_tmp->path().extension() ==
".json")
126 boost::filesystem::directory_iterator iterator(fillersPath);
127 for(; iterator != boost::filesystem::directory_iterator(); ++iterator)
128 if (boost::filesystem::is_regular_file(iterator->path()) && iterator->path().extension() ==
".json")
130 string fileboost = iterator->path().filename().string();
const Object & get_obj() const
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
bool filltests
Create JSON test files from execution results.
static Options const & get(int argc=0, char **argv=0)
Get reference to options The first time used, options are parsed with argc, argv. ...
std::hash for asio::adress
Model of an Ethereum state, essentially a facade for the trie.
BOOST_AUTO_TEST_CASE(stBlockHashTest)
void doStateTests(json_spirit::mValue &_v, bool _fillin)
Base class for all exceptions.
Test started/finished notification RAII helper.
std::vector< byte > bytes
std::string getTestPath()
void fillAllFilesInFolder(string _folder)
mConfig::Object_type mObject
#define BOOST_FIXTURE_TEST_SUITE(a, b)
boost::error_info< struct tag_comment, std::string > errinfo_comment
#define BOOST_AUTO_TEST_SUITE_END()
void executeTests(const string &_name, const string &_testPathAppendix, const string &_fillerPathAppendix, std::function< void(json_spirit::mValue &, bool)> doTests, bool _addFillerSuffix)
Helper functions to work with json::spirit and test files.
static void initTest(int _maxTests=1)