Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-cooper committed Sep 1, 2023
1 parent ee2d42e commit 9416730
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions tests/parser/functions/test_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ def bar() -> uint256:
)


# check that event types match
def test_malformed_event(assert_compile_failed):
interface_code = """
event Foo:
Expand Down Expand Up @@ -172,6 +173,64 @@ def bar() -> uint256:
)


# check that event non-indexed arg needs to match interface
def test_malformed_events_indexed(assert_compile_failed):
interface_code = """
event Foo:
a: uint256
"""

interface_codes = {"FooBarInterface": {"type": "vyper", "code": interface_code}}

not_implemented_code = """
import a as FooBarInterface
implements: FooBarInterface
# a should not be indexed
event Foo:
a: indexed(uint256)
@external
def bar() -> uint256:
return 1
"""

assert_compile_failed(
lambda: compile_code(not_implemented_code, interface_codes=interface_codes),
InterfaceViolation,
)


# check that event indexed arg needs to match interface
def test_malformed_events_indexed2(assert_compile_failed):
interface_code = """
event Foo:
a: indexed(uint256)
"""

interface_codes = {"FooBarInterface": {"type": "vyper", "code": interface_code}}

not_implemented_code = """
import a as FooBarInterface
implements: FooBarInterface
# a should be indexed
event Foo:
a: uint256
@external
def bar() -> uint256:
return 1
"""

assert_compile_failed(
lambda: compile_code(not_implemented_code, interface_codes=interface_codes),
InterfaceViolation,
)


VALID_IMPORT_CODE = [
# import statement, import path without suffix
("import a as Foo", "a"),
Expand Down

0 comments on commit 9416730

Please sign in to comment.