Removes client_password from character init where possible, require signer to init a TransactingPower, removing default web3 signer.

pull/2560/head
Kieran Prasch 2021-02-12 23:40:45 -08:00
parent c1eed47459
commit 4c0f679c7e
33 changed files with 198 additions and 109 deletions

View File

@ -213,9 +213,8 @@ class ContractAdministrator(NucypherTokenActor):
def __init__(self,
registry: BaseContractRegistry,
deployer_address: str = None,
client_password: str = None,
signer: Signer = None,
is_transacting: bool = True, # FIXME: Workaround to be able to build MultiSig TXs
is_transacting: bool = True,
economics: BaseEconomics = None):
"""
Note: super() is not called here to avoid setting the token agent. TODO: call super but use "bare mode" without token agent. #1510
@ -232,10 +231,10 @@ class ContractAdministrator(NucypherTokenActor):
# Powers
if is_transacting:
self.deployer_power = TransactingPower(signer=signer,
password=client_password,
account=deployer_address,
cache=True)
if not signer:
raise ValueError('signer is required to make a transacting ContractAdministrator.')
self.deployer_power = TransactingPower(signer=signer, account=deployer_address)
self.transacting_power = self.deployer_power
self.transacting_power.activate()
else:
@ -253,7 +252,7 @@ class ContractAdministrator(NucypherTokenActor):
def recruit_sidekick(self, sidekick_address: str, sidekick_password: str):
self.sidekick_power = TransactingPower(account=sidekick_address, password=sidekick_password, cache=True)
if self.sidekick_power.is_device:
raise ValueError("Holy Wallet! Sidekicks can only be SW accounts")
raise ValueError("Holy Wallet! Sidekicks can only be SW accounts.")
self.sidekick_address = sidekick_address
def activate_deployer(self, refresh: bool = True):
@ -404,15 +403,16 @@ class Trustee(MultiSigActor):
def __init__(self,
checksum_address: str,
client_password: str = None,
is_transacting: bool,
signer: Optional[Signer] = None,
*args, **kwargs):
super().__init__(checksum_address=checksum_address, *args, **kwargs)
self.authorizations = dict()
self.executive_addresses = tuple(
self.multisig_agent.owners) # TODO: Investigate unresolved reference to .owners (linter)
if client_password: # TODO: Consider an is_transacting parameter
self.transacting_power = TransactingPower(password=client_password,
account=checksum_address)
self.executive_addresses = tuple(self.multisig_agent.owners)
if is_transacting:
if not signer:
raise ValueError('signer is required to create a transacting Trustee.')
self.transacting_power = TransactingPower(account=checksum_address, signer=signer)
self.transacting_power.activate()
def add_authorization(self, authorization, proposal: Proposal) -> str:
@ -495,7 +495,6 @@ class Executive(MultiSigActor):
def __init__(self,
checksum_address: str,
signer: Signer = None,
client_password: str = None,
*args, **kwargs):
super().__init__(checksum_address=checksum_address, *args, **kwargs)
@ -504,9 +503,7 @@ class Executive(MultiSigActor):
f"Current owners are {self.multisig_agent.owners}")
self.signer = signer
if signer:
self.transacting_power = TransactingPower(signer=signer,
password=client_password,
account=checksum_address)
self.transacting_power = TransactingPower(signer=signer, account=checksum_address)
self.transacting_power.activate()
def authorize_proposal(self, proposal) -> Authorization:
@ -1645,7 +1642,6 @@ class Bidder(NucypherTokenActor):
checksum_address: str,
transacting: bool = True,
signer: Signer = None,
client_password: str = None,
*args, **kwargs):
super().__init__(checksum_address=checksum_address, *args, **kwargs)
@ -1655,9 +1651,9 @@ class Bidder(NucypherTokenActor):
self.economics = EconomicsFactory.get_economics(registry=self.registry)
if transacting:
self.transacting_power = TransactingPower(signer=signer,
password=client_password,
account=checksum_address)
if not signer:
raise ValueError('signer is required to init a transacting Bidder.')
self.transacting_power = TransactingPower(signer=signer, account=checksum_address)
self.transacting_power.activate()
self._all_bonus_bidders = None
@ -1908,14 +1904,11 @@ class DaoActor(BaseActor):
checksum_address: ChecksumAddress,
registry=None,
signer: Signer = None,
client_password: str = None,
transacting: bool = True):
super().__init__(registry=registry, domain=network, checksum_address=checksum_address)
self.dao_registry = DAORegistry(network=network)
if transacting: # TODO: This logic is repeated in Bidder and possible others.
self.transacting_power = TransactingPower(signer=signer,
password=client_password,
account=checksum_address)
self.transacting_power = TransactingPower(signer=signer, account=checksum_address)
self.transacting_power.activate()

View File

@ -116,8 +116,6 @@ class Alice(Character, BlockchainPolicyAuthor):
# Ownership
checksum_address: str = None,
client_password: str = None,
cache_password: bool = False,
# M of N
m: int = None,
@ -164,10 +162,8 @@ class Alice(Character, BlockchainPolicyAuthor):
if is_me and not federated_only: # TODO: #289
blockchain = BlockchainInterfaceFactory.get_interface(provider_uri=self.provider_uri)
self.transacting_power = TransactingPower(account=self.checksum_address,
password=client_password,
cache=cache_password,
signer=signer or Web3Signer(blockchain.client))
signer = signer or Web3Signer(blockchain.client) # fallback to web3 provider by default for Alice.
self.transacting_power = TransactingPower(account=self.checksum_address, signer=signer)
self._crypto_power.consume_power_up(self.transacting_power)
BlockchainPolicyAuthor.__init__(self,

View File

@ -15,16 +15,17 @@ You should have received a copy of the GNU Affero General Public License
along with nucypher. If not, see <https://www.gnu.org/licenses/>.
"""
from copy import copy
import tempfile
from eth_tester.exceptions import ValidationError
from unittest.mock import patch
from eth_tester.exceptions import ValidationError
from nucypher.blockchain.eth.signers.software import Web3Signer
from nucypher.characters.lawful import Alice, Ursula
from nucypher.config.constants import TEMPORARY_DOMAIN
from nucypher.crypto.api import encrypt_and_sign
from nucypher.crypto.constants import HRAC_LENGTH
from nucypher.crypto.powers import CryptoPower, SigningPower, DecryptingPower, TransactingPower
from nucypher.exceptions import DevelopmentInstallationRequired
from nucypher.policy.collections import SignedTreasureMap
@ -70,8 +71,9 @@ class Vladimir(Ursula):
if claim_signing_key:
crypto_power.consume_power_up(SigningPower(public_key=target_ursula.stamp.as_umbral_pubkey()))
blockchain = target_ursula.policy_agent.blockchain
if attach_transacting_key:
cls.attach_transacting_key(blockchain=target_ursula.policy_agent.blockchain)
cls.attach_transacting_key(blockchain=blockchain)
db_filepath = tempfile.mkdtemp(prefix='Vladimir')
@ -87,6 +89,7 @@ class Vladimir(Ursula):
network_middleware=cls.network_middleware,
checksum_address=cls.fraud_address,
worker_address=cls.fraud_address,
signer=Web3Signer(blockchain.client),
######### Asshole.
timestamp=target_ursula._timestamp,
interface_signature=target_ursula._interface_signature,

View File

@ -281,7 +281,6 @@ class AliceCharacterOptions:
unlock_keyring=not config.dev_mode,
teacher_uri=self.teacher_uri,
min_stake=self.min_stake,
client_password=client_password,
start_learning_now=load_seednodes,
lonely=self.config_options.lonely)
return ALICE

View File

@ -92,7 +92,6 @@ class DaoOptions: # TODO: This class is essentially the same that WorkLock opti
actor = EmergencyResponseManager(checksum_address=self.participant_address, # bomberos
network=self.network,
registry=registry,
client_password=client_password,
signer=signer,
transacting=transacting)
return actor

View File

@ -200,15 +200,14 @@ class ActorOptions:
click.confirm(CONFIRM_SELECTED_ACCOUNT.format(address=deployer_address), abort=True)
is_clef = ClefSigner.is_valid_clef_uri(self.signer_uri)
eth_password_is_needed = not self.hw_wallet and not deployer_interface.client.is_local and not is_clef
if eth_password_is_needed:
password_required = not self.hw_wallet and not deployer_interface.client.is_local and not is_clef
if password_required:
password = get_client_password(checksum_address=deployer_address)
# Produce Actor
testnet = deployer_interface.client.chain_name != PUBLIC_CHAINS[1] # Mainnet
signer = Signer.from_signer_uri(self.signer_uri, testnet=testnet) if self.signer_uri else None
ADMINISTRATOR = ContractAdministrator(registry=local_registry,
client_password=password,
deployer_address=deployer_address,
is_transacting=is_transacting,
signer=signer)

View File

@ -161,7 +161,7 @@ class FelixCharacterOptions:
envvar=NUCYPHER_ENVVAR_WORKER_ETH_PASSWORD)
# Produce Felix
FELIX = felix_config.produce(domain=self.config_options.domain, client_password=client_password)
FELIX = felix_config.produce(domain=self.config_options.domain)
FELIX.make_web_app() # attach web application, but dont start service
return FELIX

View File

@ -110,8 +110,7 @@ class MultiSigOptions:
client_password = get_client_password(checksum_address=self.checksum_address)
executive = Executive(checksum_address=self.checksum_address,
registry=registry,
signer=ClefSigner(self.signer_uri),
client_password=client_password)
signer=ClefSigner(self.signer_uri))
return executive
def create_executive(self, registry) -> Executive: # TODO: Reconsider this method: Executives don't transact, just sign.
@ -125,7 +124,7 @@ class MultiSigOptions:
is_clef = ClefSigner.is_valid_clef_uri(self.signer_uri)
if transacting and not self.hw_wallet and not is_clef:
client_password = get_client_password(checksum_address=self.checksum_address)
trustee = Trustee(checksum_address=self.checksum_address, registry=registry, client_password=client_password)
trustee = Trustee(checksum_address=self.checksum_address, registry=registry)
return trustee
def create_trustee(self, registry) -> Trustee:

View File

@ -264,11 +264,11 @@ class UrsulaCharacterOptions:
try:
URSULA = make_cli_character(character_config=ursula_config,
emitter=emitter,
client_password=client_password,
min_stake=self.min_stake,
teacher_uri=self.teacher_uri,
unlock_keyring=not self.config_options.dev,
lonely=self.config_options.lonely,
client_password=client_password,
start_learning_now=load_seednodes)
return ursula_config, URSULA

View File

@ -114,17 +114,19 @@ class WorkLockOptions:
def __create_bidder(self,
registry,
transacting: bool = True,
hw_wallet: bool = False) -> Bidder:
hw_wallet: bool = False
) -> Bidder:
client_password = None
is_clef = ClefSigner.is_valid_clef_uri(self.signer_uri)
if transacting and not is_clef and not hw_wallet:
client_password = get_client_password(checksum_address=self.bidder_address)
testnet = self.network != NetworksInventory.MAINNET
signer = Signer.from_signer_uri(self.signer_uri, testnet=testnet) if self.signer_uri else None
password_required = (not is_clef and not hw_wallet)
if signer and transacting and password_required:
client_password = get_client_password(checksum_address=self.bidder_address)
signer.unlock_account(account=self.bidder_address, password=client_password)
bidder = Bidder(checksum_address=self.bidder_address,
registry=registry,
client_password=client_password,
signer=signer,
transacting=transacting)
return bidder

View File

@ -112,7 +112,7 @@ class TransactingPower(CryptoPowerUp):
@validate_checksum_address
def __init__(self,
account: str,
signer: Signer = None,
signer: Signer,
password: str = None,
cache: bool = False):
"""
@ -121,9 +121,7 @@ class TransactingPower(CryptoPowerUp):
# Auth
if not signer:
# TODO: Consider making this required
blockchain = BlockchainInterfaceFactory.get_interface()
signer = Web3Signer(client=blockchain.client)
raise ValueError('signer is required to init a TransactingPower.')
self._signer = signer
self.__account = account
self.__password = password
@ -186,6 +184,8 @@ class TransactingPower(CryptoPowerUp):
def unlock_account(self, password: str = None, duration: int = None) -> bool:
"""Unlocks the account with provided or cached password."""
if self.is_unlocked:
return True
password = password or self.__password
result = self._signer.unlock_account(self.__account,
password=password,

View File

@ -415,7 +415,7 @@ class Learner:
try:
node.verify_node(force=force_verification_recheck,
network_middleware_client=self.network_middleware.client,
registry=registry) # composed on character subclass, determines operating mode
registry=registry)
except SSLError:
# TODO: Bucket this node as having bad TLS info - maybe it's an update that hasn't fully propagated? 567
return False

View File

@ -14,6 +14,8 @@
You should have received a copy of the GNU Affero General Public License
along with nucypher. If not, see <https://www.gnu.org/licenses/>.
"""
from eth_typing import HexStr
from web3 import Web3
from web3._utils.abi import get_constructor_abi, merge_args_and_kwargs
@ -21,6 +23,7 @@ from web3._utils.contracts import encode_abi
from web3.contract import ContractConstructor
def to_bytes32(value=None, hexstr=None) -> bytes:
return Web3.toBytes(primitive=value, hexstr=hexstr).rjust(32, b'\0')

View File

@ -20,6 +20,7 @@ import random
import pytest
from eth_tester.exceptions import TransactionFailed
from nucypher.blockchain.eth.signers.software import Web3Signer
from nucypher.blockchain.eth.actors import Bidder
from nucypher.blockchain.eth.agents import ContractAgency, StakingEscrowAgent, WorkLockAgent
from nucypher.blockchain.eth.constants import NULL_ADDRESS
@ -27,7 +28,7 @@ from nucypher.blockchain.eth.constants import NULL_ADDRESS
def test_create_bidder(testerchain, test_registry, agency, token_economics):
bidder_address = testerchain.unassigned_accounts[0]
bidder = Bidder(checksum_address=bidder_address, registry=test_registry)
bidder = Bidder(checksum_address=bidder_address, registry=test_registry, signer=Web3Signer(testerchain.client))
assert bidder.checksum_address == bidder_address
assert bidder.registry == test_registry
@ -48,7 +49,7 @@ def test_bidding(testerchain, agency, token_economics, test_registry):
for i, bid in enumerate(initial_bids):
bidder_address = testerchain.client.accounts[i]
bidder = Bidder(checksum_address=bidder_address, registry=test_registry)
bidder = Bidder(checksum_address=bidder_address, registry=test_registry, signer=Web3Signer(testerchain.client))
assert bidder.get_deposited_eth == 0
receipt = bidder.place_bid(value=bid)
@ -61,7 +62,7 @@ def test_cancel_bid(testerchain, agency, token_economics, test_registry):
testerchain.time_travel(seconds=token_economics.bidding_duration+1)
bidder_address = testerchain.client.accounts[1]
bidder = Bidder(checksum_address=bidder_address, registry=test_registry)
bidder = Bidder(checksum_address=bidder_address, registry=test_registry, signer=Web3Signer(testerchain.client))
assert bidder.get_deposited_eth # Bid
receipt = bidder.cancel_bid() # Cancel
assert receipt['status'] == 1
@ -74,14 +75,14 @@ def test_cancel_bid(testerchain, agency, token_economics, test_registry):
def test_get_remaining_work(testerchain, agency, token_economics, test_registry):
bidder_address = testerchain.client.accounts[0]
bidder = Bidder(checksum_address=bidder_address, registry=test_registry)
bidder = Bidder(checksum_address=bidder_address, registry=test_registry, signer=Web3Signer(testerchain.client))
remaining = bidder.remaining_work
assert remaining
def test_verify_correctness_before_refund(testerchain, agency, token_economics, test_registry):
bidder_address = testerchain.client.accounts[0]
bidder = Bidder(checksum_address=bidder_address, registry=test_registry)
bidder = Bidder(checksum_address=bidder_address, registry=test_registry, signer=Web3Signer(testerchain.client))
worklock_agent = ContractAgency.get_agent(WorkLockAgent, registry=test_registry)
with pytest.raises(Bidder.CancellationWindowIsOpen):
@ -99,7 +100,7 @@ def test_verify_correctness_before_refund(testerchain, agency, token_economics,
def test_force_refund(testerchain, agency, token_economics, test_registry):
bidder_address = testerchain.client.accounts[0]
bidder = Bidder(checksum_address=bidder_address, registry=test_registry)
bidder = Bidder(checksum_address=bidder_address, registry=test_registry, signer=Web3Signer(testerchain.client))
whales = bidder.get_whales()
# Simulate force refund
@ -110,7 +111,7 @@ def test_force_refund(testerchain, agency, token_economics, test_registry):
new_whales = bidder.get_whales()
bidder_address = testerchain.client.accounts[1]
bidder = Bidder(checksum_address=bidder_address, registry=test_registry)
bidder = Bidder(checksum_address=bidder_address, registry=test_registry, signer=Web3Signer(testerchain.client))
worklock_agent = ContractAgency.get_agent(WorkLockAgent, registry=test_registry)
receipt = bidder.force_refund()
@ -127,7 +128,7 @@ def test_force_refund(testerchain, agency, token_economics, test_registry):
def test_verify_correctness(testerchain, agency, token_economics, test_registry):
bidder_address = testerchain.client.accounts[0]
bidder = Bidder(checksum_address=bidder_address, registry=test_registry)
bidder = Bidder(checksum_address=bidder_address, registry=test_registry, signer=Web3Signer(testerchain.client))
worklock_agent = ContractAgency.get_agent(WorkLockAgent, registry=test_registry)
assert not worklock_agent.bidders_checked()
@ -143,7 +144,7 @@ def test_verify_correctness(testerchain, agency, token_economics, test_registry)
def test_withdraw_compensation(testerchain, agency, token_economics, test_registry):
bidder_address = testerchain.client.accounts[12]
bidder = Bidder(checksum_address=bidder_address, registry=test_registry)
bidder = Bidder(checksum_address=bidder_address, registry=test_registry, signer=Web3Signer(testerchain.client))
worklock_agent = ContractAgency.get_agent(WorkLockAgent, registry=test_registry)
assert worklock_agent.get_available_compensation(checksum_address=bidder_address) > 0
@ -154,7 +155,7 @@ def test_withdraw_compensation(testerchain, agency, token_economics, test_regist
def test_claim(testerchain, agency, token_economics, test_registry):
bidder_address = testerchain.client.accounts[11]
bidder = Bidder(checksum_address=bidder_address, registry=test_registry)
bidder = Bidder(checksum_address=bidder_address, registry=test_registry, signer=Web3Signer(testerchain.client))
staking_agent = ContractAgency.get_agent(StakingEscrowAgent, registry=test_registry)
worklock_agent = ContractAgency.get_agent(WorkLockAgent, registry=test_registry)

View File

@ -21,6 +21,7 @@ import json
import pytest
import random
from nucypher.blockchain.eth.signers.software import Web3Signer
from nucypher.blockchain.eth.actors import ContractAdministrator
from nucypher.crypto.powers import TransactingPower
from tests.constants import INSECURE_DEVELOPMENT_PASSWORD, NUMBER_OF_ALLOCATIONS_IN_TESTS
@ -37,11 +38,14 @@ def test_rapid_deployment(token_economics, test_registry, tmpdir, get_random_che
# TODO: #1092 - TransactingPower
blockchain.transacting_power = TransactingPower(password=INSECURE_DEVELOPMENT_PASSWORD,
signer=Web3Signer(blockchain.client),
account=blockchain.etherbase_account)
blockchain.transacting_power.activate()
deployer_address = blockchain.etherbase_account
administrator = ContractAdministrator(deployer_address=deployer_address, registry=test_registry)
administrator = ContractAdministrator(deployer_address=deployer_address,
signer=Web3Signer(blockchain.client),
registry=test_registry)
blockchain.bootstrap_network(registry=test_registry)
all_yall = blockchain.unassigned_accounts

View File

@ -15,11 +15,10 @@ You should have received a copy of the GNU Affero General Public License
along with nucypher. If not, see <https://www.gnu.org/licenses/>.
"""
import pytest
from unittest.mock import patch
from nucypher.blockchain.eth.signers.software import Web3Signer
from nucypher.blockchain.eth.actors import Trustee
from nucypher.blockchain.eth.agents import MultiSigAgent
from nucypher.blockchain.eth.deployers import MultiSigDeployer
@ -33,10 +32,13 @@ def test_trustee_proposes_multisig_management_operations(testerchain, test_regis
for step in multisig_deployer.deployment_steps:
assert receipts[step]['status'] == 1
multisig_agent = multisig_deployer.make_agent() # type: MultiSigAgent
multisig_agent = multisig_deployer.make_agent()
trustee_address = testerchain.unassigned_accounts[-1]
trustee = Trustee(checksum_address=trustee_address, registry=test_registry)
trustee = Trustee(checksum_address=trustee_address,
signer=Web3Signer(testerchain.client),
registry=test_registry,
is_transacting=True)
# Propose changing threshold
free_payload = {'nonce': 0, 'from': multisig_agent.contract_address, 'gasPrice': 0}

View File

@ -256,6 +256,8 @@ def test_staker_collects_staking_reward(testerchain,
ursula_decentralized_test_config):
token_agent, staking_agent, policy_agent = agency
testerchain.transacting_power.activate()
# Give more tokens to staker
token_airdrop(token_agent=token_agent,
origin=testerchain.etherbase_account,

View File

@ -149,7 +149,6 @@ def test_set_min_fee_rate(testerchain, test_registry, agency, policy_meta):
assert policy_agent.get_min_fee_rate(staker) == minimum + 1
@pytest.mark.usefixtures('blockchain_ursulas')
def test_collect_policy_fee(testerchain, agency, policy_meta, token_economics, mock_transacting_power_activation):
token_agent, staking_agent, policy_agent = agency

View File

@ -19,6 +19,7 @@ import pytest
from constant_sorrow import constants
from eth_tester.exceptions import TransactionFailed
from nucypher.blockchain.eth.signers.software import Web3Signer
from nucypher.blockchain.eth.actors import Staker
from nucypher.blockchain.eth.agents import ContractAgency, NucypherTokenAgent, StakingEscrowAgent
from nucypher.blockchain.eth.deployers import (AdjudicatorDeployer, BaseContractDeployer, NucypherTokenDeployer,
@ -131,7 +132,9 @@ def test_stake_in_idle_network(testerchain, token_economics, test_registry):
staker = Staker(is_me=True, checksum_address=account, registry=test_registry)
# Mock TransactingPower consumption
staker.transacting_power = TransactingPower(password=INSECURE_DEVELOPMENT_PASSWORD, account=staker.checksum_address)
staker.transacting_power = TransactingPower(password=INSECURE_DEVELOPMENT_PASSWORD,
signer=Web3Signer(testerchain.client),
account=staker.checksum_address)
staker.transacting_power.activate()
# Since StakingEscrow hasn't been activated yet, deposit should work but making a commitment must fail

View File

@ -18,6 +18,7 @@
from nucypher.blockchain.eth.interfaces import BlockchainDeployerInterface, BlockchainInterfaceFactory
from nucypher.blockchain.eth.registry import InMemoryContractRegistry
from nucypher.blockchain.eth.signers.software import Web3Signer
from nucypher.blockchain.eth.sol.compile.constants import TEST_MULTIVERSION_CONTRACTS
from nucypher.blockchain.eth.sol.compile.types import SourceBundle
from nucypher.crypto.powers import TransactingPower
@ -49,7 +50,9 @@ def test_deployer_interface_multiversion_contract():
BlockchainInterfaceFactory.register_interface(interface=blockchain_interface) # Lets this test run in isolation
origin = blockchain_interface.client.accounts[0]
blockchain_interface.transacting_power = TransactingPower(password=INSECURE_DEVELOPMENT_PASSWORD, account=origin)
blockchain_interface.transacting_power = TransactingPower(password=INSECURE_DEVELOPMENT_PASSWORD,
signer=Web3Signer(blockchain_interface.client),
account=origin)
blockchain_interface.transacting_power.activate()
# Searching both contract through raw data

View File

@ -20,10 +20,10 @@ import pytest
from nucypher.blockchain.eth.clients import EthereumClient
from nucypher.blockchain.eth.interfaces import BlockchainDeployerInterface
from nucypher.blockchain.eth.registry import InMemoryContractRegistry
from nucypher.blockchain.eth.signers.software import Web3Signer
from nucypher.blockchain.eth.sol.compile.compile import multiversion_compile
from nucypher.blockchain.eth.sol.compile.constants import TEST_MULTIVERSION_CONTRACTS, SOLIDITY_SOURCE_ROOT
from nucypher.blockchain.eth.sol.compile.types import SourceBundle
from nucypher.config.constants import NUCYPHER_TEST_DIR
from nucypher.crypto.powers import TransactingPower
from tests.constants import (
DEVELOPMENT_ETH_AIRDROP_AMOUNT,
@ -112,7 +112,9 @@ def test_multiversion_contract():
blockchain_interface._raw_contract_cache = compiled_contracts
origin = blockchain_interface.client.accounts[0]
blockchain_interface.transacting_power = TransactingPower(password=INSECURE_DEVELOPMENT_PASSWORD, account=origin)
blockchain_interface.transacting_power = TransactingPower(password=INSECURE_DEVELOPMENT_PASSWORD,
signer=Web3Signer(blockchain_interface.client),
account=origin)
blockchain_interface.transacting_power.activate()
# Searching both contract through raw data

View File

@ -15,10 +15,12 @@
along with nucypher. If not, see <https://www.gnu.org/licenses/>.
"""
import pytest
from eth_account._utils.transactions import Transaction
from eth_utils import to_checksum_address
from nucypher.blockchain.eth.signers.software import Web3Signer
from nucypher.blockchain.eth.agents import NucypherTokenAgent
from nucypher.crypto.api import verify_eip_191
from nucypher.crypto.powers import TransactingPower
@ -33,6 +35,7 @@ def test_transacting_power_sign_message(testerchain):
# Manually create a TransactingPower
eth_address = testerchain.etherbase_account
power = TransactingPower(password=INSECURE_DEVELOPMENT_PASSWORD,
signer=Web3Signer(testerchain.client),
account=eth_address)
# The default state of the account is locked.
@ -69,6 +72,7 @@ def test_transacting_power_sign_transaction(testerchain):
eth_address = testerchain.unassigned_accounts[2]
power = TransactingPower(password=INSECURE_DEVELOPMENT_PASSWORD,
signer=Web3Signer(testerchain.client),
account=eth_address)
assert power.is_active is False
@ -116,6 +120,7 @@ def test_transacting_power_sign_transaction(testerchain):
# Tear-Down Test
power = TransactingPower(password=INSECURE_DEVELOPMENT_PASSWORD,
signer=Web3Signer(testerchain.client),
account=testerchain.etherbase_account)
power.activate(password=INSECURE_DEVELOPMENT_PASSWORD)
@ -134,6 +139,7 @@ def test_transacting_power_sign_agent_transaction(testerchain, agency, test_regi
# Sign with Transacting Power
transacting_power = TransactingPower(password=INSECURE_DEVELOPMENT_PASSWORD,
signer=Web3Signer(testerchain.client),
account=testerchain.etherbase_account)
transacting_power.activate()
signed_raw_transaction = transacting_power.sign_transaction(unsigned_transaction)

View File

@ -48,6 +48,7 @@ def test_deploy_single_contract(click_runner, tempfile_path):
'--contract-name', NucypherTokenAgent.contract_name,
'--registry-infile', tempfile_path,
'--provider', TEST_PROVIDER_URI,
'--signer', TEST_PROVIDER_URI,
'--network', TEMPORARY_DOMAIN,
'--debug']
@ -106,6 +107,7 @@ def test_upgrade_contracts(click_runner, test_registry_source_manager, test_regi
cli_action = 'upgrade'
base_command = ('--registry-infile', registry_filepath,
'--provider', TEST_PROVIDER_URI,
'--signer', TEST_PROVIDER_URI,
'--confirmations', 1,
'--network', TEMPORARY_DOMAIN,
'--force' # skip registry preflight check for tests
@ -234,7 +236,9 @@ def test_rollback(click_runner, testerchain, registry_filepath, agency):
'--contract-name', contract_name,
'--registry-infile', registry_filepath,
'--network', TEMPORARY_DOMAIN,
'--provider', TEST_PROVIDER_URI)
'--provider', TEST_PROVIDER_URI,
'--signer', TEST_PROVIDER_URI
)
user_input = '0\n' + YES_ENTER
result = click_runner.invoke(deploy, command, input=user_input, catch_exceptions=False)

View File

@ -62,6 +62,7 @@ def test_set_range(click_runner, testerchain, agency_local_registry):
minimum, default, maximum = 10, 20, 30
status_command = ('set-range',
'--provider', TEST_PROVIDER_URI,
'--signer', TEST_PROVIDER_URI,
'--registry-infile', agency_local_registry.filepath,
'--minimum', minimum,
'--default', default,
@ -122,6 +123,7 @@ def test_transfer_ownership(click_runner, testerchain, agency_local_registry):
'--registry-infile', agency_local_registry.filepath,
'--contract-name', STAKING_ESCROW_CONTRACT_NAME,
'--provider', TEST_PROVIDER_URI,
'--signer', TEST_PROVIDER_URI,
'--network', TEMPORARY_DOMAIN,
'--target-address', maclane)
@ -146,6 +148,7 @@ def test_transfer_ownership(click_runner, testerchain, agency_local_registry):
'--contract-name', STAKING_ESCROW_CONTRACT_NAME,
'--registry-infile', agency_local_registry.filepath,
'--provider', TEST_PROVIDER_URI,
'--signer', TEST_PROVIDER_URI,
'--network', TEMPORARY_DOMAIN,
'--target-address', michwill)
@ -171,6 +174,7 @@ def test_transfer_ownership_staking_interface_router(click_runner, testerchain,
'--registry-infile', agency_local_registry.filepath,
'--contract-name', StakingInterfaceDeployer.contract_name,
'--provider', TEST_PROVIDER_URI,
'--signer', TEST_PROVIDER_URI,
'--network', TEMPORARY_DOMAIN,
'--target-address', maclane,
'--debug')
@ -200,6 +204,7 @@ def test_bare_contract_deployment_to_alternate_registry(click_runner, agency_loc
'--contract-name', StakingEscrowDeployer.contract_name,
'--mode', 'bare',
'--provider', TEST_PROVIDER_URI,
'--signer', TEST_PROVIDER_URI,
'--registry-infile', agency_local_registry.filepath,
'--registry-outfile', ALTERNATE_REGISTRY_FILEPATH,
'--network', TEMPORARY_DOMAIN,
@ -246,6 +251,7 @@ def test_manual_proxy_retargeting(monkeypatch, testerchain, click_runner, token_
'--contract-name', StakingEscrowDeployer.contract_name,
'--target-address', untargeted_deployment.address,
'--provider', TEST_PROVIDER_URI,
'--signer', TEST_PROVIDER_URI,
'--registry-infile', ALTERNATE_REGISTRY_FILEPATH,
'--confirmations', 4,
'--network', TEMPORARY_DOMAIN)
@ -275,6 +281,7 @@ def test_manual_deployment_of_idle_network(click_runner):
'--contract-name', NUCYPHER_TOKEN_CONTRACT_NAME,
'--provider', TEST_PROVIDER_URI,
'--network', TEMPORARY_DOMAIN,
'--signer', TEST_PROVIDER_URI,
'--registry-infile', ALTERNATE_REGISTRY_FILEPATH_2)
result = click_runner.invoke(deploy, command, input=user_input, catch_exceptions=False)
@ -291,6 +298,7 @@ def test_manual_deployment_of_idle_network(click_runner):
'--contract-name', STAKING_ESCROW_CONTRACT_NAME,
'--mode', 'init',
'--provider', TEST_PROVIDER_URI,
'--signer', TEST_PROVIDER_URI,
'--network', TEMPORARY_DOMAIN,
'--registry-infile', ALTERNATE_REGISTRY_FILEPATH_2)
@ -304,6 +312,7 @@ def test_manual_deployment_of_idle_network(click_runner):
command = ('contracts',
'--contract-name', POLICY_MANAGER_CONTRACT_NAME,
'--provider', TEST_PROVIDER_URI,
'--signer', TEST_PROVIDER_URI,
'--network', TEMPORARY_DOMAIN,
'--registry-infile', ALTERNATE_REGISTRY_FILEPATH_2)
@ -317,6 +326,7 @@ def test_manual_deployment_of_idle_network(click_runner):
command = ('contracts',
'--contract-name', ADJUDICATOR_CONTRACT_NAME,
'--provider', TEST_PROVIDER_URI,
'--signer', TEST_PROVIDER_URI,
'--network', TEMPORARY_DOMAIN,
'--registry-infile', ALTERNATE_REGISTRY_FILEPATH_2)
@ -331,6 +341,7 @@ def test_manual_deployment_of_idle_network(click_runner):
'--contract-name', STAKING_ESCROW_CONTRACT_NAME,
'--mode', 'idle',
'--provider', TEST_PROVIDER_URI,
'--signer', TEST_PROVIDER_URI,
'--network', TEMPORARY_DOMAIN,
'--registry-infile', ALTERNATE_REGISTRY_FILEPATH_2)
@ -345,6 +356,7 @@ def test_manual_deployment_of_idle_network(click_runner):
'--contract-name', STAKING_ESCROW_CONTRACT_NAME,
'--activate',
'--provider', TEST_PROVIDER_URI,
'--signer', TEST_PROVIDER_URI,
'--network', TEMPORARY_DOMAIN,
'--registry-infile', ALTERNATE_REGISTRY_FILEPATH_2)

View File

@ -23,6 +23,7 @@ import pytest
from eth_utils import to_wei
from web3 import Web3
from nucypher.blockchain.eth.signers.software import Web3Signer
from nucypher.crypto.powers import TransactingPower
from nucypher.blockchain.eth.actors import Bidder, Staker
from nucypher.blockchain.eth.agents import (
@ -73,6 +74,7 @@ def test_bid(click_runner, testerchain, agency_local_registry, token_economics,
base_command = ('escrow',
'--registry-filepath', agency_local_registry.filepath,
'--provider', TEST_PROVIDER_URI,
'--signer', TEST_PROVIDER_URI,
'--network', TEMPORARY_DOMAIN,
'--force')
@ -107,6 +109,7 @@ def test_cancel_bid(click_runner, testerchain, agency_local_registry, token_econ
'--participant-address', bidder,
'--registry-filepath', agency_local_registry.filepath,
'--provider', TEST_PROVIDER_URI,
'--signer', TEST_PROVIDER_URI,
'--network', TEMPORARY_DOMAIN,
'--force')
@ -123,6 +126,7 @@ def test_cancel_bid(click_runner, testerchain, agency_local_registry, token_econ
'--participant-address', bidder,
'--registry-filepath', agency_local_registry.filepath,
'--provider', TEST_PROVIDER_URI,
'--signer', TEST_PROVIDER_URI,
'--network', TEMPORARY_DOMAIN,
'--force')
@ -146,6 +150,7 @@ def test_enable_claiming(click_runner, testerchain, agency_local_registry, token
'--participant-address', bidder,
'--registry-filepath', agency_local_registry.filepath,
'--provider', TEST_PROVIDER_URI,
'--signer', TEST_PROVIDER_URI,
'--force',
'--network', TEMPORARY_DOMAIN,
'--gas-limit', 100000)
@ -165,6 +170,7 @@ def test_claim(click_runner, testerchain, agency_local_registry, token_economics
'--participant-address', bidder,
'--registry-filepath', agency_local_registry.filepath,
'--provider', TEST_PROVIDER_URI,
'--signer', TEST_PROVIDER_URI,
'--network', TEMPORARY_DOMAIN,
'--force')
@ -178,6 +184,7 @@ def test_claim(click_runner, testerchain, agency_local_registry, token_economics
'--participant-address', whale,
'--registry-filepath', agency_local_registry.filepath,
'--provider', TEST_PROVIDER_URI,
'--signer', TEST_PROVIDER_URI,
'--network', TEMPORARY_DOMAIN,
'--force')
@ -201,6 +208,7 @@ def test_remaining_work(click_runner, testerchain, agency_local_registry, token_
'--participant-address', bidder,
'--registry-filepath', agency_local_registry.filepath,
'--provider', TEST_PROVIDER_URI,
'--signer', TEST_PROVIDER_URI,
'--network', TEMPORARY_DOMAIN)
result = click_runner.invoke(worklock, command, catch_exceptions=False)
@ -230,6 +238,7 @@ def test_refund(click_runner, testerchain, agency_local_registry, token_economic
worker = Ursula(is_me=True,
registry=agency_local_registry,
checksum_address=bidder,
signer=Web3Signer(testerchain.client),
worker_address=worker_address,
rest_host=MOCK_IP_ADDRESS,
rest_port=select_test_port(),
@ -255,6 +264,7 @@ def test_refund(click_runner, testerchain, agency_local_registry, token_economic
'--participant-address', bidder,
'--registry-filepath', agency_local_registry.filepath,
'--provider', TEST_PROVIDER_URI,
'--signer', TEST_PROVIDER_URI,
'--network', TEMPORARY_DOMAIN,
'--force')
@ -268,12 +278,15 @@ def test_refund(click_runner, testerchain, agency_local_registry, token_economic
def test_participant_status(click_runner, testerchain, agency_local_registry, token_economics):
bidder = Bidder(checksum_address=testerchain.client.accounts[2], registry=agency_local_registry)
bidder = Bidder(checksum_address=testerchain.client.accounts[2],
signer=Web3Signer(testerchain.client),
registry=agency_local_registry)
command = ('status',
'--registry-filepath', agency_local_registry.filepath,
'--participant-address', bidder.checksum_address,
'--provider', TEST_PROVIDER_URI,
'--signer', TEST_PROVIDER_URI,
'--network', TEMPORARY_DOMAIN)
result = click_runner.invoke(worklock, command, catch_exceptions=False)

View File

@ -145,9 +145,9 @@ def test_ursula_and_local_keystore_signer_integration(click_runner,
# Produce an Ursula with a Keystore signer correctly derived from the signer URI, and don't do anything else!
mocker.patch.object(StakeList, 'refresh', autospec=True)
ursula = ursula_config.produce(client_password=password,
commit_now=False,
block_until_ready=False)
ursula = ursula_config.produce(commit_now=False, block_until_ready=False)
ursula.signer.unlock_account(account=worker_account.address, password=password)
try:
# Verify the keystore path is still preserved

View File

@ -16,32 +16,41 @@ along with nucypher. If not, see <https://www.gnu.org/licenses/>.
"""
import json
import random
import maya
import os
import pytest
import random
import tempfile
from web3 import Web3
from nucypher.blockchain.eth.actors import Staker
from nucypher.blockchain.eth.agents import (ContractAgency, NucypherTokenAgent, PreallocationEscrowAgent,
StakingEscrowAgent)
from nucypher.blockchain.eth.agents import (
ContractAgency,
NucypherTokenAgent,
PreallocationEscrowAgent,
StakingEscrowAgent
)
from nucypher.blockchain.eth.constants import NULL_ADDRESS
from nucypher.blockchain.eth.deployers import PreallocationEscrowDeployer
from nucypher.blockchain.eth.registry import InMemoryAllocationRegistry, IndividualAllocationRegistry
from nucypher.blockchain.eth.signers.software import Web3Signer
from nucypher.blockchain.eth.token import NU, Stake, StakeList
from nucypher.characters.lawful import Enrico, Ursula
from nucypher.cli.main import nucypher_cli
from nucypher.config.characters import UrsulaConfiguration
from nucypher.config.constants import TEMPORARY_DOMAIN
from nucypher.utilities.logging import Logger
from tests.constants import (FAKE_PASSWORD_CONFIRMED, INSECURE_DEVELOPMENT_PASSWORD,
MOCK_INDIVIDUAL_ALLOCATION_FILEPATH, MOCK_IP_ADDRESS,
ONE_YEAR_IN_SECONDS,
TEST_PROVIDER_URI)
from tests.constants import (
FAKE_PASSWORD_CONFIRMED,
INSECURE_DEVELOPMENT_PASSWORD,
MOCK_INDIVIDUAL_ALLOCATION_FILEPATH,
MOCK_IP_ADDRESS,
ONE_YEAR_IN_SECONDS,
TEST_PROVIDER_URI
)
from tests.utils.middleware import MockRestMiddleware
from tests.utils.ursula import MOCK_KNOWN_URSULAS_CACHE, MOCK_URSULA_STARTING_PORT, select_test_port
from tests.utils.ursula import MOCK_KNOWN_URSULAS_CACHE, select_test_port
#
@ -492,6 +501,7 @@ def test_collect_rewards_integration(click_runner,
ursula_port = select_test_port()
ursula = Ursula(is_me=True,
signer=Web3Signer(testerchain.client),
checksum_address=staker_address,
worker_address=worker_address,
registry=agency_local_registry,

View File

@ -15,18 +15,20 @@ You should have received a copy of the GNU Affero General Public License
along with nucypher. If not, see <https://www.gnu.org/licenses/>.
"""
import json
import os
import random
import tempfile
from unittest import mock
import maya
import os
import random
import tempfile
from web3 import Web3
from nucypher.blockchain.eth.actors import Staker
from nucypher.blockchain.eth.agents import ContractAgency, StakingEscrowAgent
from nucypher.blockchain.eth.constants import NULL_ADDRESS
from nucypher.blockchain.eth.signers.software import Web3Signer
from nucypher.blockchain.eth.token import NU, Stake
from nucypher.blockchain.eth.utils import prettify_eth_amount
from nucypher.characters.lawful import Enrico, Ursula
@ -35,11 +37,16 @@ from nucypher.cli.main import nucypher_cli
from nucypher.config.characters import StakeHolderConfiguration, UrsulaConfiguration
from nucypher.config.constants import TEMPORARY_DOMAIN
from nucypher.utilities.logging import Logger
from tests.constants import FAKE_PASSWORD_CONFIRMED, FEE_RATE_RANGE, INSECURE_DEVELOPMENT_PASSWORD, MOCK_IP_ADDRESS, \
TEST_PROVIDER_URI, YES_ENTER
from tests.constants import (
FAKE_PASSWORD_CONFIRMED,
FEE_RATE_RANGE,
INSECURE_DEVELOPMENT_PASSWORD,
MOCK_IP_ADDRESS,
TEST_PROVIDER_URI,
YES_ENTER
)
from tests.utils.middleware import MockRestMiddleware
from tests.utils.ursula import MOCK_KNOWN_URSULAS_CACHE, MOCK_URSULA_STARTING_PORT, select_test_port
from tests.utils.ursula import MOCK_KNOWN_URSULAS_CACHE, select_test_port
@mock.patch('nucypher.config.characters.StakeHolderConfiguration.default_filepath', return_value='/non/existent/file')
@ -562,6 +569,7 @@ def test_collect_rewards_integration(click_runner,
ursula_port = select_test_port()
ursula = Ursula(is_me=True,
checksum_address=staker_address,
signer=Web3Signer(testerchain.client),
worker_address=worker_address,
registry=agency_local_registry,
rest_host='127.0.0.1',

View File

@ -14,19 +14,26 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with nucypher. If not, see <https://www.gnu.org/licenses/>.
"""
import contextlib
import os
from pathlib import Path
import requests
from constant_sorrow import constants
from pathlib import Path
from web3.exceptions import ValidationError
from nucypher.blockchain.eth.deployers import AdjudicatorDeployer, BaseContractDeployer, NucypherTokenDeployer, \
PolicyManagerDeployer, StakingEscrowDeployer, WorklockDeployer
from nucypher.blockchain.eth.deployers import (
AdjudicatorDeployer,
BaseContractDeployer,
NucypherTokenDeployer,
PolicyManagerDeployer,
StakingEscrowDeployer,
WorklockDeployer
)
from nucypher.blockchain.eth.interfaces import BlockchainDeployerInterface, BlockchainInterfaceFactory
from nucypher.blockchain.eth.registry import InMemoryContractRegistry
from nucypher.blockchain.eth.signers.software import Web3Signer
from nucypher.blockchain.eth.sol.compile.constants import SOLIDITY_SOURCE_ROOT
from nucypher.blockchain.eth.sol.compile.types import SourceBundle
from nucypher.crypto.powers import TransactingPower
@ -137,7 +144,9 @@ def test_upgradeability(temp_dir_path):
blockchain_interface.connect()
origin = blockchain_interface.client.accounts[0]
BlockchainInterfaceFactory.register_interface(interface=blockchain_interface)
blockchain_interface.transacting_power = TransactingPower(password=INSECURE_DEVELOPMENT_PASSWORD, account=origin)
blockchain_interface.transacting_power = TransactingPower(password=INSECURE_DEVELOPMENT_PASSWORD,
signer=Web3Signer(blockchain_interface.client),
account=origin)
blockchain_interface.transacting_power.activate()
economics = make_token_economics(blockchain_interface)

View File

@ -100,8 +100,9 @@ def test_ursula_init_with_local_keystore_signer(click_runner,
# Produce an ursula with a Keystore signer correctly derived from the signer URI, and dont do anything else!
mocker.patch.object(StakeList, 'refresh', autospec=True)
ursula = ursula_config.produce(client_password=password,
block_until_ready=False)
ursula = ursula_config.produce(block_until_ready=False)
ursula.signer.unlock_account(account=worker_account.address, password=password)
# Verify the keystore path is still preserved
assert isinstance(ursula.signer, KeystoreSigner)

View File

@ -24,6 +24,7 @@ import pytest
from eth_utils import to_wei
from web3 import Web3
from nucypher.blockchain.eth.signers.software import Web3Signer
from nucypher.blockchain.eth.actors import Bidder
from nucypher.blockchain.eth.interfaces import BlockchainInterface
from nucypher.blockchain.eth.utils import prettify_eth_amount
@ -51,7 +52,8 @@ from tests.mock.agents import MockContractAgent
@pytest.fixture()
def surrogate_bidder(mock_testerchain, test_registry, mock_worklock_agent):
address = mock_testerchain.etherbase_account
bidder = Bidder(checksum_address=address, registry=test_registry)
signer = Web3Signer(mock_testerchain.client)
bidder = Bidder(checksum_address=address, registry=test_registry, signer=signer)
return bidder
@ -80,9 +82,10 @@ def test_account_selection(click_runner, mocker, mock_testerchain, mock_worklock
command = ('cancel-escrow',
'--provider', MOCK_PROVIDER_URI,
'--signer', MOCK_PROVIDER_URI,
'--network', TEMPORARY_DOMAIN)
user_input = '\n'.join((str(index), INSECURE_DEVELOPMENT_PASSWORD, YES))
user_input = '\n'.join((str(index), INSECURE_DEVELOPMENT_PASSWORD, YES, YES))
result = click_runner.invoke(worklock, command, input=user_input, catch_exceptions=False)
assert result.exit_code == 0
@ -103,6 +106,7 @@ def bidding_command(token_economics, surrogate_bidder):
'--participant-address', surrogate_bidder.checksum_address,
'--value', bid_value,
'--provider', MOCK_PROVIDER_URI,
'--signer', MOCK_PROVIDER_URI,
'--network', TEMPORARY_DOMAIN,
'--force')
return command
@ -197,6 +201,7 @@ def test_valid_bid(click_runner,
'--participant-address', surrogate_bidder.checksum_address,
'--value', bid_value_in_eth,
'--provider', MOCK_PROVIDER_URI,
'--signer', MOCK_PROVIDER_URI,
'--network', TEMPORARY_DOMAIN,
'--force')
@ -237,6 +242,7 @@ def test_cancel_bid(click_runner,
command = ('cancel-escrow',
'--participant-address', surrogate_bidder.checksum_address,
'--provider', MOCK_PROVIDER_URI,
'--signer', MOCK_PROVIDER_URI,
'--network', TEMPORARY_DOMAIN,
'--force')
result = click_runner.invoke(worklock, command, input=INSECURE_DEVELOPMENT_PASSWORD, catch_exceptions=False)
@ -303,6 +309,7 @@ def test_enable_claiming(click_runner,
command = ('enable-claiming',
'--participant-address', surrogate_bidder.checksum_address,
'--provider', MOCK_PROVIDER_URI,
'--signer', MOCK_PROVIDER_URI,
'--network', TEMPORARY_DOMAIN)
gas_limit_1 = 200000
@ -362,6 +369,7 @@ def test_initial_claim(click_runner,
command = ('claim',
'--participant-address', bidder_address,
'--provider', MOCK_PROVIDER_URI,
'--signer', MOCK_PROVIDER_URI,
'--network', TEMPORARY_DOMAIN)
# First, let's test that if claiming is not available, command fails
@ -439,6 +447,7 @@ def test_already_claimed(click_runner,
command = ('claim',
'--participant-address', surrogate_bidder.checksum_address,
'--provider', MOCK_PROVIDER_URI,
'--signer', MOCK_PROVIDER_URI,
'--network', TEMPORARY_DOMAIN,
'--force')
@ -470,6 +479,7 @@ def test_remaining_work(click_runner,
command = ('remaining-work',
'--participant-address', surrogate_bidder.checksum_address,
'--provider', MOCK_PROVIDER_URI,
'--signer', MOCK_PROVIDER_URI,
'--network', TEMPORARY_DOMAIN)
result = click_runner.invoke(worklock, command, catch_exceptions=False)
@ -496,6 +506,7 @@ def test_refund(click_runner,
command = ('refund',
'--participant-address', bidder_address,
'--provider', MOCK_PROVIDER_URI,
'--signer', MOCK_PROVIDER_URI,
'--network', TEMPORARY_DOMAIN)
user_input = INSECURE_DEVELOPMENT_PASSWORD + '\n' + YES
@ -521,6 +532,7 @@ def test_participant_status(click_runner,
command = ('status',
'--participant-address', surrogate_bidder.checksum_address,
'--provider', MOCK_PROVIDER_URI,
'--signer', MOCK_PROVIDER_URI,
'--network', TEMPORARY_DOMAIN)
result = click_runner.invoke(worklock, command, catch_exceptions=False)
@ -574,6 +586,7 @@ def test_interactive_new_bid(click_runner,
command = ('escrow',
'--participant-address', surrogate_bidder.checksum_address,
'--provider', MOCK_PROVIDER_URI,
'--signer', MOCK_PROVIDER_URI,
'--network', TEMPORARY_DOMAIN,)
user_input = "\n".join((INSECURE_DEVELOPMENT_PASSWORD, str(wrong_bid_in_eth), str(bid_value_in_eth), YES))
@ -624,6 +637,7 @@ def test_interactive_increase_bid(click_runner,
command = ('escrow',
'--participant-address', surrogate_bidder.checksum_address,
'--provider', MOCK_PROVIDER_URI,
'--signer', MOCK_PROVIDER_URI,
'--network', TEMPORARY_DOMAIN,)
user_input = "\n".join((INSECURE_DEVELOPMENT_PASSWORD, str(bid_value_in_eth), YES))

View File

@ -176,7 +176,8 @@ def make_alice(known_nodes: Optional[Set[Ursula]] = None):
alice_config.initialize(password=INSECURE_PASSWORD)
alice_config.keyring.unlock(password=INSECURE_PASSWORD)
alice = alice_config.produce(client_password=SIGNER_PASSWORD)
alice = alice_config.produce()
alice.signer.unlock_account(account=ALICE_ADDRESS, password=SIGNER_PASSWORD)
alice.start_learning_loop(now=True)
return alice

View File

@ -24,6 +24,7 @@ from hexbytes import HexBytes
from typing import List, Tuple, Union, Optional
from web3 import Web3
from nucypher.blockchain.eth.signers.software import Web3Signer
from nucypher.blockchain.economics import BaseEconomics, StandardTokenEconomics
from nucypher.blockchain.eth.actors import ContractAdministrator
from nucypher.blockchain.eth.deployers import StakingEscrowDeployer
@ -50,6 +51,9 @@ from constant_sorrow.constants import INIT
def token_airdrop(token_agent, amount: NU, origin: str, addresses: List[str]):
"""Airdrops tokens from creator address to all other addresses!"""
signer = Web3Signer(token_agent.blockchain.client)
signer.unlock_account(account=origin, password=INSECURE_DEVELOPMENT_PASSWORD)
def txs():
args = {'from': origin, 'gasPrice': token_agent.blockchain.client.gas_price}
for address in addresses:
@ -222,13 +226,11 @@ class TesterBlockchain(BlockchainDeployerInterface):
testerchain = cls()
if not BlockchainInterfaceFactory.is_interface_initialized(provider_uri=testerchain.provider_uri):
BlockchainInterfaceFactory.register_interface(interface=testerchain)
power = TransactingPower(password=INSECURE_DEVELOPMENT_PASSWORD, account=testerchain.etherbase_account)
power.activate()
testerchain.transacting_power = power
origin = testerchain.client.etherbase
admin = ContractAdministrator(deployer_address=origin,
registry=registry,
signer=Web3Signer(testerchain.client),
economics=economics or cls.DEFAULT_ECONOMICS)
gas_limit = None # TODO: Gas management - #842