Browse Source

Merge branch 'StateBug' into NewStateTests

cl-refactor
Christoph Jentzsch 10 years ago
parent
commit
db8f0e0487
  1. 4
      alethzero/MainWin.cpp
  2. 2
      libethereum/ExtVM.h
  3. 2
      libevm/ExtVMFace.cpp
  4. 4
      libevm/ExtVMFace.h
  5. 4
      test/createRandomTest.cpp
  6. 4
      test/state.cpp
  7. 10
      test/vm.cpp

4
alethzero/MainWin.cpp

@ -1344,7 +1344,7 @@ void Main::populateDebugger(dev::bytesConstRef _r)
debugFinished();
vector<WorldState const*> levels;
m_codes.clear();
bytesConstRef lastExtCode;
bytes lastExtCode;
bytesConstRef lastData;
h256 lastHash;
h256 lastDataHash;
@ -1357,7 +1357,7 @@ void Main::populateDebugger(dev::bytesConstRef _r)
lastExtCode = ext.code;
lastHash = sha3(lastExtCode);
if (!m_codes.count(lastHash))
m_codes[lastHash] = ext.code.toBytes();
m_codes[lastHash] = ext.code;
}
if (ext.data != lastData)
{

2
libethereum/ExtVM.h

@ -40,7 +40,7 @@ class ExtVM: public ExtVMFace
public:
/// Full constructor.
ExtVM(State& _s, Address _myAddress, Address _caller, Address _origin, u256 _value, u256 _gasPrice, bytesConstRef _data, bytesConstRef _code, Manifest* o_ms, unsigned _depth = 0):
ExtVMFace(_myAddress, _caller, _origin, _value, _gasPrice, _data, _code, _s.m_previousBlock, _s.m_currentBlock, _depth), m_s(_s), m_origCache(_s.m_cache), m_ms(o_ms)
ExtVMFace(_myAddress, _caller, _origin, _value, _gasPrice, _data, _code.toBytes(), _s.m_previousBlock, _s.m_currentBlock, _depth), m_s(_s), m_origCache(_s.m_cache), m_ms(o_ms)
{
m_s.ensureCached(_myAddress, true, true);
}

2
libevm/ExtVMFace.cpp

@ -25,7 +25,7 @@ using namespace std;
using namespace dev;
using namespace dev::eth;
ExtVMFace::ExtVMFace(Address _myAddress, Address _caller, Address _origin, u256 _value, u256 _gasPrice, bytesConstRef _data, bytesConstRef _code, BlockInfo const& _previousBlock, BlockInfo const& _currentBlock, unsigned _depth):
ExtVMFace::ExtVMFace(Address _myAddress, Address _caller, Address _origin, u256 _value, u256 _gasPrice, bytesConstRef _data, bytes _code, BlockInfo const& _previousBlock, BlockInfo const& _currentBlock, unsigned _depth):
myAddress(_myAddress),
caller(_caller),
origin(_origin),

4
libevm/ExtVMFace.h

@ -96,7 +96,7 @@ public:
ExtVMFace() = default;
/// Full constructor.
ExtVMFace(Address _myAddress, Address _caller, Address _origin, u256 _value, u256 _gasPrice, bytesConstRef _data, bytesConstRef _code, BlockInfo const& _previousBlock, BlockInfo const& _currentBlock, unsigned _depth);
ExtVMFace(Address _myAddress, Address _caller, Address _origin, u256 _value, u256 _gasPrice, bytesConstRef _data, bytes _code, BlockInfo const& _previousBlock, BlockInfo const& _currentBlock, unsigned _depth);
virtual ~ExtVMFace() = default;
@ -145,7 +145,7 @@ public:
u256 value; ///< Value (in Wei) that was passed to this address.
u256 gasPrice; ///< Price of gas (that we already paid).
bytesConstRef data; ///< Current input data.
bytesConstRef code; ///< Current code that is executing.
bytes code; ///< Current code that is executing.
BlockInfo previousBlock; ///< The previous block's information.
BlockInfo currentBlock; ///< The current block's information.
SubState sub; ///< Sub-band VM state (suicides, refund counter, logs).

4
test/createRandomTest.cpp

@ -134,10 +134,10 @@ void doMyTests(json_spirit::mValue& v)
o["pre"] = mValue(fev.exportState());
fev.importExec(o["exec"].get_obj());
if (!fev.code)
if (!fev.code.size())
{
fev.thisTxCode = get<3>(fev.addresses.at(fev.myAddress));
fev.code = &fev.thisTxCode;
fev.code = fev.thisTxCode;
}
vm.reset(fev.gas);

4
test/state.cpp

@ -20,8 +20,6 @@
* State test functions.
*/
#define FILL_TESTS
#include <boost/filesystem/operations.hpp>
#include <boost/test/unit_test.hpp>
#include "JsonSpiritHeaders.h"
@ -60,7 +58,7 @@ void doStateTests(json_spirit::mValue& v, bool _fillin)
if (_fillin)
{
importer.code = importer.m_statePre.code(importer.m_environment.myAddress);
importer.m_environment.code = &importer.code;
importer.m_environment.code = importer.code;
}
State theState = importer.m_statePre;

10
test/vm.cpp

@ -29,7 +29,7 @@ using namespace dev::eth;
using namespace dev::test;
FakeExtVM::FakeExtVM(eth::BlockInfo const& _previousBlock, eth::BlockInfo const& _currentBlock, unsigned _depth): /// TODO: XXX: remove the default argument & fix.
ExtVMFace(Address(), Address(), Address(), 0, 1, bytesConstRef(), bytesConstRef(), _previousBlock, _currentBlock, _depth) {}
ExtVMFace(Address(), Address(), Address(), 0, 1, bytesConstRef(), bytes(), _previousBlock, _currentBlock, _depth) {}
h160 FakeExtVM::create(u256 _endowment, u256* _gas, bytesConstRef _init, OnOpFunc const&)
{
@ -206,11 +206,11 @@ void FakeExtVM::importExec(mObject& _o)
gas = toInt(_o["gas"]);
thisTxCode.clear();
code = &thisTxCode;
code = thisTxCode;
thisTxCode = importCode(_o);
if (_o["code"].type() != str_type && _o["code"].type() != array_type)
code.reset();
code.clear();
thisTxData.clear();
thisTxData = importData(_o);
@ -303,10 +303,10 @@ void doVMTests(json_spirit::mValue& v, bool _fillin)
o["pre"] = mValue(fev.exportState());
fev.importExec(o["exec"].get_obj());
if (!fev.code)
if (!fev.code.size())
{
fev.thisTxCode = get<3>(fev.addresses.at(fev.myAddress));
fev.code = &fev.thisTxCode;
fev.code = fev.thisTxCode;
}
bytes output;

Loading…
Cancel
Save