aboutsummaryrefslogtreecommitdiffstats
path: root/TestHelper.cpp
diff options
context:
space:
mode:
authorPaweł Bylica <pawel.bylica@imapp.pl>2014-12-05 16:24:47 +0800
committerPaweł Bylica <pawel.bylica@imapp.pl>2014-12-05 16:24:47 +0800
commit20b6b30b999447e7770b062bf71741d2ba88d1fb (patch)
treefe47f1ad89bf2802dd2c25debeb7b9ae10be0981 /TestHelper.cpp
parent29b1964cfbcc21bb16cbeddfb2662c22813056f0 (diff)
parent3c8a45cec4a36ebd4560d7f4ee718b60680b3010 (diff)
downloaddexon-solidity-20b6b30b999447e7770b062bf71741d2ba88d1fb.tar
dexon-solidity-20b6b30b999447e7770b062bf71741d2ba88d1fb.tar.gz
dexon-solidity-20b6b30b999447e7770b062bf71741d2ba88d1fb.tar.bz2
dexon-solidity-20b6b30b999447e7770b062bf71741d2ba88d1fb.tar.lz
dexon-solidity-20b6b30b999447e7770b062bf71741d2ba88d1fb.tar.xz
dexon-solidity-20b6b30b999447e7770b062bf71741d2ba88d1fb.tar.zst
dexon-solidity-20b6b30b999447e7770b062bf71741d2ba88d1fb.zip
Merge branch 'develop' into develop-evmcc
Conflicts: libevm/VM.h test/createRandomTest.cpp
Diffstat (limited to 'TestHelper.cpp')
-rw-r--r--TestHelper.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/TestHelper.cpp b/TestHelper.cpp
index ca0394b8..1ece875e 100644
--- a/TestHelper.cpp
+++ b/TestHelper.cpp
@@ -72,6 +72,7 @@ ImportTest::ImportTest(json_spirit::mObject& _o, bool isFiller): m_TestObject(_o
if (!isFiller)
{
importState(_o["post"].get_obj(), m_statePost);
+ m_environment.sub.logs = importLog(_o["logs"].get_obj());
}
}
@@ -148,6 +149,9 @@ void ImportTest::exportTest(bytes _output, State& _statePost)
// export output
m_TestObject["out"] = "0x" + toHex(_output);
+ // export logs
+ m_TestObject["logs"] = exportLog(_statePost.pending().size() ? _statePost.log(0) : LogEntries());
+
// export post state
json_spirit::mObject postState;
@@ -255,6 +259,44 @@ bytes importCode(json_spirit::mObject& _o)
return code;
}
+LogEntries importLog(json_spirit::mObject& _o)
+{
+ LogEntries logEntries;
+ for (auto const& l: _o)
+ {
+ json_spirit::mObject o = l.second.get_obj();
+ // cant use BOOST_REQUIRE, because this function is used outside boost test (createRandomTest)
+ assert(o.count("address") > 0);
+ assert(o.count("topics") > 0);
+ assert(o.count("data") > 0);
+ LogEntry log;
+ log.address = Address(o["address"].get_str());
+ for (auto const& t: o["topics"].get_array())
+ log.topics.push_back(h256(t.get_str()));
+ log.data = importData(o);
+ logEntries.push_back(log);
+ }
+ return logEntries;
+}
+
+json_spirit::mObject exportLog(eth::LogEntries _logs)
+{
+ json_spirit::mObject ret;
+ if (_logs.size() == 0) return ret;
+ for (LogEntry const& l: _logs)
+ {
+ json_spirit::mObject o;
+ o["address"] = toString(l.address);
+ json_spirit::mArray topics;
+ for (auto const& t: l.topics)
+ topics.push_back(toString(t));
+ o["topics"] = topics;
+ o["data"] = "0x" + toHex(l.data);
+ ret[toString(l.bloom())] = o;
+ }
+ return ret;
+}
+
void checkOutput(bytes const& _output, json_spirit::mObject& _o)
{
int j = 0;