-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add load_vyi and loads_vyi (#314)
* feat: add load_vyi and loads_vyi create an ABIContractFactory from a vyi file
- Loading branch information
1 parent
651ed33
commit 86df893
Showing
3 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import pytest | ||
|
||
import boa | ||
|
||
FOO_CONTRACT = """ | ||
@external | ||
def foo() -> uint256: | ||
return 5 | ||
""" | ||
|
||
FOO_INTERFACE = """ | ||
@external | ||
def foo() -> uint256: | ||
... | ||
""" | ||
|
||
|
||
@pytest.fixture | ||
def foo_contract(): | ||
return boa.loads(FOO_CONTRACT) | ||
|
||
|
||
@pytest.fixture | ||
def foo_interface(foo_contract): | ||
return boa.loads_vyi(FOO_INTERFACE).at(foo_contract.address) | ||
|
||
|
||
# from file | ||
@pytest.fixture | ||
def foo_interface2(foo_contract, tmp_path): | ||
p = tmp_path / "foo.vyi" | ||
with p.open("w") as f: | ||
f.write(FOO_INTERFACE) | ||
return boa.load_vyi(p).at(foo_contract.address) | ||
|
||
|
||
def test_foo_interface(foo_interface): | ||
assert foo_interface.foo() == 5 | ||
|
||
|
||
def test_foo_interface2(foo_interface2): | ||
assert foo_interface2.foo() == 5 |