Browse Source

Merge pull request #2777 from CJentzsch/fixStateTestsFilling

compile code in accounts when importing state
cl-refactor
Gav Wood 9 years ago
parent
commit
d1465ea13f
  1. 11
      libethereum/Account.cpp
  2. 17
      test/TestHelper.cpp
  3. 8
      test/libethereum/blockchain.cpp
  4. 17
      test/libethereum/state.cpp

11
libethereum/Account.cpp

@ -20,6 +20,7 @@
*/
#include "Account.h"
#include <liblll/Compiler.h>
#include <test/JsonSpiritHeaders.h>
#include <libethcore/Common.h>
using namespace std;
@ -63,7 +64,15 @@ 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()));
if (o["code"].type() == json_spirit::str_type)
{
if (o["code"].get_str().find("0x") != 0)
ret[a].setCode(compileLLL(o["code"].get_str(), false));
else
ret[a].setCode(fromHex(o["code"].get_str().substr(2)));
}
else
cerr << "Error importing code of account " << a << "! Code field needs to be a string";
}
else
ret[a] = Account(balance, Account::NormalCreation);

17
test/TestHelper.cpp

@ -121,10 +121,21 @@ bytes ImportTest::executeTest()
{
ExecutionResult res;
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_statePost = m_statePre;
m_statePre = tmpState;

8
test/libethereum/blockchain.cpp

@ -51,14 +51,6 @@ void overwriteBlockHeader(BlockHeader& _current_BlockHeader, mObject& _blObj, co
void updatePoW(BlockHeader& _bi);
mArray importUncles(mObject const& _blObj, vector<BlockHeader>& _vBiUncles, vector<BlockHeader> const& _vBiBlocks, std::vector<blockSet> _blockSet);
//void doBlockchainTests(json_spirit::mValue& _v, bool _fillin)
//{
// if (_fillin == false)
// _v.get_bool();
// cerr << "BlockChainTests not implemented!" << endl;
//}
void doBlockchainTests(json_spirit::mValue& _v, bool _fillin)
{
for (auto& i: _v.get_obj())

17
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)
{

Loading…
Cancel
Save