Skip to content

Commit

Permalink
Omit proxy key, update error message
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielSchiavini committed Aug 15, 2024
1 parent e42232a commit 81df170
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 30 deletions.
2 changes: 1 addition & 1 deletion boa_zksync/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def compile_zksync(
if source_code is None:
with open(filename) as file:
source_code = file.read()

compile_output = get_compiler_output(output)
bytecode = to_bytes(compile_output.pop("bytecode"))
return ZksyncCompilerData(
Expand Down
12 changes: 6 additions & 6 deletions boa_zksync/compiler_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ def get_compiler_output(output):
# we need this helper method to get the correct key containing compiler output
# from the compiler. Assuming key names could change and also assuming that the
# number of keys could change, this method breaks if any of that happens:
excluded_keys = {"version", "zk_version"}

excluded_keys = {"version", "zk_version", "__VYPER_MINIMAL_PROXY_CONTRACT"}
contract_keys = set(output.keys()) - excluded_keys

if len(contract_keys) != 1:
raise ValueError(f"Expected exactly one contract key, found {len(contract_keys)}")
return output[next(iter(contract_keys))]
raise ValueError(f"Expected exactly one contract key, found {contract_keys}")

return output[next(iter(contract_keys))]
1 change: 1 addition & 0 deletions boa_zksync/deployer.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def env(self) -> "ZksyncEnv":
"""
env = Env.get_singleton()
from boa_zksync.environment import ZksyncEnv

assert isinstance(
env, ZksyncEnv
), "ZksyncDeployer can only be used in zkSync environments"
Expand Down
44 changes: 21 additions & 23 deletions tests/test_get_compiler_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,34 @@


def test_get_compiler_output():

output_dict = {
"blabla": 123,
"zk_version": 456,
"version": 789,
}

get_compiler_output(output_dict) == 123


def test_get_compiler_output_revert_too_many_keys():

output_dict = {"blabla": 123, "zk_version": 456, "version": 789}

assert get_compiler_output(output_dict) == 123


def test_get_compiler_output_too_many_keys():

output_dict = {
"blabla": 123,
"zk_version": 456,
"version": 789,
"new_compiler_output_key": 101112,
}

with pytest.raises(ValueError, match="Expected exactly one contract key, found 2"):

with pytest.raises(
ValueError,
match="Expected exactly one contract key, found {'blabla', 'new_compiler_output_key'}",
):
get_compiler_output(output_dict)


def test_get_compiler_output_revert_unexpected_key():
output_dict = {
"blabla": 123,
"zk_versions": 456,
"version": 789,
}

with pytest.raises(ValueError, match="Expected exactly one contract key, found 2"):

def test_get_compiler_output_unexpected_key():

output_dict = {"blabla": 123, "zk_versions": 456, "version": 789}

with pytest.raises(
ValueError,
match="Expected exactly one contract key, found {'blabla', 'zk_versions'}",
):
get_compiler_output(output_dict)

0 comments on commit 81df170

Please sign in to comment.