From eab54c8d1d12f2220bf4a016cc852e6b77f3c86d Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Mon, 10 Aug 2015 16:47:42 +0200 Subject: [PATCH] compile code in accounts when importing state --- libethereum/Account.cpp | 3 ++- test/TestHelper.cpp | 17 ++++++++++++++--- test/libethereum/state.cpp | 17 +++-------------- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/libethereum/Account.cpp b/libethereum/Account.cpp index 44b5079ea..4297ec479 100644 --- a/libethereum/Account.cpp +++ b/libethereum/Account.cpp @@ -21,6 +21,7 @@ #include "Account.h" #include +#include #include using namespace std; using namespace dev; @@ -63,7 +64,7 @@ AccountMap dev::eth::jsonToAccountMap(std::string const& _json, AccountMaskMap* if (haveCode) { ret[a] = Account(balance, Account::ContractConception); - ret[a].setCode(fromHex(o["code"].get_str())); + ret[a].setCode(test::importCode(o)); } else ret[a] = Account(balance, Account::NormalCreation); diff --git a/test/TestHelper.cpp b/test/TestHelper.cpp index 399779756..0b9f1e0ef 100644 --- a/test/TestHelper.cpp +++ b/test/TestHelper.cpp @@ -121,10 +121,21 @@ bytes ImportTest::executeTest() { ExecutionResult res; eth::State tmpState = m_statePre; + try + { + std::pair execOut = m_statePre.execute(m_envInfo, m_transaction); + res = execOut.first; + m_logs = execOut.second.log(); + } + catch (Exception const& _e) + { + cnote << "Exception: " << diagnostic_information(_e); + } + catch (std::exception const& _e) + { + cnote << "state execution exception: " << _e.what(); + } - std::pair execOut = m_statePre.execute(m_envInfo, m_transaction); - res = execOut.first; - m_logs = execOut.second.log(); m_statePre.commit(); m_statePost = m_statePre; m_statePre = tmpState; diff --git a/test/libethereum/state.cpp b/test/libethereum/state.cpp index f0653401e..4c9d998b2 100644 --- a/test/libethereum/state.cpp +++ b/test/libethereum/state.cpp @@ -59,20 +59,9 @@ void doStateTests(json_spirit::mValue& v, bool _fillin) const State importedStatePost = importer.m_statePost; bytes output; - try - { - Listener::ExecTimeGuard guard{i.first}; - output = importer.executeTest(); - } - catch (Exception const& _e) - { - cnote << "Exception: " << diagnostic_information(_e); - //theState.commit(); - } - catch (std::exception const& _e) - { - cnote << "state execution exception: " << _e.what(); - } + // execute transaction + Listener::ExecTimeGuard guard{i.first}; + output = importer.executeTest(); if (_fillin) {