Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Commit a359833

Browse files
committed
Passing all tests in py2 and py3
1 parent 792b14a commit a359833

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

ethereum/tests/test_contracts.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
from ethereum.tools import tester
1111
from ethereum.utils import safe_ord, big_endian_to_int
1212

13+
# from ethereum.slogging import get_logger, configure_logging
14+
# logger = get_logger()
15+
# configure_logging(':trace')
16+
1317

1418
# Test EVM contracts
1519
serpent_code = """

ethereum/vm.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from ethereum.abi import is_numeric
1414
from ethereum import opcodes
1515
from ethereum.slogging import get_logger
16-
from ethereum.utils import to_string, encode_int, zpad, bytearray_to_bytestr
16+
from ethereum.utils import to_string, encode_int, zpad, bytearray_to_bytestr, safe_ord
1717

1818
if sys.version_info.major == 2:
1919
from repoze.lru import lru_cache
@@ -114,11 +114,12 @@ def preprocess_code(code):
114114
pushcache = {}
115115
code = code + b'\x00' * 32
116116
while i < len(code) - 32:
117-
if code[i] == 0x5b:
117+
codebyte = safe_ord(code[i])
118+
if codebyte == 0x5b:
118119
o |= 1 << i
119-
if 0x60 <= code[i] <= 0x7f:
120-
pushcache[i] = utils.big_endian_to_int(code[i + 1: i + code[i] - 0x5e])
121-
i += code[i] - 0x5e
120+
if 0x60 <= codebyte <= 0x7f:
121+
pushcache[i] = utils.big_endian_to_int(code[i + 1: i + codebyte - 0x5e])
122+
i += codebyte - 0x5e
122123
else:
123124
i += 1
124125
return o, pushcache
@@ -203,7 +204,7 @@ def vm_execute(ext, msg, code):
203204

204205
while compustate.pc < codelen:
205206

206-
opcode = code[compustate.pc]
207+
opcode = safe_ord(code[compustate.pc])
207208

208209
# Invalid operation
209210
if opcode not in opcodes.opcodes:

0 commit comments

Comments
 (0)