aboutsummaryrefslogtreecommitdiffstats
path: root/vm.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'vm.cpp')
-rw-r--r--vm.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/vm.cpp b/vm.cpp
index 67f08837..03e03566 100644
--- a/vm.cpp
+++ b/vm.cpp
@@ -310,6 +310,7 @@ void doVMTests(json_spirit::mValue& v, bool _fillin)
auto startTime = std::chrono::high_resolution_clock::now();
u256 gas;
+ bool vmExceptionOccured = false;
try
{
output = vm->go(fev, fev.simpleTrace()).toVector();
@@ -323,7 +324,7 @@ void doVMTests(json_spirit::mValue& v, bool _fillin)
catch (VMException const& _e)
{
cnote << "VM did throw an exception: " << diagnostic_information(_e);
- gas = 0;
+ vmExceptionOccured = true;
}
catch (Exception const& _e)
{
@@ -370,13 +371,20 @@ void doVMTests(json_spirit::mValue& v, bool _fillin)
{
o["env"] = mValue(fev.exportEnv());
o["exec"] = mValue(fev.exportExec());
+ if (!vmExceptionOccured)
+ {
o["post"] = mValue(fev.exportState());
o["callcreates"] = fev.exportCallCreates();
o["out"] = "0x" + toHex(output);
fev.push(o, "gas", gas);
}
+ }
else
{
+ if (o.count("post") > 0) // No exceptions expected
+ {
+ BOOST_CHECK(!vmExceptionOccured);
+
BOOST_REQUIRE(o.count("post") > 0);
BOOST_REQUIRE(o.count("callcreates") > 0);
BOOST_REQUIRE(o.count("out") > 0);
@@ -388,7 +396,7 @@ void doVMTests(json_spirit::mValue& v, bool _fillin)
checkOutput(output, o);
- BOOST_CHECK_EQUAL(toInt(o["gas"]), gas);
+ BOOST_CHECK_EQUAL(toInt(o["gas"]), gas);
if (outOfGas)
BOOST_CHECK_MESSAGE(gas == 0, "Remaining gas not 0 in out-of-gas state");
@@ -416,6 +424,9 @@ 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);
BOOST_CHECK(test.callcreates == fev.callcreates);
}
+ else // Exception expected
+ BOOST_CHECK(vmExceptionOccured);
+ }
}
}