|
@ -120,6 +120,43 @@ void FakeExtVM::importEnv(mObject& _o) |
|
|
currentBlock.coinbaseAddress = Address(_o["currentCoinbase"].get_str()); |
|
|
currentBlock.coinbaseAddress = Address(_o["currentCoinbase"].get_str()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
mObject FakeExtVM::exportLog() |
|
|
|
|
|
{ |
|
|
|
|
|
mObject ret; |
|
|
|
|
|
for (LogEntry const& l: sub.logs) |
|
|
|
|
|
{ |
|
|
|
|
|
mObject o; |
|
|
|
|
|
o["address"] = toString(l.address); |
|
|
|
|
|
mArray topics; |
|
|
|
|
|
for (auto const& t: l.topics) |
|
|
|
|
|
topics.push_back(toString(t)); |
|
|
|
|
|
o["topics"] = topics; |
|
|
|
|
|
o["data"] = "0x" + toHex(l.data); |
|
|
|
|
|
ret[toString(l.bloom())] = o; |
|
|
|
|
|
} |
|
|
|
|
|
return ret; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void FakeExtVM::importLog(mObject& _o) |
|
|
|
|
|
{ |
|
|
|
|
|
for (auto const& l: _o) |
|
|
|
|
|
{ |
|
|
|
|
|
mObject o = l.second.get_obj(); |
|
|
|
|
|
// cant use BOOST_REQUIRE, because this function is used outside boost test (createRandomTest)
|
|
|
|
|
|
assert(o.count("address") > 0); |
|
|
|
|
|
assert(o.count("topics") > 0); |
|
|
|
|
|
assert(o.count("data") > 0); |
|
|
|
|
|
LogEntry log; |
|
|
|
|
|
log.address = Address(o["address"].get_str()); |
|
|
|
|
|
for (auto const& t: o["topics"].get_array()) |
|
|
|
|
|
{ |
|
|
|
|
|
log.topics.insert(h256(t.get_str())); |
|
|
|
|
|
} |
|
|
|
|
|
log.data = importData(o); |
|
|
|
|
|
sub.logs.push_back(log); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
mObject FakeExtVM::exportState() |
|
|
mObject FakeExtVM::exportState() |
|
|
{ |
|
|
{ |
|
|
mObject ret; |
|
|
mObject ret; |
|
@ -302,7 +339,7 @@ void doVMTests(json_spirit::mValue& v, bool _fillin) |
|
|
u256 gas; |
|
|
u256 gas; |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
output = vm.go(fev, fev.simpleTrace()).toVector(); |
|
|
output = vm.go(fev, fev.simpleTrace()).toBytes(); |
|
|
gas = vm.gas(); |
|
|
gas = vm.gas(); |
|
|
} |
|
|
} |
|
|
catch (VMException const& _e) |
|
|
catch (VMException const& _e) |
|
@ -346,6 +383,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(fev.exportLog()); |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
@ -353,10 +391,12 @@ void doVMTests(json_spirit::mValue& v, bool _fillin) |
|
|
BOOST_REQUIRE(o.count("callcreates") > 0); |
|
|
BOOST_REQUIRE(o.count("callcreates") > 0); |
|
|
BOOST_REQUIRE(o.count("out") > 0); |
|
|
BOOST_REQUIRE(o.count("out") > 0); |
|
|
BOOST_REQUIRE(o.count("gas") > 0); |
|
|
BOOST_REQUIRE(o.count("gas") > 0); |
|
|
|
|
|
BOOST_REQUIRE(o.count("logs") > 0); |
|
|
|
|
|
|
|
|
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.importLog(o["logs"].get_obj()); |
|
|
|
|
|
|
|
|
checkOutput(output, o); |
|
|
checkOutput(output, o); |
|
|
|
|
|
|
|
@ -384,6 +424,8 @@ void doVMTests(json_spirit::mValue& v, bool _fillin) |
|
|
|
|
|
|
|
|
checkAddresses<std::map<Address, std::tuple<u256, u256, std::map<u256, u256>, bytes> > >(test.addresses, fev.addresses); |
|
|
checkAddresses<std::map<Address, std::tuple<u256, u256, std::map<u256, u256>, bytes> > >(test.addresses, fev.addresses); |
|
|
BOOST_CHECK(test.callcreates == fev.callcreates); |
|
|
BOOST_CHECK(test.callcreates == fev.callcreates); |
|
|
|
|
|
|
|
|
|
|
|
checkLog(fev.sub.logs, test.sub.logs); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -432,6 +474,11 @@ BOOST_AUTO_TEST_CASE(vmPushDupSwapTest) |
|
|
dev::test::executeTests("vmPushDupSwapTest", "/VMTests", dev::test::doVMTests); |
|
|
dev::test::executeTests("vmPushDupSwapTest", "/VMTests", dev::test::doVMTests); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(vmLogTest) |
|
|
|
|
|
{ |
|
|
|
|
|
dev::test::executeTests("vmLogTest", "/VMTests", dev::test::doVMTests); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(vmRandom) |
|
|
BOOST_AUTO_TEST_CASE(vmRandom) |
|
|
{ |
|
|
{ |
|
|
string testPath = getTestPath(); |
|
|
string testPath = getTestPath(); |
|
|