mirror of https://github.com/nucypher/nucypher.git
Blockchain -> BlockchainInterface
parent
91bc12e06b
commit
cd9b2366c8
|
@ -46,7 +46,7 @@ from nucypher.blockchain.eth.agents import (
|
|||
AdjudicatorAgent,
|
||||
EthereumContractAgent
|
||||
)
|
||||
from nucypher.blockchain.eth.interfaces import Blockchain
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainInterface
|
||||
from nucypher.blockchain.eth.deployers import (
|
||||
NucypherTokenDeployer,
|
||||
StakingEscrowDeployer,
|
||||
|
@ -55,7 +55,7 @@ from nucypher.blockchain.eth.deployers import (
|
|||
UserEscrowDeployer,
|
||||
AdjudicatorDeployer,
|
||||
ContractDeployer)
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainDeployer
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainDeployerInterface
|
||||
from nucypher.blockchain.eth.registry import AllocationRegistry
|
||||
from nucypher.blockchain.eth.token import NU, Stake, StakeTracker
|
||||
from nucypher.blockchain.eth.utils import datetime_to_period, calculate_period_duration
|
||||
|
@ -80,7 +80,7 @@ class NucypherTokenActor:
|
|||
class ActorError(Exception):
|
||||
pass
|
||||
|
||||
def __init__(self, blockchain: Blockchain, checksum_address: str = None):
|
||||
def __init__(self, blockchain: BlockchainInterface, checksum_address: str = None):
|
||||
"""
|
||||
:param checksum_address: If not passed, we assume this is an unknown actor
|
||||
"""
|
||||
|
@ -129,13 +129,13 @@ class Deployer(NucypherTokenActor):
|
|||
|
||||
contract_names = tuple(a.registry_contract_name for a in EthereumContractAgent.__subclasses__())
|
||||
|
||||
__interface_class = BlockchainDeployer
|
||||
__interface_class = BlockchainDeployerInterface
|
||||
|
||||
class UnknownContract(ValueError):
|
||||
pass
|
||||
|
||||
def __init__(self,
|
||||
blockchain: Blockchain,
|
||||
blockchain: BlockchainInterface,
|
||||
deployer_address: str = None,
|
||||
bare: bool = True
|
||||
) -> None:
|
||||
|
@ -163,7 +163,7 @@ class Deployer(NucypherTokenActor):
|
|||
|
||||
@classmethod
|
||||
def from_blockchain(cls, provider_uri: str, registry=None, *args, **kwargs):
|
||||
blockchain = Blockchain.connect(provider_uri=provider_uri, registry=registry)
|
||||
blockchain = BlockchainInterface.connect(provider_uri=provider_uri, registry=registry)
|
||||
instance = cls(blockchain=blockchain, *args, **kwargs)
|
||||
return instance
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ from twisted.logger import Logger
|
|||
from web3.contract import Contract
|
||||
|
||||
from nucypher.blockchain.eth.decorators import validate_checksum_address
|
||||
from nucypher.blockchain.eth.interfaces import Blockchain
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainInterface
|
||||
from nucypher.blockchain.eth.registry import AllocationRegistry
|
||||
|
||||
|
||||
|
@ -59,7 +59,7 @@ class EthereumContractAgent:
|
|||
pass
|
||||
|
||||
def __init__(self,
|
||||
blockchain: Blockchain = None,
|
||||
blockchain: BlockchainInterface = None,
|
||||
contract: Contract = None,
|
||||
transaction_gas: int = None
|
||||
) -> None:
|
||||
|
@ -67,7 +67,7 @@ class EthereumContractAgent:
|
|||
self.log = Logger(self.__class__.__name__)
|
||||
|
||||
if blockchain is None:
|
||||
blockchain = Blockchain.connect()
|
||||
blockchain = BlockchainInterface.connect()
|
||||
self.blockchain = blockchain
|
||||
|
||||
if contract is None: # Fetch the contract
|
||||
|
@ -215,7 +215,7 @@ class StakingEscrowAgent(EthereumContractAgent, metaclass=Agency):
|
|||
return receipt
|
||||
|
||||
def release_worker(self, staker_address: str):
|
||||
return self.set_worker(staker_address=staker_address, worker_address=Blockchain.NULL_ADDRESS)
|
||||
return self.set_worker(staker_address=staker_address, worker_address=BlockchainInterface.NULL_ADDRESS)
|
||||
|
||||
def confirm_activity(self, worker_address: str):
|
||||
"""
|
||||
|
@ -301,7 +301,7 @@ class StakingEscrowAgent(EthereumContractAgent, metaclass=Agency):
|
|||
deltas.append(next_point - previous_point)
|
||||
|
||||
addresses = set(self.contract.functions.sample(deltas, duration).call())
|
||||
addresses.discard(str(Blockchain.NULL_ADDRESS))
|
||||
addresses.discard(str(BlockchainInterface.NULL_ADDRESS))
|
||||
|
||||
if len(addresses) >= quantity:
|
||||
return system_random.sample(addresses, quantity)
|
||||
|
@ -386,11 +386,11 @@ class UserEscrowAgent(EthereumContractAgent):
|
|||
|
||||
def __init__(self,
|
||||
beneficiary: str,
|
||||
blockchain: Blockchain = None,
|
||||
blockchain: BlockchainInterface = None,
|
||||
allocation_registry: AllocationRegistry = None,
|
||||
*args, **kwargs) -> None:
|
||||
|
||||
self.blockchain = blockchain or Blockchain.connect()
|
||||
self.blockchain = blockchain or BlockchainInterface.connect()
|
||||
|
||||
self.__allocation_registry = allocation_registry or self.__allocation_registry()
|
||||
self.__beneficiary = beneficiary
|
||||
|
|
|
@ -30,16 +30,16 @@ from nucypher.blockchain.eth.agents import (
|
|||
UserEscrowAgent,
|
||||
AdjudicatorAgent)
|
||||
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainDeployer
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainDeployerInterface
|
||||
from nucypher.blockchain.eth.registry import AllocationRegistry
|
||||
from .interfaces import Blockchain
|
||||
from .interfaces import BlockchainInterface
|
||||
|
||||
|
||||
class ContractDeployer:
|
||||
|
||||
agency = NotImplemented
|
||||
contract_name = NotImplemented
|
||||
_interface_class = BlockchainDeployer
|
||||
_interface_class = BlockchainDeployerInterface
|
||||
_upgradeable = NotImplemented
|
||||
__proxy_deployer = NotImplemented
|
||||
|
||||
|
@ -49,7 +49,7 @@ class ContractDeployer:
|
|||
class ContractNotDeployed(ContractDeploymentError):
|
||||
pass
|
||||
|
||||
def __init__(self, deployer_address: str, blockchain: Blockchain) -> None:
|
||||
def __init__(self, deployer_address: str, blockchain: BlockchainInterface) -> None:
|
||||
|
||||
self.blockchain = blockchain
|
||||
self.deployment_transactions = CONTRACT_NOT_DEPLOYED
|
||||
|
|
|
@ -54,7 +54,7 @@ from nucypher.blockchain.eth.sol.compile import SolidityCompiler
|
|||
Web3Providers = Union[IPCProvider, WebsocketProvider, HTTPProvider, EthereumTester]
|
||||
|
||||
|
||||
class Blockchain:
|
||||
class BlockchainInterface:
|
||||
"""
|
||||
Interacts with a solidity compiler and a registry in order to instantiate compiled
|
||||
ethereum contracts with the given web3 provider backend.
|
||||
|
@ -318,7 +318,7 @@ class Blockchain:
|
|||
) -> dict:
|
||||
|
||||
if self.transacting_power is READ_ONLY_INTERFACE:
|
||||
raise self.InterfaceError
|
||||
raise self.InterfaceError(str(READ_ONLY_INTERFACE))
|
||||
|
||||
#
|
||||
# Build
|
||||
|
@ -373,7 +373,7 @@ class Blockchain:
|
|||
raise NotImplementedError # TODO
|
||||
|
||||
|
||||
class BlockchainDeployer(Blockchain):
|
||||
class BlockchainDeployerInterface(BlockchainInterface):
|
||||
|
||||
_contract_factory = Contract
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@ class ProviderError(Exception):
|
|||
|
||||
def _get_IPC_provider(provider_uri):
|
||||
uri_breakdown = urlparse(provider_uri)
|
||||
from nucypher.blockchain.eth.interfaces import Blockchain
|
||||
return IPCProvider(ipc_path=uri_breakdown.path, timeout=Blockchain.TIMEOUT)
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainInterface
|
||||
return IPCProvider(ipc_path=uri_breakdown.path, timeout=BlockchainInterface.TIMEOUT)
|
||||
|
||||
|
||||
def _get_HTTP_provider(provider_uri):
|
||||
|
@ -67,16 +67,16 @@ def _get_tester_pyevm(provider_uri):
|
|||
|
||||
|
||||
def _get_test_geth_parity_provider(provider_uri):
|
||||
from nucypher.blockchain.eth.interfaces import Blockchain
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainInterface
|
||||
|
||||
# geth --dev
|
||||
geth_process = NuCypherGethDevProcess()
|
||||
geth_process.start()
|
||||
geth_process.wait_for_ipc(timeout=30)
|
||||
provider = IPCProvider(ipc_path=geth_process.ipc_path, timeout=Blockchain.TIMEOUT)
|
||||
provider = IPCProvider(ipc_path=geth_process.ipc_path, timeout=BlockchainInterface.TIMEOUT)
|
||||
|
||||
# TODO: this seems strange to modify a class attr here?
|
||||
Blockchain.process = geth_process
|
||||
BlockchainInterface.process = geth_process
|
||||
return provider
|
||||
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ from umbral.keys import UmbralPublicKey
|
|||
from umbral.signing import Signature
|
||||
|
||||
from nucypher.blockchain.eth.agents import StakingEscrowAgent
|
||||
from nucypher.blockchain.eth.interfaces import Blockchain
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainInterface
|
||||
from nucypher.characters.control.controllers import JSONRPCController
|
||||
from nucypher.config.node import CharacterConfiguration
|
||||
from nucypher.crypto.api import encrypt_and_sign
|
||||
|
@ -74,7 +74,7 @@ class Character(Learner):
|
|||
domains: Set = None,
|
||||
is_me: bool = True,
|
||||
federated_only: bool = False,
|
||||
blockchain: Blockchain = None,
|
||||
blockchain: BlockchainInterface = None,
|
||||
checksum_address: str = NO_BLOCKCHAIN_CONNECTION.bool_value(False),
|
||||
network_middleware: RestMiddleware = None,
|
||||
keyring_root: str = None,
|
||||
|
|
|
@ -22,7 +22,7 @@ from hendrix.experience import hey_joe
|
|||
from nucypher.blockchain.economics import TokenEconomics
|
||||
from nucypher.blockchain.eth.actors import NucypherTokenActor
|
||||
from nucypher.blockchain.eth.agents import NucypherTokenAgent
|
||||
from nucypher.blockchain.eth.interfaces import Blockchain
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainInterface
|
||||
from nucypher.blockchain.eth.token import NU
|
||||
from nucypher.characters.banners import MOE_BANNER, FELIX_BANNER, NU_BANNER
|
||||
from nucypher.characters.base import Character
|
||||
|
@ -183,7 +183,7 @@ class Felix(Character, NucypherTokenActor):
|
|||
|
||||
# Blockchain
|
||||
self.token_agent = NucypherTokenAgent(blockchain=self.blockchain)
|
||||
self.reserved_addresses = [self.checksum_address, Blockchain.NULL_ADDRESS]
|
||||
self.reserved_addresses = [self.checksum_address, BlockchainInterface.NULL_ADDRESS]
|
||||
|
||||
# Update reserved addresses with deployed contracts
|
||||
existing_entries = list(self.blockchain.registry.enrolled_addresses)
|
||||
|
|
|
@ -889,7 +889,7 @@ class Ursula(Teacher, Character, Worker):
|
|||
|
||||
# Access to worker's ETH client via node's transacting keys
|
||||
# TODO: Better handle ephemeral staking self ursula <-- Is this still relevant?
|
||||
blockchain_power = BlockchainPower(blockchain=self.blockchain, account=worker_address)
|
||||
blockchain_power = BlockchainPower(client=self.blockchain.client)
|
||||
self._crypto_power.consume_power_up(blockchain_power)
|
||||
|
||||
# Use blockchain power to substantiate stamp
|
||||
|
|
|
@ -23,7 +23,7 @@ from web3.exceptions import TimeExhausted
|
|||
|
||||
from nucypher.blockchain.eth.actors import Deployer
|
||||
from nucypher.blockchain.eth.agents import NucypherTokenAgent
|
||||
from nucypher.blockchain.eth.interfaces import Blockchain, BlockchainDeployer
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainInterface, BlockchainDeployerInterface
|
||||
from nucypher.blockchain.eth.clients import NuCypherGethDevnetProcess
|
||||
from nucypher.blockchain.eth.registry import EthereumContractRegistry
|
||||
from nucypher.characters.banners import NU_BANNER
|
||||
|
@ -101,13 +101,13 @@ def deploy(click_config,
|
|||
provider_uri = ETH_NODE.provider_uri
|
||||
|
||||
# Deployment-tuned blockchain connection
|
||||
blockchain = BlockchainDeployer(provider_uri=provider_uri,
|
||||
poa=poa,
|
||||
registry=registry,
|
||||
compile=not no_compile,
|
||||
deployer=True,
|
||||
fetch_registry=False,
|
||||
sync=sync)
|
||||
blockchain = BlockchainDeployerInterface(provider_uri=provider_uri,
|
||||
poa=poa,
|
||||
registry=registry,
|
||||
compile=not no_compile,
|
||||
deployer=True,
|
||||
fetch_registry=False,
|
||||
sync=sync)
|
||||
|
||||
|
||||
#
|
||||
|
|
|
@ -40,7 +40,7 @@ from nacl.secret import SecretBox
|
|||
from twisted.logger import Logger
|
||||
from umbral.keys import UmbralPrivateKey, UmbralPublicKey, UmbralKeyingMaterial, derive_key_from_password
|
||||
|
||||
from nucypher.blockchain.eth.interfaces import Blockchain
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainInterface
|
||||
from nucypher.config.constants import DEFAULT_CONFIG_ROOT
|
||||
from nucypher.crypto.api import generate_self_signed_certificate
|
||||
from nucypher.crypto.constants import BLAKE2B
|
||||
|
@ -500,7 +500,7 @@ class NucypherKeyring:
|
|||
new_cryptopower = power_class(keying_material=keying_material)
|
||||
|
||||
elif power_class is BlockchainPower:
|
||||
new_cryptopower = power_class(blockchain=Blockchain.connect(), account=self.checksum_address)
|
||||
new_cryptopower = power_class(blockchain=BlockchainInterface.connect(), account=self.checksum_address)
|
||||
|
||||
else:
|
||||
failure_message = "{} is an invalid type for deriving a CryptoPower.".format(power_class.__name__)
|
||||
|
|
|
@ -32,7 +32,7 @@ from twisted.logger import Logger
|
|||
from umbral.signing import Signature
|
||||
|
||||
from nucypher.blockchain.eth.agents import PolicyAgent, StakingEscrowAgent, NucypherTokenAgent
|
||||
from nucypher.blockchain.eth.interfaces import Blockchain
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainInterface
|
||||
from nucypher.blockchain.eth.registry import EthereumContractRegistry
|
||||
from nucypher.config.base import BaseConfiguration
|
||||
from nucypher.config.keyring import NucypherKeyring
|
||||
|
@ -186,11 +186,11 @@ class CharacterConfiguration(BaseConfiguration):
|
|||
if self.federated_only:
|
||||
raise CharacterConfiguration.ConfigurationError("Cannot connect to blockchain in federated mode")
|
||||
|
||||
self.blockchain = Blockchain(provider_uri=self.provider_uri,
|
||||
poa=self.poa,
|
||||
fetch_registry=True,
|
||||
provider_process=self.provider_process,
|
||||
sync_now=sync_now)
|
||||
self.blockchain = BlockchainInterface(provider_uri=self.provider_uri,
|
||||
poa=self.poa,
|
||||
fetch_registry=True,
|
||||
provider_process=self.provider_process,
|
||||
sync_now=sync_now)
|
||||
|
||||
# Read Ethereum Node Keyring
|
||||
self.accounts = self.blockchain.w3.eth.accounts
|
||||
|
|
|
@ -45,7 +45,7 @@ from twisted.internet import task
|
|||
from twisted.internet.threads import deferToThread
|
||||
from twisted.logger import Logger
|
||||
|
||||
from nucypher.blockchain.eth.interfaces import Blockchain
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainInterface
|
||||
from nucypher.config.constants import SeednodeMetadata
|
||||
from nucypher.config.storages import ForgetfulNodeStorage
|
||||
from nucypher.crypto.api import keccak_digest, verify_eip_191, recover_address_eip_191
|
||||
|
@ -1004,7 +1004,7 @@ class Teacher:
|
|||
the case that the "staker" isn't "staking" (e.g., all her tokens have been slashed).
|
||||
"""
|
||||
staker_address = self.staking_agent.get_staker_from_worker(worker_address=self.worker_address)
|
||||
if staker_address == Blockchain.NULL_ADDRESS:
|
||||
if staker_address == BlockchainInterface.NULL_ADDRESS:
|
||||
raise self.DetachedWorker
|
||||
return staker_address == self.checksum_address
|
||||
|
||||
|
@ -1147,8 +1147,8 @@ class Teacher:
|
|||
|
||||
def substantiate_stamp(self, client_password: str):
|
||||
blockchain_power = self._crypto_power.power_ups(BlockchainPower)
|
||||
blockchain_power.unlock_account(password=client_password) # TODO: #349
|
||||
signature = blockchain_power.sign_message(bytes(self.stamp))
|
||||
blockchain_power.unlock_account(password=client_password, account=self.checksum_address) # TODO: #349
|
||||
signature = blockchain_power.sign_message(messagebytes(self.stamp))
|
||||
self.__decentralized_identity_evidence = signature
|
||||
self.__worker_address = blockchain_power.account
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ from web3 import Web3, IPCProvider, WebsocketProvider, HTTPProvider
|
|||
from nucypher.blockchain.economics import TokenEconomics
|
||||
from nucypher.blockchain.eth.actors import Deployer
|
||||
from nucypher.blockchain.eth.agents import EthereumContractAgent
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainDeployer
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainDeployerInterface
|
||||
from nucypher.blockchain.eth.registry import InMemoryEthereumContractRegistry
|
||||
from nucypher.blockchain.eth.sol.compile import SolidityCompiler
|
||||
from nucypher.blockchain.eth.token import NU
|
||||
|
@ -60,7 +60,7 @@ def token_airdrop(token_agent, amount: NU, origin: str, addresses: List[str]):
|
|||
return receipts
|
||||
|
||||
|
||||
class TesterBlockchain(BlockchainDeployer):
|
||||
class TesterBlockchain(BlockchainDeployerInterface):
|
||||
"""
|
||||
Blockchain subclass with additional test utility methods and options.
|
||||
"""
|
||||
|
|
|
@ -20,7 +20,7 @@ import random
|
|||
from cryptography.x509 import Certificate
|
||||
from typing import Set, List, Iterable
|
||||
|
||||
from nucypher.blockchain.eth.interfaces import Blockchain
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainInterface
|
||||
from nucypher.blockchain.eth.token import StakeTracker
|
||||
from nucypher.characters.lawful import Ursula
|
||||
from nucypher.config.characters import UrsulaConfiguration
|
||||
|
@ -66,7 +66,7 @@ def make_federated_ursulas(ursula_config: UrsulaConfiguration,
|
|||
|
||||
|
||||
def make_decentralized_ursulas(ursula_config: UrsulaConfiguration,
|
||||
blockchain: Blockchain,
|
||||
blockchain: BlockchainInterface,
|
||||
stakers_addresses: Iterable[str],
|
||||
workers_addresses: Iterable[str],
|
||||
confirm_activity: bool = False,
|
||||
|
|
|
@ -2,7 +2,7 @@ import os
|
|||
|
||||
import pytest
|
||||
|
||||
from nucypher.blockchain.eth.interfaces import Blockchain
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainInterface
|
||||
from nucypher.crypto.api import verify_eip_191
|
||||
|
||||
|
||||
|
@ -15,7 +15,7 @@ def test_geth_EIP_191_client_signature_integration(geth_dev_node):
|
|||
pytest.skip("Do not run Geth nodes in CI")
|
||||
|
||||
# Start a geth process
|
||||
blockchain = Blockchain(provider_process=geth_dev_node, sync_now=False)
|
||||
blockchain = BlockchainInterface(provider_process=geth_dev_node, sync_now=False)
|
||||
|
||||
# Sign a message (RPC) and verify it.
|
||||
etherbase = blockchain.accounts[0]
|
||||
|
|
|
@ -4,7 +4,7 @@ from nucypher.blockchain.eth.clients import (
|
|||
GanacheClient,
|
||||
PUBLIC_CHAINS
|
||||
)
|
||||
from nucypher.blockchain.eth.interfaces import Blockchain
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainInterface
|
||||
|
||||
|
||||
#
|
||||
|
@ -49,7 +49,7 @@ class MockWeb3:
|
|||
# Mock Blockchain
|
||||
#
|
||||
|
||||
class BlockchainTestBase(Blockchain):
|
||||
class BlockchainInterfaceTestBase(BlockchainInterface):
|
||||
|
||||
Web3 = MockWeb3
|
||||
|
||||
|
@ -63,7 +63,7 @@ class BlockchainTestBase(Blockchain):
|
|||
pass
|
||||
|
||||
|
||||
class GethClientTestBlockchain(BlockchainTestBase):
|
||||
class GethClientTestBlockchain(BlockchainInterfaceTestBase):
|
||||
|
||||
def _attach_provider(self, *args, **kwargs) -> None:
|
||||
super()._attach_provider(provider=MockGethProvider())
|
||||
|
@ -73,13 +73,13 @@ class GethClientTestBlockchain(BlockchainTestBase):
|
|||
return int(self.w3.net.version) not in PUBLIC_CHAINS
|
||||
|
||||
|
||||
class ParityClientTestInterface(BlockchainTestBase):
|
||||
class ParityClientTestInterface(BlockchainInterfaceTestBase):
|
||||
|
||||
def _attach_provider(self, *args, **kwargs) -> None:
|
||||
super()._attach_provider(provider=MockParityProvider())
|
||||
|
||||
|
||||
class GanacheClientTestInterface(BlockchainTestBase):
|
||||
class GanacheClientTestInterface(BlockchainInterfaceTestBase):
|
||||
|
||||
def _attach_provider(self, *args, **kwargs) -> None:
|
||||
super()._attach_provider(provider=MockGanacheProvider())
|
||||
|
|
|
@ -20,7 +20,7 @@ import pytest
|
|||
|
||||
from eth_tester.exceptions import TransactionFailed
|
||||
|
||||
from nucypher.blockchain.eth.interfaces import Blockchain
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainInterface
|
||||
from nucypher.utilities.sandbox.constants import MOCK_IP_ADDRESS, MOCK_IP_ADDRESS_2, MAX_TEST_SEEDER_ENTRIES, \
|
||||
MOCK_URSULA_STARTING_PORT
|
||||
|
||||
|
@ -47,13 +47,13 @@ def test_seeder(testerchain):
|
|||
testerchain.wait_for_receipt(txhash)
|
||||
assert contract.functions.seeds(seed_address).call() == [*seed]
|
||||
assert contract.functions.seedArray(0).call() == seed_address
|
||||
assert contract.functions.seedArray(1).call() == Blockchain.NULL_ADDRESS
|
||||
assert contract.functions.seedArray(1).call() == BlockchainInterface.NULL_ADDRESS
|
||||
txhash = contract.functions.enroll(another_seed_address, *another_seed).transact({'from': origin})
|
||||
testerchain.wait_for_receipt(txhash)
|
||||
assert contract.functions.seeds(another_seed_address).call() == [*another_seed]
|
||||
assert contract.functions.seedArray(0).call() == seed_address
|
||||
assert contract.functions.seedArray(1).call() == another_seed_address
|
||||
assert contract.functions.seedArray(2).call() == Blockchain.NULL_ADDRESS
|
||||
assert contract.functions.seedArray(2).call() == BlockchainInterface.NULL_ADDRESS
|
||||
|
||||
txhash = contract.functions.refresh(*another_seed).transact({'from': seed_address})
|
||||
testerchain.wait_for_receipt(txhash)
|
||||
|
|
|
@ -21,7 +21,7 @@ from eth_tester.exceptions import TransactionFailed
|
|||
from web3.contract import Contract
|
||||
from web3.exceptions import BadFunctionCallOutput
|
||||
|
||||
from nucypher.blockchain.eth.interfaces import Blockchain
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainInterface
|
||||
|
||||
SECRET_LENGTH = 16
|
||||
|
||||
|
@ -62,7 +62,7 @@ def test_dispatcher(testerchain):
|
|||
events = upgrades.get_all_entries()
|
||||
assert 1 == len(events)
|
||||
event_args = events[0]['args']
|
||||
assert Blockchain.NULL_ADDRESS == event_args['from']
|
||||
assert BlockchainInterface.NULL_ADDRESS == event_args['from']
|
||||
assert contract1_lib.address == event_args['to']
|
||||
assert creator == event_args['owner']
|
||||
|
||||
|
@ -492,7 +492,7 @@ def test_selfdestruct(testerchain):
|
|||
|
||||
# Can't create dispatcher using address without contract
|
||||
with pytest.raises((TransactionFailed, ValueError)):
|
||||
testerchain.deploy_contract('Dispatcher', Blockchain.NULL_ADDRESS, secret_hash)
|
||||
testerchain.deploy_contract('Dispatcher', BlockchainInterface.NULL_ADDRESS, secret_hash)
|
||||
with pytest.raises((TransactionFailed, ValueError)):
|
||||
testerchain.deploy_contract('Dispatcher', account, secret_hash)
|
||||
with pytest.raises((TransactionFailed, ValueError)):
|
||||
|
@ -514,7 +514,7 @@ def test_selfdestruct(testerchain):
|
|||
|
||||
# Can't upgrade to an address without contract
|
||||
with pytest.raises((TransactionFailed, ValueError)):
|
||||
tx = dispatcher.functions.upgrade(Blockchain.NULL_ADDRESS, secret, secret2_hash).transact({'from': creator})
|
||||
tx = dispatcher.functions.upgrade(BlockchainInterface.NULL_ADDRESS, secret, secret2_hash).transact({'from': creator})
|
||||
testerchain.wait_for_receipt(tx)
|
||||
with pytest.raises((TransactionFailed, ValueError)):
|
||||
tx = dispatcher.functions.upgrade(account, secret, secret2_hash).transact({'from': creator})
|
||||
|
@ -532,7 +532,7 @@ def test_selfdestruct(testerchain):
|
|||
|
||||
# Can't upgrade to an address without contract
|
||||
with pytest.raises((TransactionFailed, ValueError)):
|
||||
tx = dispatcher.functions.upgrade(Blockchain.NULL_ADDRESS, secret, secret2_hash).transact({'from': creator})
|
||||
tx = dispatcher.functions.upgrade(BlockchainInterface.NULL_ADDRESS, secret, secret2_hash).transact({'from': creator})
|
||||
testerchain.wait_for_receipt(tx)
|
||||
with pytest.raises((TransactionFailed, ValueError)):
|
||||
tx = dispatcher.functions.upgrade(account, secret, secret2_hash).transact({'from': creator})
|
||||
|
|
|
@ -20,7 +20,7 @@ import pytest
|
|||
from eth_tester.exceptions import TransactionFailed
|
||||
from eth_utils import to_canonical_address
|
||||
|
||||
from nucypher.blockchain.eth.interfaces import Blockchain
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainInterface
|
||||
|
||||
|
||||
def sign_hash(testerchain, account: str, data_hash: bytes) -> dict:
|
||||
|
@ -45,7 +45,7 @@ def test_execute(testerchain):
|
|||
|
||||
# Can't create the contract with the address 0x0 (address 0x0 is restricted for use)
|
||||
with pytest.raises((TransactionFailed, ValueError)):
|
||||
testerchain.deploy_contract('MultiSig', 3, owners + [Blockchain.NULL_ADDRESS])
|
||||
testerchain.deploy_contract('MultiSig', 3, owners + [BlockchainInterface.NULL_ADDRESS])
|
||||
# Owners must be no less than the threshold value
|
||||
with pytest.raises((TransactionFailed, ValueError)):
|
||||
testerchain.deploy_contract('MultiSig', 6, owners)
|
||||
|
@ -333,7 +333,7 @@ def test_owners_management(testerchain):
|
|||
multisig.functions.addOwner(owners[0]).buildTransaction({'from': multisig.address, 'gasPrice': 0})
|
||||
# Can't add the address 0x0 as an owner
|
||||
with pytest.raises((TransactionFailed, ValueError)):
|
||||
multisig.functions.addOwner(Blockchain.NULL_ADDRESS).buildTransaction({'from': multisig.address, 'gasPrice': 0})
|
||||
multisig.functions.addOwner(BlockchainInterface.NULL_ADDRESS).buildTransaction({'from': multisig.address, 'gasPrice': 0})
|
||||
|
||||
# Can't remove nonexistent owner
|
||||
with pytest.raises((TransactionFailed, ValueError)):
|
||||
|
|
|
@ -26,7 +26,7 @@ from eth_utils import to_canonical_address
|
|||
from typing import Tuple
|
||||
from web3.contract import Contract
|
||||
|
||||
from nucypher.blockchain.eth.interfaces import Blockchain
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainInterface
|
||||
from umbral.keys import UmbralPrivateKey
|
||||
from umbral.point import Point
|
||||
|
||||
|
@ -72,7 +72,7 @@ def test_evaluate_cfrag(testerchain,
|
|||
return penalty_, reward_
|
||||
|
||||
# Prepare one staker
|
||||
tx = escrow.functions.setStakerInfo(staker, worker_stake, Blockchain.NULL_ADDRESS).transact()
|
||||
tx = escrow.functions.setStakerInfo(staker, worker_stake, BlockchainInterface.NULL_ADDRESS).transact()
|
||||
testerchain.wait_for_receipt(tx)
|
||||
staker_umbral_public_key_bytes = get_coordinates_as_bytes(ursula.stamp)
|
||||
|
||||
|
@ -359,7 +359,7 @@ def test_evaluate_cfrag(testerchain,
|
|||
testerchain.wait_for_receipt(tx)
|
||||
|
||||
# Can't evaluate staker without tokens
|
||||
tx = escrow.functions.setStakerInfo(wrong_staker, 0, Blockchain.NULL_ADDRESS).transact()
|
||||
tx = escrow.functions.setStakerInfo(wrong_staker, 0, BlockchainInterface.NULL_ADDRESS).transact()
|
||||
testerchain.wait_for_receipt(tx)
|
||||
with pytest.raises((TransactionFailed, ValueError)):
|
||||
tx = adjudicator_contract.functions.evaluateCFrag(*wrong_args).transact()
|
||||
|
|
|
@ -22,7 +22,7 @@ import pytest
|
|||
from eth_tester.exceptions import TransactionFailed
|
||||
from web3.contract import Contract
|
||||
|
||||
from nucypher.blockchain.eth.interfaces import Blockchain
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainInterface
|
||||
|
||||
CLIENT_FIELD = 0
|
||||
RATE_FIELD = 1
|
||||
|
@ -171,7 +171,7 @@ def test_create_revoke(testerchain, escrow, policy_manager):
|
|||
testerchain.wait_for_receipt(tx)
|
||||
# Can't revoke null arrangement (also it's nonexistent)
|
||||
with pytest.raises((TransactionFailed, ValueError)):
|
||||
tx = policy_manager.functions.revokeArrangement(policy_id_2, Blockchain.NULL_ADDRESS).transact({'from': client})
|
||||
tx = policy_manager.functions.revokeArrangement(policy_id_2, BlockchainInterface.NULL_ADDRESS).transact({'from': client})
|
||||
testerchain.wait_for_receipt(tx)
|
||||
|
||||
# Revoke only one arrangement
|
||||
|
@ -195,7 +195,7 @@ def test_create_revoke(testerchain, escrow, policy_manager):
|
|||
testerchain.wait_for_receipt(tx)
|
||||
# Can't revoke null arrangement (it's nonexistent)
|
||||
with pytest.raises((TransactionFailed, ValueError)):
|
||||
tx = policy_manager.functions.revokeArrangement(policy_id_2, Blockchain.NULL_ADDRESS).transact({'from': client})
|
||||
tx = policy_manager.functions.revokeArrangement(policy_id_2, BlockchainInterface.NULL_ADDRESS).transact({'from': client})
|
||||
testerchain.wait_for_receipt(tx)
|
||||
|
||||
# Revoke policy with remaining arrangements
|
||||
|
|
|
@ -21,7 +21,7 @@ import os
|
|||
import pytest
|
||||
from eth_tester.exceptions import TransactionFailed
|
||||
|
||||
from nucypher.blockchain.eth.interfaces import Blockchain
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainInterface
|
||||
|
||||
CLIENT_FIELD = 0
|
||||
RATE_FIELD = 1
|
||||
|
@ -245,14 +245,14 @@ def test_refund(testerchain, escrow, policy_manager):
|
|||
tx = policy_manager.functions.refund(policy_id, node1).transact({'from': client})
|
||||
testerchain.wait_for_receipt(tx)
|
||||
with pytest.raises((TransactionFailed, ValueError)):
|
||||
tx = policy_manager.functions.refund(policy_id, Blockchain.NULL_ADDRESS).transact({'from': client})
|
||||
tx = policy_manager.functions.refund(policy_id, BlockchainInterface.NULL_ADDRESS).transact({'from': client})
|
||||
testerchain.wait_for_receipt(tx)
|
||||
with pytest.raises((TransactionFailed, ValueError)):
|
||||
policy_manager.functions.calculateRefundValue(policy_id).call({'from': client})
|
||||
with pytest.raises((TransactionFailed, ValueError)):
|
||||
policy_manager.functions.calculateRefundValue(policy_id, node1).call({'from': client})
|
||||
with pytest.raises((TransactionFailed, ValueError)):
|
||||
policy_manager.functions.calculateRefundValue(policy_id, Blockchain.NULL_ADDRESS).call({'from': client})
|
||||
policy_manager.functions.calculateRefundValue(policy_id, BlockchainInterface.NULL_ADDRESS).call({'from': client})
|
||||
|
||||
# Create new policy
|
||||
testerchain.time_travel(hours=1)
|
||||
|
@ -366,12 +366,12 @@ def test_refund(testerchain, escrow, policy_manager):
|
|||
tx = policy_manager.functions.refund(policy_id_2, node1).transact({'from': client})
|
||||
testerchain.wait_for_receipt(tx)
|
||||
with pytest.raises((TransactionFailed, ValueError)):
|
||||
tx = policy_manager.functions.refund(policy_id_2, Blockchain.NULL_ADDRESS).transact({'from': client})
|
||||
tx = policy_manager.functions.refund(policy_id_2, BlockchainInterface.NULL_ADDRESS).transact({'from': client})
|
||||
testerchain.wait_for_receipt(tx)
|
||||
with pytest.raises((TransactionFailed, ValueError)):
|
||||
policy_manager.functions.calculateRefundValue(policy_id_2, node1).call({'from': client})
|
||||
with pytest.raises((TransactionFailed, ValueError)):
|
||||
policy_manager.functions.calculateRefundValue(policy_id_2, Blockchain.NULL_ADDRESS).call({'from': client})
|
||||
policy_manager.functions.calculateRefundValue(policy_id_2, BlockchainInterface.NULL_ADDRESS).call({'from': client})
|
||||
|
||||
# But can refund others arrangements
|
||||
assert 240 == policy_manager.functions.calculateRefundValue(policy_id_2).call({'from': client})
|
||||
|
|
|
@ -20,7 +20,7 @@ import pytest
|
|||
from eth_tester.exceptions import TransactionFailed
|
||||
from web3.contract import Contract
|
||||
|
||||
from nucypher.blockchain.eth.interfaces import Blockchain
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainInterface
|
||||
|
||||
RE_STAKE_FIELD = 3
|
||||
LOCK_RE_STAKE_UNTIL_PERIOD_FIELD = 4
|
||||
|
@ -468,16 +468,16 @@ def test_worker(testerchain, token, escrow_contract):
|
|||
tx = intermediary1.functions.deposit(sub_stake, duration).transact({'from': ursula1})
|
||||
testerchain.wait_for_receipt(tx)
|
||||
assert sub_stake == escrow.functions.getAllTokens(intermediary1.address).call()
|
||||
assert Blockchain.NULL_ADDRESS == escrow.functions.getWorkerFromStaker(intermediary1.address).call()
|
||||
assert Blockchain.NULL_ADDRESS == escrow.functions.getStakerFromWorker(intermediary1.address).call()
|
||||
assert BlockchainInterface.NULL_ADDRESS == escrow.functions.getWorkerFromStaker(intermediary1.address).call()
|
||||
assert BlockchainInterface.NULL_ADDRESS == escrow.functions.getStakerFromWorker(intermediary1.address).call()
|
||||
|
||||
tx = token.functions.transfer(intermediary2.address, sub_stake).transact()
|
||||
testerchain.wait_for_receipt(tx)
|
||||
tx = intermediary2.functions.deposit(sub_stake, duration).transact({'from': ursula2})
|
||||
testerchain.wait_for_receipt(tx)
|
||||
assert sub_stake == escrow.functions.getAllTokens(intermediary2.address).call()
|
||||
assert Blockchain.NULL_ADDRESS == escrow.functions.getWorkerFromStaker(intermediary2.address).call()
|
||||
assert Blockchain.NULL_ADDRESS == escrow.functions.getStakerFromWorker(intermediary2.address).call()
|
||||
assert BlockchainInterface.NULL_ADDRESS == escrow.functions.getWorkerFromStaker(intermediary2.address).call()
|
||||
assert BlockchainInterface.NULL_ADDRESS == escrow.functions.getStakerFromWorker(intermediary2.address).call()
|
||||
|
||||
tx = token.functions.transfer(ursula3, sub_stake).transact()
|
||||
testerchain.wait_for_receipt(tx)
|
||||
|
@ -485,8 +485,8 @@ def test_worker(testerchain, token, escrow_contract):
|
|||
.transact({'from': ursula3})
|
||||
testerchain.wait_for_receipt(tx)
|
||||
assert sub_stake == escrow.functions.getAllTokens(ursula3).call()
|
||||
assert Blockchain.NULL_ADDRESS == escrow.functions.getWorkerFromStaker(ursula3).call()
|
||||
assert Blockchain.NULL_ADDRESS == escrow.functions.getStakerFromWorker(ursula3).call()
|
||||
assert BlockchainInterface.NULL_ADDRESS == escrow.functions.getWorkerFromStaker(ursula3).call()
|
||||
assert BlockchainInterface.NULL_ADDRESS == escrow.functions.getStakerFromWorker(ursula3).call()
|
||||
|
||||
# Ursula can't confirm activity because there is no worker by default
|
||||
with pytest.raises((TransactionFailed, ValueError)):
|
||||
|
@ -543,14 +543,14 @@ def test_worker(testerchain, token, escrow_contract):
|
|||
|
||||
# She can't unset her worker too, until enough time has passed
|
||||
with pytest.raises((TransactionFailed, ValueError)):
|
||||
tx = intermediary1.functions.setWorker(Blockchain.NULL_ADDRESS).transact({'from': ursula1})
|
||||
tx = intermediary1.functions.setWorker(BlockchainInterface.NULL_ADDRESS).transact({'from': ursula1})
|
||||
testerchain.wait_for_receipt(tx)
|
||||
|
||||
# Let's advance one period and unset the worker
|
||||
testerchain.time_travel(hours=1)
|
||||
tx = intermediary1.functions.setWorker(Blockchain.NULL_ADDRESS).transact({'from': ursula1})
|
||||
tx = intermediary1.functions.setWorker(BlockchainInterface.NULL_ADDRESS).transact({'from': ursula1})
|
||||
testerchain.wait_for_receipt(tx)
|
||||
assert Blockchain.NULL_ADDRESS == escrow.functions.getWorkerFromStaker(intermediary1.address).call()
|
||||
assert BlockchainInterface.NULL_ADDRESS == escrow.functions.getWorkerFromStaker(intermediary1.address).call()
|
||||
|
||||
number_of_events += 1
|
||||
events = worker_log.get_all_entries()
|
||||
|
@ -558,7 +558,7 @@ def test_worker(testerchain, token, escrow_contract):
|
|||
event_args = events[-1]['args']
|
||||
assert intermediary1.address == event_args['staker']
|
||||
# Now the worker has been unset ...
|
||||
assert Blockchain.NULL_ADDRESS == event_args['worker']
|
||||
assert BlockchainInterface.NULL_ADDRESS == event_args['worker']
|
||||
# ... with a new starting period.
|
||||
assert escrow.functions.getCurrentPeriod().call() == event_args['startPeriod']
|
||||
|
||||
|
@ -567,7 +567,7 @@ def test_worker(testerchain, token, escrow_contract):
|
|||
testerchain.wait_for_receipt(tx)
|
||||
assert worker2 == escrow.functions.getWorkerFromStaker(intermediary1.address).call()
|
||||
assert intermediary1.address == escrow.functions.getStakerFromWorker(worker2).call()
|
||||
assert Blockchain.NULL_ADDRESS == escrow.functions.getStakerFromWorker(worker1).call()
|
||||
assert BlockchainInterface.NULL_ADDRESS == escrow.functions.getStakerFromWorker(worker1).call()
|
||||
|
||||
number_of_events += 1
|
||||
events = worker_log.get_all_entries()
|
||||
|
@ -611,7 +611,7 @@ def test_worker(testerchain, token, escrow_contract):
|
|||
testerchain.wait_for_receipt(tx)
|
||||
assert ursula2 == escrow.functions.getWorkerFromStaker(intermediary2.address).call()
|
||||
assert intermediary2.address == escrow.functions.getStakerFromWorker(ursula2).call()
|
||||
assert Blockchain.NULL_ADDRESS == escrow.functions.getStakerFromWorker(worker1).call()
|
||||
assert BlockchainInterface.NULL_ADDRESS == escrow.functions.getStakerFromWorker(worker1).call()
|
||||
|
||||
number_of_events += 1
|
||||
events = worker_log.get_all_entries()
|
||||
|
@ -628,8 +628,8 @@ def test_worker(testerchain, token, escrow_contract):
|
|||
.transact({'from': worker1})
|
||||
testerchain.wait_for_receipt(tx)
|
||||
assert 2 * sub_stake == escrow.functions.getAllTokens(worker1).call()
|
||||
assert Blockchain.NULL_ADDRESS == escrow.functions.getStakerFromWorker(worker1).call()
|
||||
assert Blockchain.NULL_ADDRESS == escrow.functions.getWorkerFromStaker(worker1).call()
|
||||
assert BlockchainInterface.NULL_ADDRESS == escrow.functions.getStakerFromWorker(worker1).call()
|
||||
assert BlockchainInterface.NULL_ADDRESS == escrow.functions.getWorkerFromStaker(worker1).call()
|
||||
|
||||
# Ursula can't use the first worker again because worker is a staker now
|
||||
testerchain.time_travel(hours=1)
|
||||
|
|
|
@ -23,7 +23,7 @@ from eth_tester.exceptions import TransactionFailed
|
|||
from web3.contract import Contract
|
||||
from web3.exceptions import BadFunctionCallOutput
|
||||
|
||||
from nucypher.blockchain.eth.interfaces import Blockchain
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainInterface
|
||||
|
||||
|
||||
@pytest.mark.slow
|
||||
|
@ -187,7 +187,7 @@ def test_proxy_selfdestruct(testerchain, token):
|
|||
|
||||
# Can't create linker using address without contract
|
||||
with pytest.raises((TransactionFailed, ValueError)):
|
||||
testerchain.deploy_contract('UserEscrowLibraryLinker', Blockchain.NULL_ADDRESS, secret_hash)
|
||||
testerchain.deploy_contract('UserEscrowLibraryLinker', BlockchainInterface.NULL_ADDRESS, secret_hash)
|
||||
with pytest.raises((TransactionFailed, ValueError)):
|
||||
testerchain.deploy_contract('UserEscrowLibraryLinker', account, secret_hash)
|
||||
with pytest.raises((TransactionFailed, ValueError)):
|
||||
|
@ -216,7 +216,7 @@ def test_proxy_selfdestruct(testerchain, token):
|
|||
|
||||
# Can't upgrade to an address without contract
|
||||
with pytest.raises((TransactionFailed, ValueError)):
|
||||
tx = linker_contract.functions.upgrade(Blockchain.NULL_ADDRESS, secret, secret2_hash).transact({'from': creator})
|
||||
tx = linker_contract.functions.upgrade(BlockchainInterface.NULL_ADDRESS, secret, secret2_hash).transact({'from': creator})
|
||||
testerchain.wait_for_receipt(tx)
|
||||
with pytest.raises((TransactionFailed, ValueError)):
|
||||
tx = linker_contract.functions.upgrade(account, secret, secret2_hash).transact({'from': creator})
|
||||
|
@ -234,7 +234,7 @@ def test_proxy_selfdestruct(testerchain, token):
|
|||
|
||||
# Can't upgrade to an address without contract
|
||||
with pytest.raises((TransactionFailed, ValueError)):
|
||||
tx = linker_contract.functions.upgrade(Blockchain.NULL_ADDRESS, secret, secret2_hash).transact({'from': creator})
|
||||
tx = linker_contract.functions.upgrade(BlockchainInterface.NULL_ADDRESS, secret, secret2_hash).transact({'from': creator})
|
||||
testerchain.wait_for_receipt(tx)
|
||||
with pytest.raises((TransactionFailed, ValueError)):
|
||||
tx = linker_contract.functions.upgrade(account, secret, secret2_hash).transact({'from': creator})
|
||||
|
|
|
@ -22,7 +22,7 @@ import pytest
|
|||
from web3.auto import w3
|
||||
|
||||
from nucypher.blockchain.eth.actors import Deployer
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainDeployer
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainDeployerInterface
|
||||
from nucypher.blockchain.eth.registry import InMemoryEthereumContractRegistry, InMemoryAllocationRegistry
|
||||
from nucypher.blockchain.eth.sol.compile import SolidityCompiler
|
||||
# Prevents TesterBlockchain to be picked up by py.test as a test class
|
||||
|
|
|
@ -21,7 +21,7 @@ import pytest
|
|||
from eth_utils.address import to_checksum_address, is_address
|
||||
|
||||
from nucypher.blockchain.eth.agents import StakingEscrowAgent
|
||||
from nucypher.blockchain.eth.interfaces import Blockchain
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainInterface
|
||||
|
||||
|
||||
@pytest.mark.slow()
|
||||
|
@ -92,7 +92,7 @@ def test_stakers_and_workers_relationships(testerchain, agency):
|
|||
staker_account, worker_account, *other = testerchain.unassigned_accounts
|
||||
|
||||
# The staker hasn't set a worker yet
|
||||
assert Blockchain.NULL_ADDRESS == staking_agent.get_worker_from_staker(staker_address=staker_account)
|
||||
assert BlockchainInterface.NULL_ADDRESS == staking_agent.get_worker_from_staker(staker_address=staker_account)
|
||||
|
||||
_txhash = staking_agent.set_worker(staker_address=staker_account,
|
||||
worker_address=worker_account)
|
||||
|
@ -103,8 +103,8 @@ def test_stakers_and_workers_relationships(testerchain, agency):
|
|||
|
||||
# No staker-worker relationship
|
||||
random_address = to_checksum_address(os.urandom(20))
|
||||
assert Blockchain.NULL_ADDRESS == staking_agent.get_worker_from_staker(staker_address=random_address)
|
||||
assert Blockchain.NULL_ADDRESS == staking_agent.get_staker_from_worker(worker_address=random_address)
|
||||
assert BlockchainInterface.NULL_ADDRESS == staking_agent.get_worker_from_staker(staker_address=random_address)
|
||||
assert BlockchainInterface.NULL_ADDRESS == staking_agent.get_staker_from_worker(worker_address=random_address)
|
||||
|
||||
|
||||
@pytest.mark.slow()
|
||||
|
|
|
@ -22,7 +22,7 @@ from eth_utils import is_checksum_address, to_wei
|
|||
|
||||
from eth_tester.exceptions import TransactionFailed
|
||||
from nucypher.blockchain.eth.agents import UserEscrowAgent
|
||||
from nucypher.blockchain.eth.interfaces import Blockchain
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainInterface
|
||||
from nucypher.blockchain.eth.deployers import UserEscrowDeployer, UserEscrowProxyDeployer, DispatcherDeployer
|
||||
from nucypher.blockchain.eth.registry import InMemoryAllocationRegistry
|
||||
|
||||
|
@ -164,7 +164,7 @@ def test_deposit_and_withdraw_as_staker(testerchain, agent, agency, allocation_v
|
|||
assert token_agent.get_balance(address=agent.contract_address) == allocation_value
|
||||
|
||||
# Release worker
|
||||
_txhash = agent.set_worker(worker_address=Blockchain.NULL_ADDRESS)
|
||||
_txhash = agent.set_worker(worker_address=BlockchainInterface.NULL_ADDRESS)
|
||||
|
||||
txhash = agent.withdraw_as_staker(value=staking_agent.owned_tokens(address=agent.contract_address))
|
||||
assert txhash
|
||||
|
|
|
@ -18,7 +18,7 @@ along with nucypher. If not, see <https://www.gnu.org/licenses/>.
|
|||
|
||||
import pytest
|
||||
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainDeployer
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainDeployerInterface
|
||||
from nucypher.blockchain.eth.registry import InMemoryEthereumContractRegistry
|
||||
# Prevents TesterBlockchain to be picked up by py.test as a test class
|
||||
from nucypher.utilities.sandbox.blockchain import TesterBlockchain as _TesterBlockchain
|
||||
|
@ -34,9 +34,9 @@ from nucypher.utilities.sandbox.constants import (
|
|||
@pytest.fixture()
|
||||
def another_testerchain(solidity_compiler):
|
||||
memory_registry = InMemoryEthereumContractRegistry()
|
||||
deployer_interface = BlockchainDeployer(compiler=solidity_compiler,
|
||||
registry=memory_registry,
|
||||
provider_uri=TEST_PROVIDER_URI)
|
||||
deployer_interface = BlockchainDeployerInterface(compiler=solidity_compiler,
|
||||
registry=memory_registry,
|
||||
provider_uri=TEST_PROVIDER_URI)
|
||||
testerchain = _TesterBlockchain(interface=deployer_interface,
|
||||
test_accounts=2*NUMBER_OF_ETH_TEST_ACCOUNTS,
|
||||
eth_airdrop=True)
|
||||
|
|
|
@ -13,8 +13,8 @@ from nucypher.blockchain.eth.agents import (
|
|||
PolicyAgent,
|
||||
AdjudicatorAgent,
|
||||
Agency)
|
||||
from nucypher.blockchain.eth.interfaces import Blockchain
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainDeployer, Blockchain
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainInterface
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainDeployerInterface, BlockchainInterface
|
||||
from nucypher.blockchain.eth.registry import AllocationRegistry, EthereumContractRegistry
|
||||
from nucypher.blockchain.eth.sol.compile import SolidityCompiler
|
||||
from nucypher.cli.deploy import deploy
|
||||
|
@ -42,13 +42,13 @@ INSECURE_SECRETS = {v: generate_insecure_secret() for v in range(1, PLANNED_UPGR
|
|||
def make_testerchain(provider_uri, solidity_compiler):
|
||||
|
||||
# Destroy existing blockchain
|
||||
Blockchain.disconnect()
|
||||
BlockchainInterface.disconnect()
|
||||
_TesterBlockchain.sever_connection()
|
||||
|
||||
registry = EthereumContractRegistry(registry_filepath=MOCK_REGISTRY_FILEPATH)
|
||||
deployer_interface = BlockchainDeployer(compiler=solidity_compiler,
|
||||
registry=registry,
|
||||
provider_uri=provider_uri)
|
||||
deployer_interface = BlockchainDeployerInterface(compiler=solidity_compiler,
|
||||
registry=registry,
|
||||
provider_uri=provider_uri)
|
||||
|
||||
# Create new blockchain
|
||||
testerchain = _TesterBlockchain(interface=deployer_interface,
|
||||
|
@ -143,7 +143,7 @@ def test_upgrade_contracts(click_runner):
|
|||
|
||||
# Connect to the blockchain with a blank temporary file-based registry
|
||||
mock_temporary_registry = EthereumContractRegistry(registry_filepath=MOCK_REGISTRY_FILEPATH)
|
||||
blockchain = Blockchain.connect(registry=mock_temporary_registry)
|
||||
blockchain = BlockchainInterface.connect(registry=mock_temporary_registry)
|
||||
|
||||
# Check the existing state of the registry before the meat and potatoes
|
||||
expected_registrations = 9
|
||||
|
@ -266,7 +266,7 @@ def test_rollback(click_runner):
|
|||
"""Roll 'em all back!"""
|
||||
|
||||
mock_temporary_registry = EthereumContractRegistry(registry_filepath=MOCK_REGISTRY_FILEPATH)
|
||||
blockchain = Blockchain.connect(registry=mock_temporary_registry)
|
||||
blockchain = BlockchainInterface.connect(registry=mock_temporary_registry)
|
||||
|
||||
# Input Components
|
||||
yes = 'Y\n'
|
||||
|
@ -303,7 +303,7 @@ def test_rollback(click_runner):
|
|||
assert current_target_address != rollback_target_address
|
||||
|
||||
# Ensure the proxy targets the rollback target (previous version)
|
||||
with pytest.raises(Blockchain.UnknownContract):
|
||||
with pytest.raises(BlockchainInterface.UnknownContract):
|
||||
blockchain.get_proxy(target_address=current_target_address, proxy_name='Dispatcher')
|
||||
|
||||
proxy = blockchain.get_proxy(target_address=rollback_target_address, proxy_name='Dispatcher')
|
||||
|
@ -376,7 +376,7 @@ def test_nucypher_deploy_allocation_contracts(click_runner,
|
|||
#
|
||||
|
||||
# Destroy existing blockchain
|
||||
Blockchain.disconnect()
|
||||
BlockchainInterface.disconnect()
|
||||
|
||||
|
||||
def test_destroy_registry(click_runner, mock_primary_registry_filepath):
|
||||
|
|
|
@ -39,7 +39,7 @@ from nucypher.blockchain.eth.deployers import (NucypherTokenDeployer,
|
|||
PolicyManagerDeployer,
|
||||
DispatcherDeployer,
|
||||
AdjudicatorDeployer)
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainDeployer
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainDeployerInterface
|
||||
from nucypher.blockchain.eth.registry import InMemoryEthereumContractRegistry
|
||||
from nucypher.blockchain.eth.sol.compile import SolidityCompiler
|
||||
from nucypher.blockchain.eth.token import NU
|
||||
|
|
Loading…
Reference in New Issue