Skip to content

Commit

Permalink
test: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Sep 26, 2023
1 parent e22d183 commit b9f500e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
24 changes: 17 additions & 7 deletions src/ape/managers/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ class DeploymentConfigCollection(BaseModel):

@root_validator(pre=True)
def validate_deployments(cls, data: Dict):
valid_ecosystems = data.pop("valid_ecosystems", {})
valid_networks = data.pop("valid_networks", {})
for ecosystem_name, networks in data.items():
root_data = data.get("__root__", data)
valid_ecosystems = root_data.pop("valid_ecosystems", {})
valid_networks = root_data.pop("valid_networks", {})
valid_data = {}
for ecosystem_name, networks in root_data.items():
if ecosystem_name not in valid_ecosystems:
logger.warning(f"Invalid ecosystem '{ecosystem_name}' in deployments config.")
continue
Expand All @@ -46,21 +48,29 @@ def validate_deployments(cls, data: Dict):
logger.warning(f"Invalid network '{network_name}' in deployments config.")
continue

valid_deployments = []
for deployment in [d for d in contract_deployments]:
address = deployment.get("address", None)
if "address" not in deployment:
if not (address := deployment.get("address")):
logger.warning(
f"Missing 'address' field in deployment "
f"(ecosystem={ecosystem_name}, network={network_name})"
)
continue

valid_deployment = {**deployment}
try:
deployment["address"] = ecosystem.decode_address(address)
valid_deployment["address"] = ecosystem.decode_address(address)
except ValueError as err:
logger.warning(str(err))

return data
valid_deployments.append(valid_deployment)

valid_data[ecosystem_name] = {
**valid_data.get(ecosystem_name, {}),
network_name: valid_deployments,
}

return {"__root__": valid_data}


class ConfigManager(BaseInterfaceModel):
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_integer_deployment_addresses(networks):
}
config = DeploymentConfigCollection(__root__=data)
assert (
config.root["ethereum"]["local"][0]["address"]
config.__root__["ethereum"]["local"][0]["address"]
== "0x0c25212c557d00024b7Ca3df3238683A35541354"
)

Expand Down

0 comments on commit b9f500e

Please sign in to comment.