diff --git a/tests/blockchain/eth/interfaces/test_registry.py b/tests/blockchain/eth/interfaces/test_registry.py index 394776c3e..6b125ad4a 100644 --- a/tests/blockchain/eth/interfaces/test_registry.py +++ b/tests/blockchain/eth/interfaces/test_registry.py @@ -16,7 +16,6 @@ along with nucypher. If not, see . """ import json -import os import pytest from nucypher.blockchain.eth.deployers import PreallocationEscrowDeployer @@ -25,22 +24,8 @@ from nucypher.blockchain.eth.registry import LocalContractRegistry, IndividualAl @pytest.fixture(autouse=True, scope='module') -def patch_individual_allocation_registry_fetch_latest_publication(agency, test_registry): - empty_allocation_escrow_deployer = PreallocationEscrowDeployer(registry=test_registry) - allocation_contract_abi = empty_allocation_escrow_deployer.get_contract_abi() - allocation_template = { - "BENEFICIARY_ADDRESS": ["ALLOCATION_CONTRACT_ADDRESS", allocation_contract_abi] - } - new_fetch_result = json.dumps(allocation_template).encode() - - original_fetch = IndividualAllocationRegistry.fetch_latest_publication - - def new_fetch(*args, **kwargs): - return new_fetch_result - - IndividualAllocationRegistry.fetch_latest_publication = new_fetch - yield - IndividualAllocationRegistry.fetch_latest_publication = original_fetch +def patch_individual_allocation_fetch_latest_publication(_patch_individual_allocation_fetch_latest_publication): + pass def test_contract_registry(tempfile_path): diff --git a/tests/cli/ursula/test_stake_via_allocation_contract.py b/tests/cli/ursula/test_stake_via_allocation_contract.py index 593e7ddc6..c8bcded99 100644 --- a/tests/cli/ursula/test_stake_via_allocation_contract.py +++ b/tests/cli/ursula/test_stake_via_allocation_contract.py @@ -53,22 +53,8 @@ from nucypher.utilities.sandbox.middleware import MockRestMiddleware @pytest.fixture(autouse=True, scope='module') -def patch_fetch_latest_publication(test_registry): - empty_allocation_escrow_deployer = PreallocationEscrowDeployer(registry=test_registry) - allocation_contract_abi = empty_allocation_escrow_deployer.get_contract_abi() - allocation_template = { - "BENEFICIARY_ADDRESS": ["ALLOCATION_CONTRACT_ADDRESS", allocation_contract_abi] - } - new_fetch_result = json.dumps(allocation_template).encode() - - original_fetch = IndividualAllocationRegistry.fetch_latest_publication - - def new_fetch(*args, **kwargs): - return new_fetch_result - - IndividualAllocationRegistry.fetch_latest_publication = new_fetch - yield - IndividualAllocationRegistry.fetch_latest_publication = original_fetch +def patch_individual_allocation_fetch_latest_publication(_patch_individual_allocation_fetch_latest_publication): + pass @pytest.fixture(scope='module') diff --git a/tests/fixtures.py b/tests/fixtures.py index 0fefff7e6..6e9aa4150 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -40,9 +40,11 @@ from nucypher.blockchain.eth.clients import NuCypherGethDevProcess from nucypher.blockchain.eth.deployers import (NucypherTokenDeployer, StakingEscrowDeployer, PolicyManagerDeployer, - AdjudicatorDeployer, StakingInterfaceDeployer) + AdjudicatorDeployer, + StakingInterfaceDeployer, + PreallocationEscrowDeployer) from nucypher.blockchain.eth.interfaces import BlockchainInterfaceFactory -from nucypher.blockchain.eth.registry import InMemoryContractRegistry +from nucypher.blockchain.eth.registry import InMemoryContractRegistry, GithubRegistrySource from nucypher.blockchain.eth.sol.compile import SolidityCompiler from nucypher.blockchain.eth.token import NU from nucypher.characters.lawful import Enrico, Bob @@ -823,3 +825,20 @@ def get_random_checksum_address(): checksum_address = to_checksum_address(canonical_address) return checksum_address return _get_random_checksum_address + + +@pytest.fixture(scope='module') +def _patch_individual_allocation_fetch_latest_publication(agency, test_registry): + empty_allocation_escrow_deployer = PreallocationEscrowDeployer(registry=test_registry) + allocation_contract_abi = empty_allocation_escrow_deployer.get_contract_abi() + allocation_template = { + "BENEFICIARY_ADDRESS": ["ALLOCATION_CONTRACT_ADDRESS", allocation_contract_abi] + } + + def new_fetch(*args, **kwargs): + return json.dumps(allocation_template).encode() + + original_fetch = GithubRegistrySource.fetch_latest_publication + GithubRegistrySource.fetch_latest_publication = new_fetch + yield + GithubRegistrySource.fetch_latest_publication = original_fetch