mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Another round of fixing ExtVM interface
This commit is contained in:
parent
29ad070d07
commit
1b2d4c25e6
19
vm.cpp
19
vm.cpp
@ -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.
|
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(), 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;
|
Transaction t;
|
||||||
t.value = _endowment;
|
t.value = _endowment;
|
||||||
@ -45,7 +45,7 @@ h160 FakeExtVM::create(u256 _endowment, u256* _gas, bytesConstRef _init, OnOpFun
|
|||||||
|
|
||||||
m_s.noteSending(myAddress);
|
m_s.noteSending(myAddress);
|
||||||
m_ms.internal.resize(m_ms.internal.size() + 1);
|
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)
|
if (!m_ms.internal.back().from)
|
||||||
m_ms.internal.pop_back();
|
m_ms.internal.pop_back();
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ h160 FakeExtVM::create(u256 _endowment, u256* _gas, bytesConstRef _init, OnOpFun
|
|||||||
return ret;
|
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(), Address _codeAddressOverride = Address())
|
||||||
{
|
{
|
||||||
|
|
||||||
u256 contractgas = 0xffff;
|
u256 contractgas = 0xffff;
|
||||||
@ -91,7 +91,7 @@ bool FakeExtVM::call(Address _receiveAddress, u256 _value, bytesConstRef _data,
|
|||||||
if (!m_s.addresses().count(myAddress))
|
if (!m_s.addresses().count(myAddress))
|
||||||
{
|
{
|
||||||
m_ms.internal.resize(m_ms.internal.size() + 1);
|
m_ms.internal.resize(m_ms.internal.size() + 1);
|
||||||
auto na = m_s.createNewAddress(myAddress, myAddress, balance(myAddress), gasPrice, &contractgas, init, origin, &suicides, &m_ms ? &(m_ms.internal.back()) : nullptr, OnOpFunc(), 1);
|
auto na = m_s.createNewAddress(myAddress, myAddress, balance(myAddress), gasPrice, &contractgas, init, origin, &suicides, &m_ms ? &(m_ms.internal.back()) : nullptr, {}, 1);
|
||||||
if (!m_ms.internal.back().from)
|
if (!m_ms.internal.back().from)
|
||||||
m_ms.internal.pop_back();
|
m_ms.internal.pop_back();
|
||||||
if (na != myAddress)
|
if (na != myAddress)
|
||||||
@ -588,6 +588,17 @@ void doTests(json_spirit::mValue& v, bool _fillin)
|
|||||||
else
|
else
|
||||||
BOOST_CHECK(output == fromHex(o["out"].get_str()));
|
BOOST_CHECK(output == fromHex(o["out"].get_str()));
|
||||||
|
|
||||||
|
//auto a = fev.addresses.at(fev.myAddress);
|
||||||
|
//auto b = test.addresses.at(fev.myAddress);
|
||||||
|
|
||||||
|
//auto t = a == b;
|
||||||
|
//auto t0 = get<0>(a) == get<0>(b);
|
||||||
|
//auto t1 = get<1>(a) == get<1>(b);
|
||||||
|
//auto t2 = get<2>(a) == get<2>(b);
|
||||||
|
//auto t3 = get<3>(a) == get<3>(b);
|
||||||
|
|
||||||
|
//BOOST_CHECK_EQUAL(get<0>(a), get<0>(b));
|
||||||
|
|
||||||
BOOST_CHECK(test.toInt(o["gas"]) == gas);
|
BOOST_CHECK(test.toInt(o["gas"]) == gas);
|
||||||
BOOST_CHECK(test.addresses == fev.addresses);
|
BOOST_CHECK(test.addresses == fev.addresses);
|
||||||
BOOST_CHECK(test.callcreates == fev.callcreates);
|
BOOST_CHECK(test.callcreates == fev.callcreates);
|
||||||
|
18
vm.h
18
vm.h
@ -53,15 +53,15 @@ public:
|
|||||||
FakeExtVM() {}
|
FakeExtVM() {}
|
||||||
FakeExtVM(eth::BlockInfo const& _previousBlock, eth::BlockInfo const& _currentBlock, unsigned _depth = 0);
|
FakeExtVM(eth::BlockInfo const& _previousBlock, eth::BlockInfo const& _currentBlock, unsigned _depth = 0);
|
||||||
|
|
||||||
u256 store(u256 _n) { return std::get<2>(addresses[myAddress])[_n]; }
|
u256 store(u256 _n) override { return std::get<2>(addresses[myAddress])[_n]; }
|
||||||
void setStore(u256 _n, u256 _v) { std::get<2>(addresses[myAddress])[_n] = _v; }
|
void setStore(u256 _n, u256 _v) override { std::get<2>(addresses[myAddress])[_n] = _v; }
|
||||||
u256 balance(Address _a) { return std::get<0>(addresses[_a]); }
|
u256 balance(Address _a) override { return std::get<0>(addresses[_a]); }
|
||||||
void subBalance(u256 _a) { std::get<0>(addresses[myAddress]) -= _a; }
|
void subBalance(u256 _a) override { std::get<0>(addresses[myAddress]) -= _a; }
|
||||||
u256 txCount(Address _a) { return std::get<1>(addresses[_a]); }
|
u256 txCount(Address _a) override { return std::get<1>(addresses[_a]); }
|
||||||
void suicide(Address _a) { std::get<0>(addresses[_a]) += std::get<0>(addresses[myAddress]); addresses.erase(myAddress); }
|
void suicide(Address _a) override { std::get<0>(addresses[_a]) += std::get<0>(addresses[myAddress]); addresses.erase(myAddress); }
|
||||||
bytes const& codeAt(Address _a) { return std::get<3>(addresses[_a]); }
|
bytes const& codeAt(Address _a) override { return std::get<3>(addresses[_a]); }
|
||||||
h160 create(u256 _endowment, u256* _gas, bytesConstRef _init, eth::OnOpFunc);
|
h160 create(u256 _endowment, u256* _gas, bytesConstRef _init, eth::OnOpFunc const&) override;
|
||||||
bool call(Address _receiveAddress, u256 _value, bytesConstRef _data, u256* _gas, bytesRef _out, eth::OnOpFunc, Address, Address);
|
bool call(Address _receiveAddress, u256 _value, bytesConstRef _data, u256* _gas, bytesRef _out, eth::OnOpFunc const&, Address, Address) override;
|
||||||
void setTransaction(Address _caller, u256 _value, u256 _gasPrice, bytes const& _data);
|
void setTransaction(Address _caller, u256 _value, u256 _gasPrice, bytes const& _data);
|
||||||
void setContract(Address _myAddress, u256 _myBalance, u256 _myNonce, std::map<u256, u256> const& _storage, bytes const& _code);
|
void setContract(Address _myAddress, u256 _myBalance, u256 _myNonce, std::map<u256, u256> const& _storage, bytes const& _code);
|
||||||
void set(Address _a, u256 _myBalance, u256 _myNonce, std::map<u256, u256> const& _storage, bytes const& _code);
|
void set(Address _a, u256 _myBalance, u256 _myNonce, std::map<u256, u256> const& _storage, bytes const& _code);
|
||||||
|
Loading…
Reference in New Issue
Block a user