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

Commit 35b0530

Browse files
committed
fixed: test_solidity
1 parent dd18d33 commit 35b0530

File tree

1 file changed

+5
-64
lines changed

1 file changed

+5
-64
lines changed

ethereum/tests/test_solidity.py

Lines changed: 5 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from ethereum import tester
2-
import pytest
32
serpent_contract = """
43
extern solidity: [sub2:_:i]
54
@@ -14,7 +13,7 @@ def sub1():
1413
solidity_contract = """
1514
contract serpent { function sub1() returns (int256 y) {} }
1615
17-
contract foo {
16+
contract zoo {
1817
function main(address a) returns (int256 y) {
1918
y = serpent(a).sub1() * 2;
2019
}
@@ -26,69 +25,11 @@ def sub1():
2625
"""
2726

2827

29-
@pytest.mark.xfail # pysol is currently broken
3028
def test_interop():
3129
s = tester.state()
3230
c1 = s.abi_contract(serpent_contract)
33-
c2 = s.abi_contract(solidity_contract, language='solidity')
34-
# assert c1.sub1() == 5
35-
# assert c2.sub2() == 7
36-
# assert c1.main(c2.address) == 14
37-
# assert c2.main(c1.address) == 10
38-
39-
40-
if __name__ == '__main__':
41-
42-
import subprocess
43-
44-
one_solidity_contract = """
45-
46-
contract foo {
47-
function main(address a) returns (address b) {
48-
b = a;
49-
return b;
50-
}
51-
function sub2() returns (int256 y) {
52-
y = 7;
53-
}
54-
}
55-
56-
"""
57-
58-
class CompileError(Exception):
59-
pass
60-
61-
class solc_wrapper(object):
62-
63-
@classmethod
64-
def compile(cls, code):
65-
p = subprocess.Popen(['solc', '--binary', 'stdout'],
66-
stdin=subprocess.PIPE, stdout=subprocess.PIPE)
67-
stdoutdata, stderrdata = p.communicate(input=code)
68-
if p.returncode:
69-
raise CompileError('compilation failed')
70-
71-
hex_code = stdoutdata.rsplit('Binary: \n')[-1].strip()
72-
return hex_code.decode('hex')
73-
74-
@classmethod
75-
def mk_full_signature(cls, code):
76-
p = subprocess.Popen(['solc', '--json-abi', 'stdout'],
77-
stdin=subprocess.PIPE, stdout=subprocess.PIPE)
78-
stdoutdata, stderrdata = p.communicate(input=code)
79-
if p.returncode:
80-
raise CompileError('compilation failed')
81-
jsonabi = stdoutdata.rsplit('Contract JSON ABI\n')[-1].strip()
82-
return jsonabi
83-
84-
tester.languages['solidity'] = solc_wrapper
85-
86-
bytecode = solc_wrapper.compile(one_solidity_contract)
87-
jsonabi = solc_wrapper.mk_full_signature(one_solidity_contract)
88-
89-
# test
90-
s = tester.state()
91-
c2 = s.abi_contract(one_solidity_contract, language='solidity')
92-
a = '\0' * 20
93-
assert c2.main(a).decode('hex') == a
31+
c2 = s.abi_contract(solidity_contract, language='solidity') # should be zoo
32+
assert c1.sub1() == 5
9433
assert c2.sub2() == 7
34+
assert c1.main(c2.address) == 14
35+
assert c2.main(c1.address) == 10

0 commit comments

Comments
 (0)