mirror of https://github.com/nucypher/nucypher.git
Adapt tests to new registry fetching; extract common fixture.
parent
2e21c26b18
commit
da7a572549
|
@ -16,7 +16,6 @@ along with nucypher. If not, see <https://www.gnu.org/licenses/>.
|
|||
"""
|
||||
|
||||
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):
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue