aboutsummaryrefslogtreecommitdiffstats
path: root/vm.cpp
diff options
context:
space:
mode:
authorPaweł Bylica <pawel.bylica@imapp.pl>2014-10-21 17:54:54 +0800
committerPaweł Bylica <pawel.bylica@imapp.pl>2014-10-21 17:54:54 +0800
commitc2495456f4121b3234edfaa467789f046ca8a85d (patch)
treed912267ff6e0fd1ccb3b935daf66cdbe8062229b /vm.cpp
parenta152c3b6fb8c8e3c29a1bdb6aa98648762efcdd4 (diff)
downloaddexon-solidity-c2495456f4121b3234edfaa467789f046ca8a85d.tar
dexon-solidity-c2495456f4121b3234edfaa467789f046ca8a85d.tar.gz
dexon-solidity-c2495456f4121b3234edfaa467789f046ca8a85d.tar.bz2
dexon-solidity-c2495456f4121b3234edfaa467789f046ca8a85d.tar.lz
dexon-solidity-c2495456f4121b3234edfaa467789f046ca8a85d.tar.xz
dexon-solidity-c2495456f4121b3234edfaa467789f046ca8a85d.tar.zst
dexon-solidity-c2495456f4121b3234edfaa467789f046ca8a85d.zip
Enhance VM tests reports
Diffstat (limited to 'vm.cpp')
-rw-r--r--vm.cpp40
1 files changed, 38 insertions, 2 deletions
diff --git a/vm.cpp b/vm.cpp
index 5cb2a7b7..91bb17c0 100644
--- a/vm.cpp
+++ b/vm.cpp
@@ -588,8 +588,44 @@ void doTests(json_spirit::mValue& v, bool _fillin)
else
BOOST_CHECK(output == fromHex(o["out"].get_str()));
- BOOST_CHECK(test.toInt(o["gas"]) == gas);
- BOOST_CHECK(test.addresses == fev.addresses);
+ BOOST_CHECK_EQUAL(test.toInt(o["gas"]), gas);
+
+ auto& expectedAddrs = test.addresses;
+ auto& resultAddrs = fev.addresses;
+ for (auto&& expectedPair : expectedAddrs)
+ {
+ auto& expectedAddr = expectedPair.first;
+ auto resultAddrIt = resultAddrs.find(expectedAddr);
+ if (resultAddrIt == resultAddrs.end())
+ BOOST_ERROR("Missing expected address " << expectedAddr);
+ else
+ {
+ auto& expectedState = expectedPair.second;
+ auto& resultState = resultAddrIt->second;
+ BOOST_CHECK_MESSAGE(std::get<0>(expectedState) == std::get<0>(resultState), expectedAddr << ": incorrect balance " << std::get<0>(resultState) << ", expected " << std::get<0>(expectedState));
+ BOOST_CHECK_MESSAGE(std::get<1>(expectedState) == std::get<1>(resultState), expectedAddr << ": incorrect txCount " << std::get<1>(resultState) << ", expected " << std::get<1>(expectedState));
+ BOOST_CHECK_MESSAGE(std::get<3>(expectedState) == std::get<3>(resultState), expectedAddr << ": incorrect code");
+
+ auto&& expectedStore = std::get<2>(expectedState);
+ auto&& resultStore = std::get<2>(resultState);
+
+ for (auto&& expectedStorePair : expectedStore)
+ {
+ auto& expectedStoreKey = expectedStorePair.first;
+ auto resultStoreIt = resultStore.find(expectedStoreKey);
+ if (resultStoreIt == resultStore.end())
+ BOOST_ERROR(expectedAddr << ": missing store key " << expectedStoreKey);
+ else
+ {
+ auto& expectedStoreValue = expectedStorePair.second;
+ auto& resultStoreValue = resultStoreIt->second;
+ BOOST_CHECK_MESSAGE(expectedStoreValue == resultStoreValue, expectedAddr << ": store[" << expectedStoreKey << "] = " << resultStoreValue << ", expected " << expectedStoreValue);
+ }
+ }
+ }
+ }
+
+ BOOST_CHECK(test.addresses == fev.addresses); // Just to make sure nothing missed
BOOST_CHECK(test.callcreates == fev.callcreates);
}
}