From 8245dd69789fe3ff0241af416841f923ce3001f4 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Mon, 1 Dec 2014 22:44:31 +0100 Subject: [PATCH] style Conflicts: libevm/VM.h --- test/TestHelper.cpp | 67 ++++++++++++++++++++++----------------------- test/state.cpp | 4 +-- test/vm.cpp | 4 +-- 3 files changed, 37 insertions(+), 38 deletions(-) diff --git a/test/TestHelper.cpp b/test/TestHelper.cpp index b9575ad2b..bfdd393d7 100644 --- a/test/TestHelper.cpp +++ b/test/TestHelper.cpp @@ -72,7 +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()); + m_environment.sub.logs = importLog(_o["logs"].get_obj()); } } @@ -96,7 +96,6 @@ void ImportTest::importEnv(json_spirit::mObject& _o) m_statePre.m_currentBlock = m_environment.currentBlock; } - void ImportTest::importState(json_spirit::mObject& _o, State& _state) { for (auto& i: _o) @@ -150,8 +149,8 @@ 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 logs + m_TestObject["logs"] = exportLog(_statePost.pending().size() ? _statePost.log(0) : LogEntries()); // export post state json_spirit::mObject postState; @@ -262,40 +261,40 @@ bytes importCode(json_spirit::mObject& _o) 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.insert(h256(t.get_str())); - log.data = importData(o); - logEntries.push_back(log); - } - return logEntries; + 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.insert(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; + 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) diff --git a/test/state.cpp b/test/state.cpp index c2b41fca5..5fc23f149 100644 --- a/test/state.cpp +++ b/test/state.cpp @@ -81,8 +81,8 @@ void doStateTests(json_spirit::mValue& v, bool _fillin) // check output checkOutput(output, o); - // check logs - checkLog(theState.pending().size() ? theState.log(0) : LogEntries(), importer.m_environment.sub.logs); + // check logs + checkLog(theState.pending().size() ? theState.log(0) : LogEntries(), importer.m_environment.sub.logs); // check addresses auto expectedAddrs = importer.m_statePost.addresses(); diff --git a/test/vm.cpp b/test/vm.cpp index 0d61bf6ba..8c9810a2c 100644 --- a/test/vm.cpp +++ b/test/vm.cpp @@ -349,7 +349,7 @@ void doVMTests(json_spirit::mValue& v, bool _fillin) o["callcreates"] = fev.exportCallCreates(); o["out"] = "0x" + toHex(output); fev.push(o, "gas", gas); - o["logs"] = mValue(exportLog(fev.sub.logs)); + o["logs"] = mValue(exportLog(fev.sub.logs)); } } else @@ -367,7 +367,7 @@ void doVMTests(json_spirit::mValue& v, bool _fillin) dev::test::FakeExtVM test; test.importState(o["post"].get_obj()); test.importCallCreates(o["callcreates"].get_array()); - test.sub.logs = importLog(o["logs"].get_obj()); + test.sub.logs = importLog(o["logs"].get_obj()); checkOutput(output, o);