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

Commit a710989

Browse files
committed
proper use of bytes for python 3
1 parent 857a783 commit a710989

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

ethereum/_solidity.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
import yaml
88

9+
from rlp.utils import decode_hex
10+
from . import utils
11+
912
BINARY = 'solc'
1013

1114

@@ -49,7 +52,7 @@ def solc_arguments(libraries=None, combined='bin,abi', optimize=True):
4952

5053
if libraries is not None and len(libraries):
5154
addresses = [
52-
'{name}:{address}'.format(name=name, address=address)
55+
'{name}:{address}'.format(name=name, address=address.decode('utf8'))
5356
for name, address in libraries.items()
5457
]
5558
args.extend([

ethereum/tests/test_contracts.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,8 +1207,8 @@ def test_ecrecover():
12071207
signature = pk.ecdsa_recoverable_serialize(
12081208
pk.ecdsa_sign_recoverable(msghash, raw=True)
12091209
)
1210-
signature = signature[0] + chr(signature[1])
1211-
V = ord(signature[64]) + 27
1210+
signature = signature[0] + utils.bytearray_to_bytestr([signature[1]])
1211+
V = utils.safe_ord(signature[64]) + 27
12121212
R = big_endian_to_int(signature[0:32])
12131213
S = big_endian_to_int(signature[32:64])
12141214

@@ -1629,9 +1629,15 @@ def test_string_logging():
16291629
o = []
16301630
s.block.log_listeners.append(lambda x: o.append(c.translator.listen(x)))
16311631
c.moo()
1632-
assert o == [{"_event_type": "foo", "x": "bob", "__hash_x": utils.sha3("bob"),
1633-
"y": "cow", "__hash_y": utils.sha3("cow"), "z": "dog",
1634-
"__hash_z": utils.sha3("dog")}]
1632+
assert o == [{
1633+
"_event_type": b"foo",
1634+
"x": b"bob",
1635+
"__hash_x": utils.sha3(b"bob"),
1636+
"y": b"cow",
1637+
"__hash_y": utils.sha3(b"cow"),
1638+
"z": b"dog",
1639+
"__hash_z": utils.sha3(b"dog"),
1640+
}]
16351641

16361642

16371643
params_code = """
@@ -1654,7 +1660,7 @@ def test_params_contract():
16541660
s = tester.state()
16551661
c = s.abi_contract(params_code, FOO=4, BAR='horse')
16561662
assert c.garble() == 4
1657-
assert c.marble() == 'horse'
1663+
assert c.marble() == b'horse'
16581664

16591665
prefix_types_in_functions_code = """
16601666
type fixedp: fp_

0 commit comments

Comments
 (0)