diff options
author | Paweł Bylica <pawel.bylica@imapp.pl> | 2014-10-22 01:42:24 +0800 |
---|---|---|
committer | Paweł Bylica <pawel.bylica@imapp.pl> | 2014-10-22 01:42:24 +0800 |
commit | d6ec0a124844e68a4eadc24f8a91d58d5af2e5fc (patch) | |
tree | c916c98a13b71b4ec09e8010a6865ca905d2ae58 /vm.cpp | |
parent | af47913b166b78ca43eea3f128bb6d6476cf1dd2 (diff) | |
download | dexon-solidity-d6ec0a124844e68a4eadc24f8a91d58d5af2e5fc.tar dexon-solidity-d6ec0a124844e68a4eadc24f8a91d58d5af2e5fc.tar.gz dexon-solidity-d6ec0a124844e68a4eadc24f8a91d58d5af2e5fc.tar.bz2 dexon-solidity-d6ec0a124844e68a4eadc24f8a91d58d5af2e5fc.tar.lz dexon-solidity-d6ec0a124844e68a4eadc24f8a91d58d5af2e5fc.tar.xz dexon-solidity-d6ec0a124844e68a4eadc24f8a91d58d5af2e5fc.tar.zst dexon-solidity-d6ec0a124844e68a4eadc24f8a91d58d5af2e5fc.zip |
Fix remaining gas testing [#81118624]
Diffstat (limited to 'vm.cpp')
-rw-r--r-- | vm.cpp | 33 |
1 files changed, 17 insertions, 16 deletions
@@ -512,37 +512,35 @@ void doTests(json_spirit::mValue& v, bool _fillin) fev.code = &fev.thisTxCode; } + + auto argc = boost::unit_test::framework::master_test_suite().argc; + auto argv = boost::unit_test::framework::master_test_suite().argv; + auto useJit = argc >= 2 && std::string(argv[1]) == "--jit"; + + jit::VM jit(fev.gas); + VM interpreter(fev.gas); bytes output; - u256 gas; + auto outOfGas = false; try { - auto argc = boost::unit_test::framework::master_test_suite().argc; - auto argv = boost::unit_test::framework::master_test_suite().argv; - - auto useJit = argc >= 2 && std::string(argv[1]) == "--jit"; if (useJit) - { - jit::VM vm(fev.gas); - output = vm.go(fev); - gas = vm.gas(); - } + output = jit.go(fev); else - { - VM vm(fev.gas); - output = vm.go(fev).toVector(); - gas = vm.gas(); // Get the remaining gas + output = interpreter.go(fev).toVector(); } + catch (OutOfGas const&) + { + outOfGas = true; } catch (Exception const& _e) { cnote << "VM did throw an exception: " << diagnostic_information(_e); - //BOOST_ERROR("Failed VM Test with Exception: " << e.what()); } catch (std::exception const& _e) { cnote << "VM did throw an exception: " << _e.what(); - //BOOST_ERROR("Failed VM Test with Exception: " << e.what()); } + auto gas = useJit ? jit.gas() : interpreter.gas(); // delete null entries in storage for the sake of comparison @@ -593,6 +591,9 @@ void doTests(json_spirit::mValue& v, bool _fillin) BOOST_CHECK(output == fromHex(o["out"].get_str())); BOOST_CHECK_EQUAL(test.toInt(o["gas"]), gas); + + if (outOfGas) + BOOST_CHECK_MESSAGE(gas == 0, "Remaining gas not 0 in out-of-gas state"); auto& expectedAddrs = test.addresses; auto& resultAddrs = fev.addresses; |