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

Commit 61bdc96

Browse files
committed
Test compile from solidity
1 parent 14e7e1c commit 61bdc96

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

ethereum/tests/test_solidity.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,34 @@ def sub1():
3131
}
3232
"""
3333

34+
@pytest.mark.xfail(reason="compilation from file seems to work with library, but the ABI-calling tx fails")
35+
@pytest.mark.skipif(get_solidity() is None, reason="'solc' compiler not available")
36+
def test_compile_from_file(tmpdir):
37+
contractsdir = tmpdir.mkdir("contracts")
38+
otherpath = contractsdir.join("Other.sol")
39+
otherpath.write("""library Other {
40+
function seven() returns (int256 y) {
41+
y = 7;
42+
}
43+
}
44+
""")
45+
userpath = contractsdir.join("user.sol")
46+
userpath.write("""import "Other.sol";
47+
contract user {
48+
function test() returns (int256 seven) {
49+
seven = Other.seven();
50+
}
51+
}
52+
""")
53+
s = tester.state()
54+
othercontract = s.abi_contract(None, path=str(otherpath), language='solidity')
55+
# assert othercontract.seven() == 7
56+
libraryuser = s.abi_contract('', path=str(userpath),
57+
# libraries still need to be supplied with their address:
58+
libraries={'Other': othercontract.address.encode('hex')},
59+
language='solidity')
60+
assert libraryuser.test() == 7
61+
3462

3563
@pytest.mark.skipif(get_solidity() is None, reason="'solc' compiler not available")
3664
def test_interop():

0 commit comments

Comments
 (0)