Browse Source

compile code in accounts when importing state

cl-refactor
CJentzsch 10 years ago
parent
commit
eab54c8d1d
  1. 3
      libethereum/Account.cpp
  2. 17
      test/TestHelper.cpp
  3. 17
      test/libethereum/state.cpp

3
libethereum/Account.cpp

@ -21,6 +21,7 @@
#include "Account.h" #include "Account.h"
#include <test/JsonSpiritHeaders.h> #include <test/JsonSpiritHeaders.h>
#include <test/TestHelper.h>
#include <libethcore/Common.h> #include <libethcore/Common.h>
using namespace std; using namespace std;
using namespace dev; using namespace dev;
@ -63,7 +64,7 @@ AccountMap dev::eth::jsonToAccountMap(std::string const& _json, AccountMaskMap*
if (haveCode) if (haveCode)
{ {
ret[a] = Account(balance, Account::ContractConception); ret[a] = Account(balance, Account::ContractConception);
ret[a].setCode(fromHex(o["code"].get_str())); ret[a].setCode(test::importCode(o));
} }
else else
ret[a] = Account(balance, Account::NormalCreation); ret[a] = Account(balance, Account::NormalCreation);

17
test/TestHelper.cpp

@ -121,10 +121,21 @@ bytes ImportTest::executeTest()
{ {
ExecutionResult res; ExecutionResult res;
eth::State tmpState = m_statePre; eth::State tmpState = m_statePre;
try
{
std::pair<ExecutionResult, TransactionReceipt> 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<ExecutionResult, TransactionReceipt> execOut = m_statePre.execute(m_envInfo, m_transaction);
res = execOut.first;
m_logs = execOut.second.log();
m_statePre.commit(); m_statePre.commit();
m_statePost = m_statePre; m_statePost = m_statePre;
m_statePre = tmpState; m_statePre = tmpState;

17
test/libethereum/state.cpp

@ -59,20 +59,9 @@ void doStateTests(json_spirit::mValue& v, bool _fillin)
const State importedStatePost = importer.m_statePost; const State importedStatePost = importer.m_statePost;
bytes output; bytes output;
try // execute transaction
{ Listener::ExecTimeGuard guard{i.first};
Listener::ExecTimeGuard guard{i.first}; output = importer.executeTest();
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();
}
if (_fillin) if (_fillin)
{ {

Loading…
Cancel
Save