aboutsummaryrefslogtreecommitdiffstats
path: root/vm.cpp
diff options
context:
space:
mode:
authorPaweł Bylica <pawel.bylica@imapp.pl>2014-10-21 20:44:09 +0800
committerPaweł Bylica <pawel.bylica@imapp.pl>2014-10-21 20:44:09 +0800
commitc50afdef183e874ba6e353598d319f15c0e47259 (patch)
treec74481842cc65cbb7a6dd3b7d334471d73a226cf /vm.cpp
parentc2495456f4121b3234edfaa467789f046ca8a85d (diff)
parentb2e085c7d6f272d2b06a66ebce01259ac99ac9c6 (diff)
downloaddexon-solidity-c50afdef183e874ba6e353598d319f15c0e47259.tar.gz
dexon-solidity-c50afdef183e874ba6e353598d319f15c0e47259.tar.zst
dexon-solidity-c50afdef183e874ba6e353598d319f15c0e47259.zip
Merge branch 'develop' into develop-evmcc
Conflicts: libevm/FeeStructure.cpp test/vm.cpp
Diffstat (limited to 'vm.cpp')
-rw-r--r--vm.cpp65
1 files changed, 41 insertions, 24 deletions
diff --git a/vm.cpp b/vm.cpp
index 91bb17c0..784515c1 100644
--- a/vm.cpp
+++ b/vm.cpp
@@ -23,6 +23,7 @@
#include "vm.h"
#include <libdevcore/CommonIO.h>
#include <libevmjit/VM.h>
+#include <boost/filesystem/path.hpp>
//#define FILL_TESTS
@@ -98,7 +99,7 @@ bool FakeExtVM::call(Address _receiveAddress, u256 _value, bytesConstRef _data,
{
cnote << "not able to call to : " << myAddress << "\n";
cnote << "in FakeExtVM you can only make a call to " << na << "\n";
- BOOST_THROW_EXCEPTION(FakeExtVMFailure() << errinfo_comment("Address not callable in FakeExtVM\n") << errinfo_wrongAddress(myAddress));
+ BOOST_THROW_EXCEPTION(FakeExtVMFailure() << errinfo_comment("Address not callable in FakeExtVM\n") << errinfo_wrongAddress(toString(myAddress)));
return false;
}
}
@@ -124,7 +125,7 @@ bool FakeExtVM::call(Address _receiveAddress, u256 _value, bytesConstRef _data,
{
cnote << "not able to call to : " << (_codeAddressOverride ? _codeAddressOverride : _receiveAddress) << "\n";
cnote << "in FakeExtVM you can only make a call to " << na << "\n";
- BOOST_THROW_EXCEPTION(FakeExtVMFailure() << errinfo_comment("Address not callable in FakeExtVM\n") << errinfo_wrongAddress(_codeAddressOverride ? _codeAddressOverride : _receiveAddress));
+ BOOST_THROW_EXCEPTION(FakeExtVMFailure() << errinfo_comment("Address not callable in FakeExtVM\n") << errinfo_wrongAddress(toString(_codeAddressOverride ? _codeAddressOverride : _receiveAddress)));
return false;
}
}
@@ -252,12 +253,13 @@ mObject FakeExtVM::exportEnv()
void FakeExtVM::importEnv(mObject& _o)
{
- BOOST_REQUIRE(_o.count("previousHash") > 0);
- BOOST_REQUIRE(_o.count("currentGasLimit") > 0);
- BOOST_REQUIRE(_o.count("currentDifficulty") > 0);
- BOOST_REQUIRE(_o.count("currentTimestamp") > 0);
- BOOST_REQUIRE(_o.count("currentCoinbase") > 0);
- BOOST_REQUIRE(_o.count("currentNumber") > 0);
+ // cant use BOOST_REQUIRE, because this function is used outside boost test (createRandomTest)
+ assert(_o.count("previousHash") > 0);
+ assert(_o.count("currentGasLimit") > 0);
+ assert(_o.count("currentDifficulty") > 0);
+ assert(_o.count("currentTimestamp") > 0);
+ assert(_o.count("currentCoinbase") > 0);
+ assert(_o.count("currentNumber") > 0);
previousBlock.hash = h256(_o["previousHash"].get_str());
currentBlock.number = toInt(_o["currentNumber"]);
@@ -294,10 +296,11 @@ void FakeExtVM::importState(mObject& _object)
for (auto const& i: _object)
{
mObject o = i.second.get_obj();
- BOOST_REQUIRE(o.count("balance") > 0);
- BOOST_REQUIRE(o.count("nonce") > 0);
- BOOST_REQUIRE(o.count("storage") > 0);
- BOOST_REQUIRE(o.count("code") > 0);
+ // cant use BOOST_REQUIRE, because this function is used outside boost test (createRandomTest)
+ assert(o.count("balance") > 0);
+ assert(o.count("nonce") > 0);
+ assert(o.count("storage") > 0);
+ assert(o.count("code") > 0);
auto& a = addresses[Address(i.first)];
get<0>(a) = toInt(o["balance"]);
@@ -335,13 +338,14 @@ mObject FakeExtVM::exportExec()
void FakeExtVM::importExec(mObject& _o)
{
- BOOST_REQUIRE(_o.count("address")> 0);
- BOOST_REQUIRE(_o.count("caller") > 0);
- BOOST_REQUIRE(_o.count("origin") > 0);
- BOOST_REQUIRE(_o.count("value") > 0);
- BOOST_REQUIRE(_o.count("data") > 0);
- BOOST_REQUIRE(_o.count("gasPrice") > 0);
- BOOST_REQUIRE(_o.count("gas") > 0);
+ // cant use BOOST_REQUIRE, because this function is used outside boost test (createRandomTest)
+ assert(_o.count("address")> 0);
+ assert(_o.count("caller") > 0);
+ assert(_o.count("origin") > 0);
+ assert(_o.count("value") > 0);
+ assert(_o.count("data") > 0);
+ assert(_o.count("gasPrice") > 0);
+ assert(_o.count("gas") > 0);
myAddress = Address(_o["address"].get_str());
caller = Address(_o["caller"].get_str());
@@ -527,7 +531,7 @@ void doTests(json_spirit::mValue& v, bool _fillin)
VM vm(fev.gas);
output = vm.go(fev).toVector();
gas = vm.gas(); // Get the remaining gas
- }
+ }
}
catch (Exception const& _e)
{
@@ -661,16 +665,29 @@ void doTests(json_spirit::mValue& v, bool _fillin)
void executeTests(const string& _name)
{
+ const char* ptestPath = getenv("ETHEREUM_TEST_PATH");
+ string testPath;
+
+ if (ptestPath == NULL)
+ {
+ cnote << " could not find environment variable ETHEREUM_TEST_PATH \n";
+ testPath = "../../../tests/vmtests";
+ }
+ else
+ testPath = ptestPath;
+
#ifdef FILL_TESTS
try
{
cnote << "Populating VM tests...";
json_spirit::mValue v;
- string s = asString(contents("../../../cpp-ethereum/test/" + _name + "Filler.json"));
+ boost::filesystem::path p(__FILE__);
+ boost::filesystem::path dir = p.parent_path();
+ string s = asString(contents(dir.string() + "/" + _name + "Filler.json"));
BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of " + _name + "Filler.json is empty.");
json_spirit::read_string(s, v);
dev::test::doTests(v, true);
- writeFile("../../../tests/vmtests/" + _name + ".json", asBytes(json_spirit::write_string(v, true)));
+ writeFile(testPath + "/" + _name + ".json", asBytes(json_spirit::write_string(v, true)));
}
catch (Exception const& _e)
{
@@ -686,8 +703,8 @@ void executeTests(const string& _name)
{
cnote << "Testing VM..." << _name;
json_spirit::mValue v;
- string s = asString(contents("../../../tests/vmtests/" + _name + ".json"));
- BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of " + _name + ".json is empty. Have you cloned the 'tests' repo branch develop?");
+ string s = asString(contents(testPath + "/" + _name + ".json"));
+ BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of " + _name + ".json is empty. Have you cloned the 'tests' repo branch develop and set ETHEREUM_TEST_PATH to its path?");
json_spirit::read_string(s, v);
dev::test::doTests(v, false);
}