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:
parent
bb4a7966a8
commit
61babdbe21
@ -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'''
|
||||
|
||||
@ -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])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user