aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarl Allendorph <callendorph@gmail.com>2014-04-20 13:09:41 +0800
committerCarl Allendorph <callendorph@gmail.com>2014-04-20 13:09:41 +0800
commitcd2168dddab68763a65cec9949e4c8ea1c70b725 (patch)
tree25f2506d3e2cbd991d82b8a4fac9bb699ec090b8
parentb8da12f2b8c2bfc2d5469a74d930b8256cb9b991 (diff)
downloaddexon-solidity-cd2168dddab68763a65cec9949e4c8ea1c70b725.tar.gz
dexon-solidity-cd2168dddab68763a65cec9949e4c8ea1c70b725.tar.zst
dexon-solidity-cd2168dddab68763a65cec9949e4c8ea1c70b725.zip
Added some checks on parameters of the objects imported from the json files to make debugging easier.
-rw-r--r--vm.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/vm.cpp b/vm.cpp
index 3fe5b399..a3242b57 100644
--- a/vm.cpp
+++ b/vm.cpp
@@ -136,6 +136,12 @@ public:
void importEnv(mObject& _o)
{
+ BOOST_REQUIRE(_o.count("previousHash") > 0 );
+ BOOST_REQUIRE(_o.count("previousNonce") > 0 );
+ BOOST_REQUIRE(_o.count("currentDifficulty") > 0 );
+ BOOST_REQUIRE(_o.count("currentTimestamp") > 0 );
+ BOOST_REQUIRE(_o.count("currentCoinbase") > 0 );
+
previousBlock.hash = h256(_o["previousHash"].get_str());
previousBlock.nonce = h256(_o["previousNonce"].get_str());
currentBlock.difficulty = toInt(_o["currentDifficulty"]);
@@ -229,6 +235,10 @@ public:
for (auto const& i: _o)
{
mObject o = i.second.get_obj();
+ BOOST_REQUIRE(o.count("balance") > 0 );
+ BOOST_REQUIRE(o.count("nonce") > 0 );
+ BOOST_REQUIRE(o.count("store") > 0 );
+
auto& a = addresses[Address(i.first)];
get<0>(a) = toInt(o["balance"]);
get<1>(a) = toInt(o["nonce"]);
@@ -250,6 +260,7 @@ public:
mObject exportExec()
{
+
mObject ret;
ret["address"] = toString(myAddress);
ret["caller"] = toString(caller);
@@ -265,6 +276,13 @@ public:
void 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("gasPrice") > 0);
+ BOOST_REQUIRE(_o.count("data") > 0 );
+
myAddress = Address(_o["address"].get_str());
caller = Address(_o["caller"].get_str());
origin = Address(_o["origin"].get_str());
@@ -298,6 +316,9 @@ public:
for (mValue& v: _txs)
{
auto tx = v.get_obj();
+ BOOST_REQUIRE(tx.count("destination") > 0);
+ BOOST_REQUIRE(tx.count("value") > 0 );
+ BOOST_REQUIRE(tx.count("data") > 0 );
Transaction t;
t.receiveAddress = Address(tx["destination"].get_str());
t.value = toInt(tx["value"]);
@@ -320,6 +341,10 @@ public:
cnote << i.first;
mObject& o = i.second.get_obj();
+ BOOST_REQUIRE( o.count("env") > 0 );
+ BOOST_REQUIRE( o.count("pre") > 0 );
+ BOOST_REQUIRE( o.count("exec") > 0 );
+
VM vm;
eth::test::FakeExtVM fev;
fev.importEnv(o["env"].get_obj());
@@ -345,6 +370,10 @@ public:
}
else
{
+ BOOST_REQUIRE( o.count("post") > 0 );
+ BOOST_REQUIRE( o.count("txs") > 0 );
+ BOOST_REQUIRE( o.count("out") > 0 );
+
eth::test::FakeExtVM test;
test.importState(o["post"].get_obj());
test.importTxs(o["txs"].get_array());