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

Method executeTest

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

Source from the content-addressed store, hash-verified

51}
52
53bytes ImportTest::executeTest()
54{
55 if (m_testType == testType::StateTests)
56 {
57 eth::Network network = eth::Network::MainNetwork;
58 std::pair<eth::State, ImportTest::execOutput> out = executeTransaction(network, m_envInfo, m_statePre, m_transaction);
59 m_statePost = out.first;
60 m_logs = out.second.second.log();
61 return out.second.first.output;
62 }
63 else if (m_testType == testType::GeneralStateTest)
64 {
65 vector<eth::Network> networks;
66 if (!Options::get().singleTestNet.empty())
67 {
68 networks.push_back(stringToNetId(Options::get().singleTestNet));
69 }
70 else
71 {
72 networks.push_back(eth::Network::FrontierTest);
73 networks.push_back(eth::Network::HomesteadTest);
74 networks.push_back(eth::Network::EIP150Test);
75 networks.push_back(eth::Network::EIP158Test);
76 networks.push_back(eth::Network::MetropolisTest);
77 }
78
79 json_spirit::mObject json;
80 vector<transactionToExecute> transactionResults;
81 for (size_t j = 0; j < networks.size(); j++)
82 {
83 for (size_t i = 0; i < m_transactions.size(); i++)
84 {
85 eth::Network network = networks[j];
86 std::pair<eth::State, ImportTest::execOutput> out = executeTransaction(network, m_envInfo, m_statePre, m_transactions[i].transaction);
87 m_transactions[i].postState = out.first;
88 m_transactions[i].netId = network;
89 transactionResults.push_back(m_transactions[i]);
90
91 if (Options::get().fillchain)
92 {
93 json_spirit::mObject testObj;
94 testObj["network"] = netIdToString(networks[j]);
95 string postfix = "_d" + toString(m_transactions[i].dataInd);
96 postfix += "g" + toString(m_transactions[i].gasInd);
97 postfix += "v" + toString(m_transactions[i].valInd);
98 postfix += "_" + netIdToString(networks[j]);
99 string testname = TestOutputHelper::testName() + postfix;
100
101 json_spirit::mObject genesisObj = TestBlockChain::defaultGenesisBlockJson();
102 genesisObj["coinbase"] = toString(m_envInfo.author());
103 genesisObj["gasLimit"] = toCompactHex(m_envInfo.gasLimit(), HexPrefix::Add);
104 genesisObj["timestamp"] = toCompactHex(m_envInfo.timestamp() - 50, HexPrefix::Add);
105 testObj["genesisBlockHeader"] = genesisObj;
106 testObj["pre"] = fillJsonWithState(m_statePre);
107
108 State s = State (0, OverlayDB(), eth::BaseState::Empty);
109 AccountMaskMap m = std::unordered_map<Address, AccountMask>();
110 StateAndMap smap {s, m};

Callers 1

doStateTestsFunction · 0.80

Calls 15

stringToNetIdFunction · 0.85
netIdToStringFunction · 0.85
toCompactHexFunction · 0.85
fillJsonWithStateFunction · 0.85
toIntFunction · 0.85
fillJsonWithTransactionFunction · 0.85
writeFileFunction · 0.85
asBytesFunction · 0.85
executeTestsFunction · 0.85
gasLimitMethod · 0.80
difficultyMethod · 0.80
StateClass · 0.70

Tested by

no test coverage detected