Fix evm RETURN implementation (#808)

* Fix write_buffer issue (#807)

* Add test for write_buffer fix

* Use Operators.ORD instead of ord (even though were assuming concrete vals)

* Cleanup
This commit is contained in:
Yan Ivnitskiy 2018-03-12 15:27:18 -04:00 committed by GitHub
parent bb4a7966a8
commit 61babdbe21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 4 deletions

View File

@ -1805,10 +1805,8 @@ class EVM(Eventful):
return data
def write_buffer(self, offset, buf):
count = 0
for c in buf:
self._store(offset + count, c)
count += 1
for i, c in enumerate(buf):
self._store(offset+i, Operators.ORD(c))
def CREATE(self, value, offset, size):
'''Create a new account with associated code'''

View File

@ -102,3 +102,23 @@ class EthTests(unittest.TestCase):
x = mevm.create_account(balance=0)
contract_account = mevm.solidity_create_contract(source_code,
contract_name="C", owner=owner, args=[x])
def test_writebuffer_doesnt_raise(self):
mevm = ManticoreEVM()
source_code = """
contract X {
mapping(address => uint) private balance;
function f(address z) returns (uint) { return balance[z]; }
}
contract C {
X y;
function C() {
y = new X();
uint z = y.f(0);
}
}"""
# Make sure that write_buffer (used by RETURN) succeeds without errors
owner = mevm.create_account(balance=1000)
x = mevm.create_account(balance=0)
contract_account = mevm.solidity_create_contract(source_code,
contract_name="C", owner=owner, args=[x])