Skip to content

Commit

Permalink
test: correct part of test
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Feb 5, 2024
1 parent e979257 commit edbf756
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions tests/functional/test_config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import tempfile
from pathlib import Path
from typing import Dict, Union
from typing import Dict, Optional, Union

import pytest
from pydantic_settings import SettingsConfigDict
Expand All @@ -19,21 +19,30 @@
from tests.functional.conftest import PROJECT_WITH_LONG_CONTRACTS_FOLDER


def test_deployments(networks, owner, vyper_contract_container):
def test_deployments(networks_connected_to_tester, owner, vyper_contract_container, config):
networks = networks_connected_to_tester # Connection needs to lookup config.

# First, obtain a "previously-deployed" contract.
instance = vyper_contract_container.deploy(1000200000, sender=owner)
address = instance.address

# Create a config using this new contract for a "later time".
data = {
**_create_deployments(address=instance.address),
**_create_deployments(address=address, contract_name=instance.contract_type.name),
"valid_ecosystems": {"ethereum": networks.ethereum},
"valid_networks": [LOCAL_NETWORK_NAME],
}
config = DeploymentConfigCollection(root=data)
assert config.root["ethereum"]["local"][0]["address"] == instance.address
deploy_config = DeploymentConfigCollection(root=data)
assert deploy_config.root["ethereum"]["local"][0]["address"] == address

orig = config.deployments
config.deployments = deploy_config
try:
# Ensure we can reference the deployment on the contract.
deployment = vyper_contract_container.deployments[0]
finally:
config.deployments = orig

# Ensure we can reference the deployment on the project.
deployment = vyper_contract_container.deployments[0]
assert deployment.address == instance.address


Expand Down Expand Up @@ -71,13 +80,14 @@ def _create_deployments(
ecosystem_name: str = "ethereum",
network_name: str = "local",
address: Union[int, str] = "0x0C25212C557D00024B7CA3DF3238683A35541354",
contract_name: Optional[str] = "MyContract",
) -> Dict:
return {
ecosystem_name: {
network_name: [
{
"address": address,
"contract_type": "MyContract",
"contract_type": contract_name,
}
]
}
Expand Down

0 comments on commit edbf756

Please sign in to comment.