mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
updated createRandomTest to correct exception behavior
This commit is contained in:
parent
d952833c1b
commit
057553a0a0
@ -121,14 +121,14 @@ void doMyTests(json_spirit::mValue& v)
|
|||||||
{
|
{
|
||||||
for (auto& i: v.get_obj())
|
for (auto& i: v.get_obj())
|
||||||
{
|
{
|
||||||
|
cnote << i.first;
|
||||||
mObject& o = i.second.get_obj();
|
mObject& o = i.second.get_obj();
|
||||||
|
|
||||||
assert(o.count("env") > 0);
|
assert(o.count("env") > 0);
|
||||||
assert(o.count("pre") > 0);
|
assert(o.count("pre") > 0);
|
||||||
assert(o.count("exec") > 0);
|
assert(o.count("exec") > 0);
|
||||||
|
|
||||||
eth::VM vm;
|
dev::test::FakeExtVM fev;
|
||||||
test::FakeExtVM fev;
|
|
||||||
fev.importEnv(o["env"].get_obj());
|
fev.importEnv(o["env"].get_obj());
|
||||||
fev.importState(o["pre"].get_obj());
|
fev.importState(o["pre"].get_obj());
|
||||||
|
|
||||||
@ -141,17 +141,20 @@ void doMyTests(json_spirit::mValue& v)
|
|||||||
fev.code = fev.thisTxCode;
|
fev.code = fev.thisTxCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
vm.reset(fev.gas);
|
|
||||||
bytes output;
|
bytes output;
|
||||||
|
eth::VM vm(fev.gas);
|
||||||
|
|
||||||
u256 gas;
|
u256 gas;
|
||||||
|
bool vmExceptionOccured = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
output = vm.go(fev).toBytes();
|
output = vm.go(fev, fev.simpleTrace()).toBytes();
|
||||||
|
gas = vm.gas();
|
||||||
}
|
}
|
||||||
catch (eth::VMException const& _e)
|
catch (eth::VMException const& _e)
|
||||||
{
|
{
|
||||||
cnote << "VM did throw an exception: " << diagnostic_information(_e);
|
cnote << "VM did throw an exception: " << diagnostic_information(_e);
|
||||||
gas = 0;
|
vmExceptionOccured = true;
|
||||||
}
|
}
|
||||||
catch (Exception const& _e)
|
catch (Exception const& _e)
|
||||||
{
|
{
|
||||||
@ -180,9 +183,13 @@ void doMyTests(json_spirit::mValue& v)
|
|||||||
|
|
||||||
o["env"] = mValue(fev.exportEnv());
|
o["env"] = mValue(fev.exportEnv());
|
||||||
o["exec"] = mValue(fev.exportExec());
|
o["exec"] = mValue(fev.exportExec());
|
||||||
o["post"] = mValue(fev.exportState());
|
if (!vmExceptionOccured)
|
||||||
o["callcreates"] = fev.exportCallCreates();
|
{
|
||||||
o["out"] = "0x" + toHex(output);
|
o["post"] = mValue(fev.exportState());
|
||||||
fev.push(o, "gas", gas);
|
o["callcreates"] = fev.exportCallCreates();
|
||||||
|
o["out"] = "0x" + toHex(output);
|
||||||
|
fev.push(o, "gas", gas);
|
||||||
|
o["logs"] = mValue(test::exportLog(fev.sub.logs));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user