diff --git a/nucypher/acumen/perception.py b/nucypher/acumen/perception.py index 85314cd6e..dba60af95 100644 --- a/nucypher/acumen/perception.py +++ b/nucypher/acumen/perception.py @@ -9,9 +9,9 @@ from eth_typing import ChecksumAddress from nucypher_core import FleetStateChecksum, NodeMetadata from nucypher import characters -from nucypher.blockchain.eth.domains import TACoDomain from nucypher.utilities.logging import Logger +from ..blockchain.eth.domains import TACoDomain from .nicknames import Nickname diff --git a/nucypher/blockchain/eth/domains.py b/nucypher/blockchain/eth/domains.py index 588606a39..e64c056b0 100644 --- a/nucypher/blockchain/eth/domains.py +++ b/nucypher/blockchain/eth/domains.py @@ -1,5 +1,5 @@ from enum import Enum -from typing import Any, Dict, NamedTuple +from typing import Any, Dict, NamedTuple, Tuple from cytoolz.functoolz import memoize @@ -25,10 +25,17 @@ class PolygonChain(ChainInfo, Enum): class TACoDomain: - def __init__(self, name: str, eth_chain: EthChain, polygon_chain: PolygonChain): + def __init__( + self, + name: str, + eth_chain: EthChain, + polygon_chain: PolygonChain, + condition_chains: Tuple[ChainInfo, ...], + ): self.name = name self.eth_chain = eth_chain self.polygon_chain = polygon_chain + self.condition_chains = condition_chains def __repr__(self) -> str: return f"" @@ -63,18 +70,26 @@ MAINNET = TACoDomain( name="mainnet", eth_chain=EthChain.MAINNET, polygon_chain=PolygonChain.MAINNET, + condition_chains=(EthChain.MAINNET, PolygonChain.MAINNET), ) LYNX = TACoDomain( name="lynx", eth_chain=EthChain.GOERLI, polygon_chain=PolygonChain.MUMBAI, + condition_chains=( + EthChain.MAINNET, + EthChain.GOERLI, + PolygonChain.MUMBAI, + PolygonChain.MAINNET, + ), ) TAPIR = TACoDomain( name="tapir", eth_chain=EthChain.SEPOLIA, polygon_chain=PolygonChain.MUMBAI, + condition_chains=(EthChain.SEPOLIA, PolygonChain.MUMBAI), ) diff --git a/nucypher/policy/payment.py b/nucypher/policy/payment.py index 0b27d67e4..e50e0b0a2 100644 --- a/nucypher/policy/payment.py +++ b/nucypher/policy/payment.py @@ -6,9 +6,9 @@ from nucypher_core import ReencryptionRequest from web3.types import ChecksumAddress, Timestamp, TxReceipt, Wei from nucypher.blockchain.eth.agents import ContractAgency, SubscriptionManagerAgent -from nucypher.blockchain.eth.domains import TACoDomain from nucypher.blockchain.eth.registry import ContractRegistry from nucypher.policy import policies +from tests.utils.registry import TACoDomain class PaymentMethod(ABC): diff --git a/scripts/hooks/nucypher_agents.py b/scripts/hooks/nucypher_agents.py index 63ee8fd91..7af9f4217 100644 --- a/scripts/hooks/nucypher_agents.py +++ b/scripts/hooks/nucypher_agents.py @@ -20,6 +20,7 @@ import rlcompleter import click +from nucypher.blockchain.eth import domains from nucypher.blockchain.eth.agents import ( ContractAgency, CoordinatorAgent, @@ -27,7 +28,6 @@ from nucypher.blockchain.eth.agents import ( TACoApplicationAgent, TACoChildApplicationAgent, ) -from nucypher.blockchain.eth import domains from nucypher.blockchain.eth.registry import ContractRegistry from nucypher.utilities.emitters import StdoutEmitter from nucypher.utilities.logging import GlobalLoggerSettings diff --git a/tests/constants.py b/tests/constants.py index b1a14c1dc..bd1978af5 100644 --- a/tests/constants.py +++ b/tests/constants.py @@ -79,6 +79,7 @@ TEMPORARY_DOMAIN = TACoDomain( name=TEMPORARY_DOMAIN_NAME, eth_chain=TESTERCHAIN_CHAIN_INFO, polygon_chain=TESTERCHAIN_CHAIN_INFO, + condition_chains=(TESTERCHAIN_CHAIN_INFO,), ) diff --git a/tests/fixtures.py b/tests/fixtures.py index 7e05d7854..4d99eeac4 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -306,8 +306,6 @@ def lonely_ursula_maker(ursula_test_config, testerchain): # # Blockchain # - - @pytest.fixture(scope="module") def mock_registry_sources(module_mocker): with tests.utils.registry.mock_registry_sources(module_mocker): diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 860b8907e..9fdfedf17 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -286,7 +286,6 @@ def mock_condition_blockchains(module_mocker): ) - @pytest.fixture(scope="module") def multichain_ids(module_mocker): ids = mock_permitted_multichain_connections(mocker=module_mocker) diff --git a/tests/integration/learning/test_domains.py b/tests/integration/learning/test_domains.py index f06832916..6b9493308 100644 --- a/tests/integration/learning/test_domains.py +++ b/tests/integration/learning/test_domains.py @@ -20,6 +20,7 @@ def domain_1(): name="domain_uno", eth_chain=TESTERCHAIN_CHAIN_INFO, polygon_chain=TESTERCHAIN_CHAIN_INFO, + condition_chains=(TESTERCHAIN_CHAIN_INFO,), ) @@ -29,6 +30,7 @@ def domain_2(): name="domain_dos", eth_chain=TESTERCHAIN_CHAIN_INFO, polygon_chain=TESTERCHAIN_CHAIN_INFO, + condition_chains=(TESTERCHAIN_CHAIN_INFO,), ) diff --git a/tests/unit/test_taco_domains.py b/tests/unit/test_taco_domains.py index 83fad77b3..de035c9bf 100644 --- a/tests/unit/test_taco_domains.py +++ b/tests/unit/test_taco_domains.py @@ -9,13 +9,13 @@ from nucypher.blockchain.eth.domains import ( @pytest.fixture(scope="module") def test_registry(module_mocker): - # override fixture which mocks SUPPORTED_DOMAINS + # override fixture which mocks domains.SUPPORTED_DOMAINS yield @pytest.fixture(scope="module", autouse=True) def mock_condition_blockchains(module_mocker): - # override fixture which mocks get_domain + # override fixture which mocks domains.get_domain yield @@ -49,9 +49,32 @@ def test_polygon_chains(poly_chain_test): @pytest.mark.parametrize( "taco_domain_test", ( - (domains.MAINNET, "mainnet", EthChain.MAINNET, PolygonChain.MAINNET), - (domains.LYNX, "lynx", EthChain.GOERLI, PolygonChain.MUMBAI), - (domains.TAPIR, "tapir", EthChain.SEPOLIA, PolygonChain.MUMBAI), + ( + domains.MAINNET, + "mainnet", + EthChain.MAINNET, + PolygonChain.MAINNET, + (EthChain.MAINNET, PolygonChain.MAINNET), + ), + ( + domains.LYNX, + "lynx", + EthChain.GOERLI, + PolygonChain.MUMBAI, + ( + EthChain.MAINNET, + EthChain.GOERLI, + PolygonChain.MUMBAI, + PolygonChain.MAINNET, + ), + ), + ( + domains.TAPIR, + "tapir", + EthChain.SEPOLIA, + PolygonChain.MUMBAI, + (EthChain.SEPOLIA, PolygonChain.MUMBAI), + ), ), ) def test_taco_domain_info(taco_domain_test): diff --git a/tests/unit/test_teacher_nodes.py b/tests/unit/test_teacher_nodes.py index 12b42e3ad..7d727e905 100644 --- a/tests/unit/test_teacher_nodes.py +++ b/tests/unit/test_teacher_nodes.py @@ -12,7 +12,7 @@ def mock_teacher_nodes(mocker): @pytest.fixture(scope="module") def test_registry(module_mocker): - # override fixture which mocks SUPPORTED_DOMAINS + # override fixture which mocks domains.SUPPORTED_DOMAINS yield diff --git a/tests/utils/registry.py b/tests/utils/registry.py index fb052cdba..f42199c60 100644 --- a/tests/utils/registry.py +++ b/tests/utils/registry.py @@ -19,12 +19,10 @@ from tests.constants import TEMPORARY_DOMAIN def mock_registry_sources(mocker, _domains: List[TACoDomain] = None): if not _domains: _domains = [TEMPORARY_DOMAIN] - _supported_domains = mocker.patch.dict( "nucypher.blockchain.eth.domains.SUPPORTED_DOMAINS", {str(domain): domain for domain in _domains}, ) - mocker.patch.object(MockRegistrySource, "ALLOWED_DOMAINS", list(map(str, _domains))) mocker.patch.object(RegistrySourceManager, "_FALLBACK_CHAIN", (MockRegistrySource,)) yield