Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tserg committed Oct 2, 2024
1 parent 8439d5b commit 2539997
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions tests/functional/codegen/modules/test_interface_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,56 @@ def foo() -> bool:
c = get_contract(main, input_bundle=input_bundle)

assert c.foo() is True


def test_import_interface_constants(make_input_bundle, get_contract):
ifaces = """
FOO: constant(uint256) = 3
interface IFoo:
def foo() -> DynArray[uint256, FOO]: nonpayable
"""

contract = """
import ifaces
implements: ifaces
@external
def foo() -> DynArray[uint256, ifaces.FOO]:
return [1, 2, ifaces.FOO]
"""

input_bundle = make_input_bundle({"ifaces.vyi": ifaces})

c = get_contract(contract, input_bundle=input_bundle)

assert c.foo() == [1, 2, 3]


def test_import_interface_flags(make_input_bundle, get_contract):
ifaces = """
flag Foo:
BOO
MOO
POO
interface IFoo:
def foo() -> Foo: nonpayable
"""

contract = """
import ifaces
implements: ifaces
@external
def foo() -> ifaces.Foo:
return ifaces.Foo.POO
"""

input_bundle = make_input_bundle({"ifaces.vyi": ifaces})

c = get_contract(contract, input_bundle=input_bundle)

assert c.foo() == 4

0 comments on commit 2539997

Please sign in to comment.