Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add another borrowship test #3802

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion tests/functional/syntax/modules/test_initializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ def foo():

@external
def foo(new_value: uint256):
# can access lib1 state through lib2?
# cannot access lib1 state through lib2, lib2 does not `use` lib1.
lib2.lib1.counter = new_value
"""
input_bundle = make_input_bundle({"lib1.vy": lib1, "lib2.vy": lib2})
Expand All @@ -860,6 +860,35 @@ def foo(new_value: uint256):
assert e.value._hint == expected_hint


def test_uses_skip_import2(make_input_bundle):
lib1 = """
counter: uint256
"""
lib2 = """
import lib1

initializes: lib1

@internal
def foo():
pass
"""
main = """
import lib1
import lib2

initializes: lib2

@external
def foo(new_value: uint256):
# *can* access lib1 state through lib2, because lib2 initializes lib1
lib2.lib1.counter = new_value
"""
input_bundle = make_input_bundle({"lib1.vy": lib1, "lib2.vy": lib2})

assert compile_code(main, input_bundle=input_bundle) is not None


def test_invalid_uses(make_input_bundle, chdir_tmp_path):
lib1 = """
counter: uint256
Expand Down
Loading