MCPcopy Create free account
hub / github.com/LUX-Core/lux / checkGeneralTestSectionSearch

Method checkGeneralTestSectionSearch

src/cpp-ethereum/test/libtesteth/ImportTest.cpp:470–552  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

468}
469
470void ImportTest::checkGeneralTestSectionSearch(json_spirit::mObject const& _expects, vector<size_t>& _errorTransactions, string const& _network, TrExpectSection* _search) const
471{
472 vector<int> d;
473 vector<int> g;
474 vector<int> v;
475 vector<string> network;
476 if (_network.empty())
477 parseJsonStrValueIntoVector(_expects.at("network"), network);
478 else
479 network.push_back(_network);
480
481 BOOST_CHECK_MESSAGE(network.size() > 0, TestOutputHelper::testName() + "Network array not set!");
482 vector<string> allowednetworks = {netIdToString(eth::Network::FrontierTest), netIdToString(eth::Network::HomesteadTest),
483 netIdToString(eth::Network::EIP150Test), netIdToString(eth::Network::EIP158Test), netIdToString(eth::Network::MetropolisTest), "ALL"};
484 for(size_t i=0; i<network.size(); i++)
485 BOOST_CHECK_MESSAGE(inArray(allowednetworks, network.at(i)), TestOutputHelper::testName() + "Specified Network not found: " + network.at(i));
486
487 if (_expects.count("indexes"))
488 {
489 json_spirit::mObject const& indexes = _expects.at("indexes").get_obj();
490 parseJsonIntValueIntoVector(indexes.at("data"), d);
491 parseJsonIntValueIntoVector(indexes.at("gas"), g);
492 parseJsonIntValueIntoVector(indexes.at("value"), v);
493 BOOST_CHECK_MESSAGE(d.size() > 0 && g.size() > 0 && v.size() > 0, TestOutputHelper::testName() + "Indexes arrays not set!");
494 }
495 else
496 BOOST_ERROR(TestOutputHelper::testName() + "indexes section not set!");
497
498 bool foundResults = false;
499 std::vector<transactionToExecute> lookTransactions;
500 if (_search)
501 lookTransactions.push_back(_search->first);
502 else
503 lookTransactions = m_transactions;
504 for(size_t i = 0; i < lookTransactions.size(); i++)
505 {
506 transactionToExecute t = lookTransactions[i];
507 if (inArray(network, netIdToString(t.netId)) || network[0] == "ALL")
508 if ((inArray(d, t.dataInd) || d[0] == -1) && (inArray(g, t.gasInd) || g[0] == -1) && (inArray(v, t.valInd) || v[0] == -1))
509 {
510 string trInfo = netIdToString(t.netId) + " data: " + toString(t.dataInd) + " gas: " + toString(t.gasInd) + " val: " + toString(t.valInd);
511 if (_expects.count("result"))
512 {
513 Options const& opt = Options::get();
514 //filter transactions if a specific index set in options
515 if ((opt.trDataIndex != -1 && opt.trDataIndex != t.dataInd) ||
516 (opt.trGasIndex != -1 && opt.trGasIndex != t.gasInd) ||
517 (opt.trValueIndex != -1 && opt.trValueIndex != t.valInd))
518 continue;
519
520 State postState = t.postState;
521 eth::AccountMaskMap stateMap;
522 State expectState(0, OverlayDB(), eth::BaseState::Empty);
523 importState(_expects.at("result").get_obj(), expectState, stateMap);
524 if (_search)
525 {
526 _search->second.first = expectState;
527 _search->second.second = stateMap;

Callers

nothing calls this directly

Calls 15

netIdToStringFunction · 0.85
inArrayFunction · 0.85
toHexFunction · 0.85
get_strMethod · 0.80
asBytesMethod · 0.80
toStringFunction · 0.50
OverlayDBClass · 0.50
emptyMethod · 0.45
atMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected