diff options
author | Gav Wood <i@gavwood.com> | 2014-12-03 03:09:00 +0800 |
---|---|---|
committer | Gav Wood <i@gavwood.com> | 2014-12-03 03:09:00 +0800 |
commit | 2f5b9151d5d28d1874acce22fe52b6cc0ab2c226 (patch) | |
tree | 9814bd5b18103ce88f223c62edc4a833157781e6 /TestHelper.cpp | |
parent | 8d0a6647401123fcab7b1b5f38a5fd46b94331c2 (diff) | |
parent | fb7c3bb302e5d309b500e2929a565b427de23a8b (diff) | |
download | dexon-solidity-2f5b9151d5d28d1874acce22fe52b6cc0ab2c226.tar dexon-solidity-2f5b9151d5d28d1874acce22fe52b6cc0ab2c226.tar.gz dexon-solidity-2f5b9151d5d28d1874acce22fe52b6cc0ab2c226.tar.bz2 dexon-solidity-2f5b9151d5d28d1874acce22fe52b6cc0ab2c226.tar.lz dexon-solidity-2f5b9151d5d28d1874acce22fe52b6cc0ab2c226.tar.xz dexon-solidity-2f5b9151d5d28d1874acce22fe52b6cc0ab2c226.tar.zst dexon-solidity-2f5b9151d5d28d1874acce22fe52b6cc0ab2c226.zip |
Merge branch 'develop' of github.com:ethereum/cpp-ethereum into develop
Conflicts:
test/vm.cpp
Diffstat (limited to 'TestHelper.cpp')
-rw-r--r-- | TestHelper.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/TestHelper.cpp b/TestHelper.cpp index b3d1bbe8..e6426474 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; |