|
|
@ -35,7 +35,7 @@ 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) {} |
|
|
|
|
|
|
|
h160 FakeExtVM::create(u256 _endowment, u256* _gas, bytesConstRef _init, OnOpFunc) |
|
|
|
h160 FakeExtVM::create(u256 _endowment, u256* _gas, bytesConstRef _init, OnOpFunc const&) |
|
|
|
{ |
|
|
|
Transaction t; |
|
|
|
t.value = _endowment; |
|
|
@ -45,7 +45,7 @@ h160 FakeExtVM::create(u256 _endowment, u256* _gas, bytesConstRef _init, OnOpFun |
|
|
|
|
|
|
|
m_s.noteSending(myAddress); |
|
|
|
m_ms.internal.resize(m_ms.internal.size() + 1); |
|
|
|
auto ret = m_s.create(myAddress, _endowment, gasPrice, _gas, _init, origin, &suicides, &m_ms ? &(m_ms.internal.back()) : nullptr, OnOpFunc(), 1); |
|
|
|
auto ret = m_s.create(myAddress, _endowment, gasPrice, _gas, _init, origin, &suicides, &m_ms ? &(m_ms.internal.back()) : nullptr, {}, 1); |
|
|
|
if (!m_ms.internal.back().from) |
|
|
|
m_ms.internal.pop_back(); |
|
|
|
|
|
|
@ -61,7 +61,7 @@ h160 FakeExtVM::create(u256 _endowment, u256* _gas, bytesConstRef _init, OnOpFun |
|
|
|
return ret; |
|
|
|
} |
|
|
|
|
|
|
|
bool FakeExtVM::call(Address _receiveAddress, u256 _value, bytesConstRef _data, u256* _gas, bytesRef _out, OnOpFunc, Address _myAddressOverride = Address(), Address _codeAddressOverride = Address()) |
|
|
|
bool FakeExtVM::call(Address _receiveAddress, u256 _value, bytesConstRef _data, u256* _gas, bytesRef _out, OnOpFunc const&, Address _myAddressOverride, Address _codeAddressOverride) |
|
|
|
{ |
|
|
|
|
|
|
|
u256 contractgas = 0xffff; |
|
|
@ -576,8 +576,44 @@ void doTests(json_spirit::mValue& v, bool _fillin) |
|
|
|
else |
|
|
|
BOOST_CHECK(output == fromHex(o["out"].get_str())); |
|
|
|
|
|
|
|
BOOST_CHECK(test.toInt(o["gas"]) == vm.gas()); |
|
|
|
BOOST_CHECK(test.addresses == fev.addresses); |
|
|
|
BOOST_CHECK_EQUAL(test.toInt(o["gas"]), vm.gas()); |
|
|
|
|
|
|
|
auto& expectedAddrs = test.addresses; |
|
|
|
auto& resultAddrs = fev.addresses; |
|
|
|
for (auto&& expectedPair : expectedAddrs) |
|
|
|
{ |
|
|
|
auto& expectedAddr = expectedPair.first; |
|
|
|
auto resultAddrIt = resultAddrs.find(expectedAddr); |
|
|
|
if (resultAddrIt == resultAddrs.end()) |
|
|
|
BOOST_ERROR("Missing expected address " << expectedAddr); |
|
|
|
else |
|
|
|
{ |
|
|
|
auto& expectedState = expectedPair.second; |
|
|
|
auto& resultState = resultAddrIt->second; |
|
|
|
BOOST_CHECK_MESSAGE(std::get<0>(expectedState) == std::get<0>(resultState), expectedAddr << ": incorrect balance " << std::get<0>(resultState) << ", expected " << std::get<0>(expectedState)); |
|
|
|
BOOST_CHECK_MESSAGE(std::get<1>(expectedState) == std::get<1>(resultState), expectedAddr << ": incorrect txCount " << std::get<1>(resultState) << ", expected " << std::get<1>(expectedState)); |
|
|
|
BOOST_CHECK_MESSAGE(std::get<3>(expectedState) == std::get<3>(resultState), expectedAddr << ": incorrect code"); |
|
|
|
|
|
|
|
auto&& expectedStore = std::get<2>(expectedState); |
|
|
|
auto&& resultStore = std::get<2>(resultState); |
|
|
|
|
|
|
|
for (auto&& expectedStorePair : expectedStore) |
|
|
|
{ |
|
|
|
auto& expectedStoreKey = expectedStorePair.first; |
|
|
|
auto resultStoreIt = resultStore.find(expectedStoreKey); |
|
|
|
if (resultStoreIt == resultStore.end()) |
|
|
|
BOOST_ERROR(expectedAddr << ": missing store key " << expectedStoreKey); |
|
|
|
else |
|
|
|
{ |
|
|
|
auto& expectedStoreValue = expectedStorePair.second; |
|
|
|
auto& resultStoreValue = resultStoreIt->second; |
|
|
|
BOOST_CHECK_MESSAGE(expectedStoreValue == resultStoreValue, expectedAddr << ": store[" << expectedStoreKey << "] = " << resultStoreValue << ", expected " << expectedStoreValue); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
BOOST_CHECK(test.addresses == fev.addresses); // Just to make sure nothing missed
|
|
|
|
BOOST_CHECK(test.callcreates == fev.callcreates); |
|
|
|
} |
|
|
|
} |
|
|
@ -715,3 +751,4 @@ BOOST_AUTO_TEST_CASE(vmSystemOperationsTest) |
|
|
|
{ |
|
|
|
dev::test::executeTests("vmSystemOperationsTest"); |
|
|
|
} |
|
|
|
|
|
|
|