Conflicts:
	libevm/VM.h
This commit is contained in:
CJentzsch 2014-12-01 22:44:31 +01:00
parent 057553a0a0
commit fb7c3bb302
3 changed files with 37 additions and 38 deletions

View File

@ -72,7 +72,7 @@ ImportTest::ImportTest(json_spirit::mObject& _o, bool isFiller): m_TestObject(_o
if (!isFiller) if (!isFiller)
{ {
importState(_o["post"].get_obj(), m_statePost); importState(_o["post"].get_obj(), m_statePost);
m_environment.sub.logs = importLog(_o["logs"].get_obj()); m_environment.sub.logs = importLog(_o["logs"].get_obj());
} }
} }
@ -96,7 +96,6 @@ void ImportTest::importEnv(json_spirit::mObject& _o)
m_statePre.m_currentBlock = m_environment.currentBlock; m_statePre.m_currentBlock = m_environment.currentBlock;
} }
void ImportTest::importState(json_spirit::mObject& _o, State& _state) void ImportTest::importState(json_spirit::mObject& _o, State& _state)
{ {
for (auto& i: _o) for (auto& i: _o)
@ -150,8 +149,8 @@ void ImportTest::exportTest(bytes _output, State& _statePost)
// export output // export output
m_TestObject["out"] = "0x" + toHex(_output); m_TestObject["out"] = "0x" + toHex(_output);
// export logs // export logs
m_TestObject["logs"] = exportLog(_statePost.pending().size() ? _statePost.log(0) : LogEntries()); m_TestObject["logs"] = exportLog(_statePost.pending().size() ? _statePost.log(0) : LogEntries());
// export post state // export post state
json_spirit::mObject postState; json_spirit::mObject postState;
@ -262,40 +261,40 @@ bytes importCode(json_spirit::mObject& _o)
LogEntries importLog(json_spirit::mObject& _o) LogEntries importLog(json_spirit::mObject& _o)
{ {
LogEntries logEntries; LogEntries logEntries;
for (auto const& l: _o) for (auto const& l: _o)
{ {
json_spirit::mObject o = l.second.get_obj(); json_spirit::mObject o = l.second.get_obj();
// cant use BOOST_REQUIRE, because this function is used outside boost test (createRandomTest) // cant use BOOST_REQUIRE, because this function is used outside boost test (createRandomTest)
assert(o.count("address") > 0); assert(o.count("address") > 0);
assert(o.count("topics") > 0); assert(o.count("topics") > 0);
assert(o.count("data") > 0); assert(o.count("data") > 0);
LogEntry log; LogEntry log;
log.address = Address(o["address"].get_str()); log.address = Address(o["address"].get_str());
for (auto const& t: o["topics"].get_array()) for (auto const& t: o["topics"].get_array())
log.topics.insert(h256(t.get_str())); log.topics.insert(h256(t.get_str()));
log.data = importData(o); log.data = importData(o);
logEntries.push_back(log); logEntries.push_back(log);
} }
return logEntries; return logEntries;
} }
json_spirit::mObject exportLog(eth::LogEntries _logs) json_spirit::mObject exportLog(eth::LogEntries _logs)
{ {
json_spirit::mObject ret; json_spirit::mObject ret;
if (_logs.size() == 0) return ret; if (_logs.size() == 0) return ret;
for (LogEntry const& l: _logs) for (LogEntry const& l: _logs)
{ {
json_spirit::mObject o; json_spirit::mObject o;
o["address"] = toString(l.address); o["address"] = toString(l.address);
json_spirit::mArray topics; json_spirit::mArray topics;
for (auto const& t: l.topics) for (auto const& t: l.topics)
topics.push_back(toString(t)); topics.push_back(toString(t));
o["topics"] = topics; o["topics"] = topics;
o["data"] = "0x" + toHex(l.data); o["data"] = "0x" + toHex(l.data);
ret[toString(l.bloom())] = o; ret[toString(l.bloom())] = o;
} }
return ret; return ret;
} }
void checkOutput(bytes const& _output, json_spirit::mObject& _o) void checkOutput(bytes const& _output, json_spirit::mObject& _o)

View File

@ -81,8 +81,8 @@ void doStateTests(json_spirit::mValue& v, bool _fillin)
// check output // check output
checkOutput(output, o); checkOutput(output, o);
// check logs // check logs
checkLog(theState.pending().size() ? theState.log(0) : LogEntries(), importer.m_environment.sub.logs); checkLog(theState.pending().size() ? theState.log(0) : LogEntries(), importer.m_environment.sub.logs);
// check addresses // check addresses
auto expectedAddrs = importer.m_statePost.addresses(); auto expectedAddrs = importer.m_statePost.addresses();

4
vm.cpp
View File

@ -349,7 +349,7 @@ void doVMTests(json_spirit::mValue& v, bool _fillin)
o["callcreates"] = fev.exportCallCreates(); o["callcreates"] = fev.exportCallCreates();
o["out"] = "0x" + toHex(output); o["out"] = "0x" + toHex(output);
fev.push(o, "gas", gas); fev.push(o, "gas", gas);
o["logs"] = mValue(exportLog(fev.sub.logs)); o["logs"] = mValue(exportLog(fev.sub.logs));
} }
} }
else else
@ -367,7 +367,7 @@ void doVMTests(json_spirit::mValue& v, bool _fillin)
dev::test::FakeExtVM test; dev::test::FakeExtVM test;
test.importState(o["post"].get_obj()); test.importState(o["post"].get_obj());
test.importCallCreates(o["callcreates"].get_array()); test.importCallCreates(o["callcreates"].get_array());
test.sub.logs = importLog(o["logs"].get_obj()); test.sub.logs = importLog(o["logs"].get_obj());
checkOutput(output, o); checkOutput(output, o);