Make accomodations for geth managed wallets (#1117) in TransactingPower.

pull/1092/head
Kieran Prasch 2019-07-11 13:13:03 -07:00
parent be4661ec1f
commit 118262a9f4
No known key found for this signature in database
GPG Key ID: 199AB839D4125A62
20 changed files with 179 additions and 131 deletions

View File

@ -26,7 +26,6 @@ import maya
from constant_sorrow.constants import ( from constant_sorrow.constants import (
CONTRACT_NOT_DEPLOYED, CONTRACT_NOT_DEPLOYED,
NO_DEPLOYER_ADDRESS, NO_DEPLOYER_ADDRESS,
NO_STAKING_DEVICE,
WORKER_NOT_RUNNING WORKER_NOT_RUNNING
) )
from eth_tester.exceptions import TransactionFailed from eth_tester.exceptions import TransactionFailed
@ -141,7 +140,6 @@ class Deployer(NucypherTokenActor):
def __init__(self, def __init__(self,
blockchain: BlockchainInterface, blockchain: BlockchainInterface,
deployer_address: str = None, deployer_address: str = None,
device = NO_STAKING_DEVICE,
client_password: str = None, client_password: str = None,
bare: bool = True bare: bool = True
) -> None: ) -> None:
@ -162,8 +160,7 @@ class Deployer(NucypherTokenActor):
blockchain.transacting_power = TransactingPower(blockchain=blockchain, blockchain.transacting_power = TransactingPower(blockchain=blockchain,
account=deployer_address, account=deployer_address,
password=client_password, password=client_password)
device=device)
blockchain.transacting_power.activate() blockchain.transacting_power.activate()
self.log = Logger("Deployment-Actor") self.log = Logger("Deployment-Actor")

View File

@ -80,6 +80,7 @@ class Character(Learner):
keyring_root: str = None, keyring_root: str = None,
crypto_power: CryptoPower = None, crypto_power: CryptoPower = None,
crypto_power_ups: List[CryptoPowerUp] = None, crypto_power_ups: List[CryptoPowerUp] = None,
additional_powers: List[CryptoPower] = None,
*args, **kwargs *args, **kwargs
) -> None: ) -> None:

View File

@ -28,8 +28,7 @@ import requests
from bytestring_splitter import BytestringKwargifier, BytestringSplittingError from bytestring_splitter import BytestringKwargifier, BytestringSplittingError
from bytestring_splitter import BytestringSplitter, VariableLengthBytestring from bytestring_splitter import BytestringSplitter, VariableLengthBytestring
from constant_sorrow import constants from constant_sorrow import constants
from constant_sorrow.constants import INCLUDED_IN_BYTESTRING, PUBLIC_ONLY, FEDERATED_POLICY, STRANGER_ALICE, \ from constant_sorrow.constants import INCLUDED_IN_BYTESTRING, PUBLIC_ONLY, FEDERATED_POLICY, STRANGER_ALICE
NO_STAKING_DEVICE
from cryptography.hazmat.backends import default_backend from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurve from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurve
from cryptography.hazmat.primitives.serialization import Encoding from cryptography.hazmat.primitives.serialization import Encoding
@ -90,7 +89,6 @@ class Alice(Character, PolicyAuthor):
network_middleware=None, network_middleware=None,
controller=True, controller=True,
policy_agent=None, policy_agent=None,
device = NO_STAKING_DEVICE,
client_password: str = None, client_password: str = None,
*args, **kwargs) -> None: *args, **kwargs) -> None:
@ -122,9 +120,9 @@ class Alice(Character, PolicyAuthor):
if is_me and not federated_only: # TODO: #289 if is_me and not federated_only: # TODO: #289
transacting_power = TransactingPower(account=self.checksum_address, transacting_power = TransactingPower(account=self.checksum_address,
device=device, password=client_password,
blockchain=self.blockchain) blockchain=self.blockchain)
self._crypto_power.consume_power_up(transacting_power, password=client_password) self._crypto_power.consume_power_up(transacting_power)
PolicyAuthor.__init__(self, PolicyAuthor.__init__(self,
blockchain=self.blockchain, blockchain=self.blockchain,
@ -844,8 +842,6 @@ class Ursula(Teacher, Character, Worker):
checksum_address: str = None, # Staker address checksum_address: str = None, # Staker address
worker_address: str = None, worker_address: str = None,
stake_tracker: StakeTracker = None, stake_tracker: StakeTracker = None,
staking_agent: StakingEscrowAgent = None,
device = NO_STAKING_DEVICE,
client_password: str = None, client_password: str = None,
# Character # Character
@ -895,8 +891,10 @@ class Ursula(Teacher, Character, Worker):
if not federated_only: if not federated_only:
# Access staking node via node's transacting keys # Access staking node via node's transacting keys
transacting_power = TransactingPower(account=worker_address, device=device, blockchain=self.blockchain) transacting_power = TransactingPower(account=worker_address,
self._crypto_power.consume_power_up(transacting_power, client_password) password=client_password,
blockchain=self.blockchain)
self._crypto_power.consume_power_up(transacting_power)
# Use blockchain power to substantiate stamp # Use blockchain power to substantiate stamp
self.substantiate_stamp(client_password=password) self.substantiate_stamp(client_password=password)

View File

@ -1,12 +1,15 @@
import click import click
from constant_sorrow.constants import NO_BLOCKCHAIN_CONNECTION from constant_sorrow.constants import NO_BLOCKCHAIN_CONNECTION
from nucypher.blockchain.eth.interfaces import BlockchainInterface
from nucypher.blockchain.eth.registry import EthereumContractRegistry
from nucypher.characters.banners import ALICE_BANNER from nucypher.characters.banners import ALICE_BANNER
from nucypher.cli import actions, painting, types from nucypher.cli import actions, painting, types
from nucypher.cli.actions import get_password from nucypher.cli.actions import get_password
from nucypher.cli.config import nucypher_click_config from nucypher.cli.config import nucypher_click_config
from nucypher.cli.types import NETWORK_PORT, EXISTING_READABLE_FILE, EIP55_CHECKSUM_ADDRESS from nucypher.cli.types import NETWORK_PORT, EXISTING_READABLE_FILE, EIP55_CHECKSUM_ADDRESS
from nucypher.config.characters import AliceConfiguration from nucypher.config.characters import AliceConfiguration
from nucypher.crypto.powers import TransactingPower
@click.command() @click.command()
@ -24,6 +27,7 @@ from nucypher.config.characters import AliceConfiguration
@click.option('--config-file', help="Path to configuration file", type=EXISTING_READABLE_FILE) @click.option('--config-file', help="Path to configuration file", type=EXISTING_READABLE_FILE)
@click.option('--provider-uri', help="Blockchain provider's URI", type=click.STRING) @click.option('--provider-uri', help="Blockchain provider's URI", type=click.STRING)
@click.option('--sync/--no-sync', default=True) @click.option('--sync/--no-sync', default=True)
@click.option('--device/--no-device', default=False)
@click.option('--geth', '-G', help="Run using the built-in geth node", is_flag=True) @click.option('--geth', '-G', help="Run using the built-in geth node", is_flag=True)
@click.option('--poa', help="Inject POA middleware", is_flag=True, default=None) @click.option('--poa', help="Inject POA middleware", is_flag=True, default=None)
@click.option('--no-registry', help="Skip importing the default contract registry", is_flag=True) @click.option('--no-registry', help="Skip importing the default contract registry", is_flag=True)
@ -68,6 +72,7 @@ def alice(click_config,
poa, poa,
no_registry, no_registry,
registry_filepath, registry_filepath,
device,
# Alice # Alice
bob_encrypting_key, bob_encrypting_key,
@ -79,7 +84,7 @@ def alice(click_config,
rate, rate,
duration, duration,
expiration, expiration,
message_kit message_kit,
): ):
@ -168,7 +173,7 @@ def alice(click_config,
except FileNotFoundError: except FileNotFoundError:
return actions.handle_missing_configuration_file(character_config_class=AliceConfiguration, return actions.handle_missing_configuration_file(character_config_class=AliceConfiguration,
config_file=config_file) config_file=config_file)
ALICE = actions.make_cli_character(character_config=alice_config, ALICE = actions.make_cli_character(character_config=alice_config,
click_config=click_config, click_config=click_config,
dev=dev, dev=dev,

View File

@ -11,6 +11,7 @@ from nucypher.cli.config import nucypher_click_config
from nucypher.cli.types import NETWORK_PORT, EXISTING_READABLE_FILE, EIP55_CHECKSUM_ADDRESS from nucypher.cli.types import NETWORK_PORT, EXISTING_READABLE_FILE, EIP55_CHECKSUM_ADDRESS
from nucypher.config.characters import FelixConfiguration from nucypher.config.characters import FelixConfiguration
from nucypher.config.constants import DEFAULT_CONFIG_ROOT from nucypher.config.constants import DEFAULT_CONFIG_ROOT
from nucypher.crypto.powers import TransactingPower
@click.command() @click.command()
@ -118,6 +119,11 @@ def felix(click_config,
f"Check the filepath or run 'nucypher felix init' to create a new system configuration.") f"Check the filepath or run 'nucypher felix init' to create a new system configuration.")
raise click.Abort raise click.Abort
transacting_power = TransactingPower(account=felix_config.checksum_address,
device=False,
password=get_password(confirm=False),
blockchain=felix_config.blockchain)
try: try:
# Connect to Blockchain # Connect to Blockchain
@ -134,7 +140,9 @@ def felix(click_config,
network_middleware=click_config.middleware) network_middleware=click_config.middleware)
# Produce Felix # Produce Felix
FELIX = felix_config.produce(domains=network, known_nodes=teacher_nodes) FELIX = felix_config.produce(domains=network,
known_nodes=teacher_nodes,
additional_power=[transacting_power])
FELIX.make_web_app() # attach web application, but dont start service FELIX.make_web_app() # attach web application, but dont start service
except Exception as e: except Exception as e:

View File

@ -18,16 +18,13 @@ along with nucypher. If not, see <https://www.gnu.org/licenses/>.
import click import click
import socket
from constant_sorrow.constants import NO_BLOCKCHAIN_CONNECTION from constant_sorrow.constants import NO_BLOCKCHAIN_CONNECTION
from twisted.internet import stdio from twisted.internet import stdio
from nucypher.blockchain.eth.clients import NuCypherGethDevnetProcess, NuCypherGethGoerliProcess
from nucypher.blockchain.eth.token import NU from nucypher.blockchain.eth.token import NU
from nucypher.characters.banners import URSULA_BANNER from nucypher.characters.banners import URSULA_BANNER
from nucypher.cli import actions, painting from nucypher.cli import actions, painting
from nucypher.cli.actions import UnknownIPAddress, get_password from nucypher.cli.actions import get_password
from nucypher.cli.config import nucypher_click_config from nucypher.cli.config import nucypher_click_config
from nucypher.cli.processes import UrsulaCommandProtocol from nucypher.cli.processes import UrsulaCommandProtocol
from nucypher.cli.types import ( from nucypher.cli.types import (
@ -36,8 +33,7 @@ from nucypher.cli.types import (
EXISTING_READABLE_FILE, EXISTING_READABLE_FILE,
STAKE_DURATION, STAKE_DURATION,
STAKE_EXTENSION, STAKE_EXTENSION,
STAKE_VALUE, STAKE_VALUE)
IPV4_ADDRESS)
from nucypher.config.characters import UrsulaConfiguration from nucypher.config.characters import UrsulaConfiguration
from nucypher.utilities.sandbox.constants import ( from nucypher.utilities.sandbox.constants import (
TEMPORARY_DOMAIN, TEMPORARY_DOMAIN,
@ -66,6 +62,7 @@ from nucypher.utilities.sandbox.constants import (
@click.option('--config-file', help="Path to configuration file", type=EXISTING_READABLE_FILE) @click.option('--config-file', help="Path to configuration file", type=EXISTING_READABLE_FILE)
@click.option('--poa', help="Inject POA middleware", is_flag=True, default=None) @click.option('--poa', help="Inject POA middleware", is_flag=True, default=None)
@click.option('--sync/--no-sync', default=True) @click.option('--sync/--no-sync', default=True)
@click.option('--device/--no-device', default=False)
@click.option('--geth', '-G', help="Run using the built-in geth node", is_flag=True) @click.option('--geth', '-G', help="Run using the built-in geth node", is_flag=True)
@click.option('--provider-uri', help="Blockchain provider's URI", type=click.STRING) @click.option('--provider-uri', help="Blockchain provider's URI", type=click.STRING)
@click.option('--no-registry', help="Skip importing the default contract registry", is_flag=True) @click.option('--no-registry', help="Skip importing the default contract registry", is_flag=True)
@ -105,6 +102,7 @@ def ursula(click_config,
list_, list_,
divide, divide,
sync, sync,
device,
interactive, interactive,
) -> None: ) -> None:
@ -244,7 +242,6 @@ def ursula(click_config,
raise click.BadOptionUsage(option_name='--dev', message=message) raise click.BadOptionUsage(option_name='--dev', message=message)
return actions.destroy_configuration(character_config=ursula_config, force=force) return actions.destroy_configuration(character_config=ursula_config, force=force)
# #
# Make Ursula # Make Ursula
# #

View File

@ -19,7 +19,6 @@ import time
import click import click
import maya import maya
from constant_sorrow.constants import NO_STAKING_DEVICE
from nucypher.blockchain.eth.actors import Deployer from nucypher.blockchain.eth.actors import Deployer
from nucypher.blockchain.eth.agents import NucypherTokenAgent from nucypher.blockchain.eth.agents import NucypherTokenAgent
@ -42,6 +41,7 @@ from nucypher.config.constants import DEFAULT_CONFIG_ROOT
@click.option('--provider-uri', help="Blockchain provider's URI", type=click.STRING) @click.option('--provider-uri', help="Blockchain provider's URI", type=click.STRING)
@click.option('--geth', '-G', help="Run using the built-in geth node", is_flag=True) @click.option('--geth', '-G', help="Run using the built-in geth node", is_flag=True)
@click.option('--sync/--no-sync', default=True) @click.option('--sync/--no-sync', default=True)
@click.option('--device/--no-device', default=True)
@click.option('--enode', help="An ethereum bootnode enode address to start learning from", type=click.STRING) @click.option('--enode', help="An ethereum bootnode enode address to start learning from", type=click.STRING)
@click.option('--config-root', help="Custom configuration directory", type=click.Path()) @click.option('--config-root', help="Custom configuration directory", type=click.Path())
@click.option('--contract-name', help="Deploy a single contract by name", type=click.STRING) @click.option('--contract-name', help="Deploy a single contract by name", type=click.STRING)
@ -70,6 +70,7 @@ def deploy(click_config,
recipient_address, recipient_address,
config_root, config_root,
sync, sync,
device,
force): force):
"""Manage contract and registry deployment""" """Manage contract and registry deployment"""
@ -100,7 +101,6 @@ def deploy(click_config,
if registry_filepath is not None: if registry_filepath is not None:
registry = EthereumContractRegistry(registry_filepath=registry_filepath) registry = EthereumContractRegistry(registry_filepath=registry_filepath)
# TODO: Move to Deployer with TransactingPower
# Deployment-tuned blockchain connection # Deployment-tuned blockchain connection
blockchain = BlockchainDeployerInterface(provider_uri=provider_uri, blockchain = BlockchainDeployerInterface(provider_uri=provider_uri,
poa=poa, poa=poa,
@ -124,9 +124,12 @@ def deploy(click_config,
if not force: if not force:
click.confirm("Selected {} - Continue?".format(deployer_address), abort=True) click.confirm("Selected {} - Continue?".format(deployer_address), abort=True)
password = None
if not device:
password = get_password(confirm=False)
deployer = Deployer(blockchain=blockchain, deployer = Deployer(blockchain=blockchain,
device=NO_STAKING_DEVICE, client_password=password,
client_password=get_password(confirm=False),
deployer_address=deployer_address) deployer_address=deployer_address)
# Verify ETH Balance # Verify ETH Balance

View File

@ -19,7 +19,7 @@ along with nucypher. If not, see <https://www.gnu.org/licenses/>.
import inspect import inspect
from typing import List, Tuple, Optional from typing import List, Tuple, Optional
from constant_sorrow.constants import NO_STAKING_DEVICE, NO_BLOCKCHAIN_CONNECTION from constant_sorrow.constants import NO_BLOCKCHAIN_CONNECTION
from cytoolz.dicttoolz import dissoc from cytoolz.dicttoolz import dissoc
from eth_account._utils.transactions import assert_valid_fields from eth_account._utils.transactions import assert_valid_fields
from hexbytes import HexBytes from hexbytes import HexBytes
@ -116,25 +116,18 @@ class TransactingPower(CryptoPowerUp):
def __init__(self, def __init__(self,
blockchain, blockchain,
account: str, account: str,
password: str = None, password: str = None):
device=NO_STAKING_DEVICE):
""" """
Instantiates a TransactingPower for the given checksum_address. Instantiates a TransactingPower for the given checksum_address.
""" """
if password and (device is not NO_STAKING_DEVICE):
raise ValueError(f"Cannot create a {self.__class__.__name__} with both a client and an device signer.")
self.blockchain = blockchain self.blockchain = blockchain
if blockchain.is_connected: if blockchain.is_connected:
self.client = blockchain.client self.client = blockchain.client
else: else:
self.client = NO_BLOCKCHAIN_CONNECTION self.client = NO_BLOCKCHAIN_CONNECTION
self.account = account self.account = account
self.device = device self.device = True if not password else False
self.__activated = False
self.__password = password self.__password = password
self.__unlocked = False self.__unlocked = False
@ -157,30 +150,22 @@ class TransactingPower(CryptoPowerUp):
self.unlock_account(password=password) # Unlock self.unlock_account(password=password) # Unlock
self.blockchain.transacting_power = self # Attach self.blockchain.transacting_power = self # Attach
self.__password = None # Discard self.__password = None # Discard
self.__activated = True # Remember
def lock_account(self): def lock_account(self):
if self.device is not NO_STAKING_DEVICE: if self.device:
# TODO: Implement TrustedDevice # TODO: Force Disconnect Devices
_result = self.device.lock() pass
else: else:
_result = self.client.lock_account(address=self.account) _result = self.client.lock_account(address=self.account)
self.__unlocked = False self.__unlocked = False
def unlock_account(self, password: str = None): def unlock_account(self, password: str = None):
if self.device is not NO_STAKING_DEVICE: if self.device:
# TODO: Embed in TrustedDevice
ping = 'PING|PONG'
pong = self.device.client.ping(ping)
if not ping == pong:
raise self.device.NoDeviceDetected
unlocked = True unlocked = True
else: else:
if self.client is NO_BLOCKCHAIN_CONNECTION: if self.client is NO_BLOCKCHAIN_CONNECTION:
raise self.NoBlockchainConnection raise self.NoBlockchainConnection
unlocked = self.client.unlock_account(address=self.account, password=password) unlocked = self.client.unlock_account(address=self.account, password=password)
self.__unlocked = unlocked self.__unlocked = unlocked
def sign_message(self, message: bytes) -> bytes: def sign_message(self, message: bytes) -> bytes:
@ -189,16 +174,7 @@ class TransactingPower(CryptoPowerUp):
""" """
if not self.is_unlocked: if not self.is_unlocked:
raise self.AccountLocked("Failed to unlock account {}".format(self.account)) raise self.AccountLocked("Failed to unlock account {}".format(self.account))
signature = self.client.sign_message(account=self.account, message=message)
# Hardware Wallet
if self.device is not NO_STAKING_DEVICE:
# TODO: Use a common message signature type from clients and devices
signature = self.device.sign_message(checksum_address=self.account, message=message)
signature = signature.signature
# Software Wallet
else:
signature = self.client.sign_message(account=self.account, message=message)
return signature return signature
def sign_transaction(self, unsigned_transaction: dict) -> HexBytes: def sign_transaction(self, unsigned_transaction: dict) -> HexBytes:
@ -219,15 +195,8 @@ class TransactingPower(CryptoPowerUp):
except TypeError as e: except TypeError as e:
raise self.InvalidSigningRequest(f"Invalid Transaction: '{str(e)}'") raise self.InvalidSigningRequest(f"Invalid Transaction: '{str(e)}'")
# HW Signer signed_raw_transaction = self.blockchain.client.sign_transaction(transaction=unsigned_transaction,
if self.device is not NO_STAKING_DEVICE: account=self.account)
# TODO: Use a common tx_sign return type from clients and devices
signed_raw_transaction = self.device.sign_eth_transaction(unsigned_transaction=unsigned_transaction,
checksum_address=self.account)
# Web3 Signer
else:
signed_raw_transaction = self.blockchain.client.sign_transaction(transaction=unsigned_transaction,
account=self.account)
return signed_raw_transaction return signed_raw_transaction

View File

@ -213,8 +213,10 @@ class TesterBlockchain(BlockchainDeployerInterface):
"""For use with metric testing scripts""" """For use with metric testing scripts"""
testerchain = cls(compiler=SolidityCompiler()) testerchain = cls(compiler=SolidityCompiler())
power = TransactingPower(blockchain=testerchain, account=testerchain.etherbase_account) power = TransactingPower(blockchain=testerchain,
power.activate(password=INSECURE_DEVELOPMENT_PASSWORD) password=INSECURE_DEVELOPMENT_PASSWORD,
account=testerchain.etherbase_account)
power.activate()
testerchain.transacting_power = power testerchain.transacting_power = power
origin = testerchain.client.etherbase origin = testerchain.client.etherbase

View File

@ -23,11 +23,12 @@ from nucypher.blockchain.eth.interfaces import BlockchainInterface
from nucypher.blockchain.eth.token import StakeTracker from nucypher.blockchain.eth.token import StakeTracker
from nucypher.characters.lawful import Ursula from nucypher.characters.lawful import Ursula
from nucypher.config.characters import UrsulaConfiguration from nucypher.config.characters import UrsulaConfiguration
from nucypher.crypto.powers import TransactingPower
from nucypher.utilities.sandbox.constants import ( from nucypher.utilities.sandbox.constants import (
MOCK_KNOWN_URSULAS_CACHE, MOCK_KNOWN_URSULAS_CACHE,
MOCK_URSULA_STARTING_PORT, MOCK_URSULA_STARTING_PORT,
NUMBER_OF_URSULAS_IN_DEVELOPMENT_NETWORK, NUMBER_OF_URSULAS_IN_DEVELOPMENT_NETWORK,
MOCK_URSULA_DB_FILEPATH) MOCK_URSULA_DB_FILEPATH, INSECURE_DEVELOPMENT_PASSWORD)
def make_federated_ursulas(ursula_config: UrsulaConfiguration, def make_federated_ursulas(ursula_config: UrsulaConfiguration,

View File

@ -22,12 +22,15 @@ from web3.contract import Contract
from nucypher.blockchain.eth.deployers import DispatcherDeployer from nucypher.blockchain.eth.deployers import DispatcherDeployer
from nucypher.crypto.powers import TransactingPower from nucypher.crypto.powers import TransactingPower
from nucypher.utilities.sandbox.constants import INSECURE_DEVELOPMENT_PASSWORD
@pytest.fixture() @pytest.fixture()
def escrow(testerchain): def escrow(testerchain):
# Mock Powerup consumption (Deployer) # Mock Powerup consumption (Deployer)
testerchain.transacting_power = TransactingPower(blockchain=testerchain, account=testerchain.etherbase_account) testerchain.transacting_power = TransactingPower(blockchain=testerchain,
password=INSECURE_DEVELOPMENT_PASSWORD,
account=testerchain.etherbase_account)
testerchain.transacting_power.activate() testerchain.transacting_power.activate()
escrow, _ = testerchain.deploy_contract('StakingEscrowForAdjudicatorMock') escrow, _ = testerchain.deploy_contract('StakingEscrowForAdjudicatorMock')
return escrow return escrow

View File

@ -48,8 +48,10 @@ def test_rapid_deployment(token_economics):
compiler=compiler) compiler=compiler)
# TODO: #1092 - TransactingPower # TODO: #1092 - TransactingPower
blockchain.transacting_power = TransactingPower(blockchain=blockchain, account=blockchain.etherbase_account) blockchain.transacting_power = TransactingPower(blockchain=blockchain,
blockchain.transacting_power.activate(password=INSECURE_DEVELOPMENT_PASSWORD) password=INSECURE_DEVELOPMENT_PASSWORD,
account=blockchain.etherbase_account)
blockchain.transacting_power.activate()
deployer_address = blockchain.etherbase_account deployer_address = blockchain.etherbase_account
deployer = Deployer(blockchain=blockchain, deployer_address=deployer_address) deployer = Deployer(blockchain=blockchain, deployer_address=deployer_address)

View File

@ -43,8 +43,10 @@ def test_staker_locking_tokens(testerchain, agency, staker, token_economics):
token_agent, staking_agent, policy_agent = agency token_agent, staking_agent, policy_agent = agency
# Mock Powerup consumption (Ursula-Staker) # Mock Powerup consumption (Ursula-Staker)
testerchain.transacting_power = TransactingPower(blockchain=testerchain, account=staker.checksum_address) testerchain.transacting_power = TransactingPower(blockchain=testerchain,
testerchain.transacting_power.activate(password=INSECURE_DEVELOPMENT_PASSWORD) password=INSECURE_DEVELOPMENT_PASSWORD,
account=staker.checksum_address)
testerchain.transacting_power.activate()
assert NU(token_economics.minimum_allowed_locked, 'NuNit') < staker.token_balance, "Insufficient staker balance" assert NU(token_economics.minimum_allowed_locked, 'NuNit') < staker.token_balance, "Insufficient staker balance"
@ -108,8 +110,10 @@ def test_staker_collects_staking_reward(testerchain, staker, blockchain_ursulas,
assert token_agent.get_balance(staker.checksum_address) == initial_balance assert token_agent.get_balance(staker.checksum_address) == initial_balance
# Mock Powerup consumption (Ursula-Worker) # Mock Powerup consumption (Ursula-Worker)
testerchain.transacting_power = TransactingPower(blockchain=testerchain, account=staker.checksum_address) testerchain.transacting_power = TransactingPower(blockchain=testerchain,
testerchain.transacting_power.activate(password=INSECURE_DEVELOPMENT_PASSWORD) password=INSECURE_DEVELOPMENT_PASSWORD,
account=staker.checksum_address)
testerchain.transacting_power.activate()
staker.initialize_stake(amount=NU(token_economics.minimum_allowed_locked, 'NuNit'), # Lock the minimum amount of tokens staker.initialize_stake(amount=NU(token_economics.minimum_allowed_locked, 'NuNit'), # Lock the minimum amount of tokens
lock_periods=int(token_economics.minimum_locked_periods)) # ... for the fewest number of periods lock_periods=int(token_economics.minimum_locked_periods)) # ... for the fewest number of periods
@ -134,8 +138,10 @@ def test_staker_collects_staking_reward(testerchain, staker, blockchain_ursulas,
testerchain.time_travel(periods=2) testerchain.time_travel(periods=2)
# Mock Powerup consumption (Ursula-Worker) # Mock Powerup consumption (Ursula-Worker)
testerchain.transacting_power = TransactingPower(blockchain=testerchain, account=staker.checksum_address) testerchain.transacting_power = TransactingPower(blockchain=testerchain,
testerchain.transacting_power.activate(password=INSECURE_DEVELOPMENT_PASSWORD) password=INSECURE_DEVELOPMENT_PASSWORD,
account=staker.checksum_address)
testerchain.transacting_power.activate()
# Profit! # Profit!
staker.collect_staking_reward() staker.collect_staking_reward()

View File

@ -59,7 +59,9 @@ def test_adjudicator_slashes(agency,
locked_tokens = token_economics.minimum_allowed_locked * 5 locked_tokens = token_economics.minimum_allowed_locked * 5
# Mock Powerup consumption (Deployer) # Mock Powerup consumption (Deployer)
testerchain.transacting_power = TransactingPower(blockchain=testerchain, account=testerchain.etherbase_account) testerchain.transacting_power = TransactingPower(blockchain=testerchain,
password=INSECURE_DEVELOPMENT_PASSWORD,
account=testerchain.etherbase_account)
testerchain.transacting_power.activate() testerchain.transacting_power.activate()
# The staker receives an initial amount of tokens # The staker receives an initial amount of tokens
@ -68,7 +70,9 @@ def test_adjudicator_slashes(agency,
sender_address=testerchain.etherbase_account) sender_address=testerchain.etherbase_account)
# Mock Powerup consumption (Staker) # Mock Powerup consumption (Staker)
testerchain.transacting_power = TransactingPower(blockchain=testerchain, account=staker_account) testerchain.transacting_power = TransactingPower(blockchain=testerchain,
password=INSECURE_DEVELOPMENT_PASSWORD,
account=staker_account)
testerchain.transacting_power.activate() testerchain.transacting_power.activate()
# Deposit: The staker deposits tokens in the StakingEscrow contract. # Deposit: The staker deposits tokens in the StakingEscrow contract.
@ -100,7 +104,9 @@ def test_adjudicator_slashes(agency,
bobby_old_balance = bobby.token_balance bobby_old_balance = bobby.token_balance
# Mock Powerup consumption (Bob) # Mock Powerup consumption (Bob)
testerchain.transacting_power = TransactingPower(blockchain=testerchain, account=bob_account) testerchain.transacting_power = TransactingPower(blockchain=testerchain,
password=INSECURE_DEVELOPMENT_PASSWORD,
account=bob_account)
testerchain.transacting_power.activate() testerchain.transacting_power.activate()
adjudicator_agent.evaluate_cfrag(evidence=evidence, sender_address=bob_account) adjudicator_agent.evaluate_cfrag(evidence=evidence, sender_address=bob_account)

View File

@ -51,8 +51,10 @@ def test_create_policy(testerchain, agency, token_economics):
agent = policy_agent agent = policy_agent
# Mock Powerup consumption # Mock Powerup consumption
testerchain.transacting_power = TransactingPower(blockchain=testerchain, account=testerchain.alice_account) testerchain.transacting_power = TransactingPower(blockchain=testerchain,
testerchain.transacting_power.activate(password=INSECURE_DEVELOPMENT_PASSWORD) password=INSECURE_DEVELOPMENT_PASSWORD,
account=testerchain.alice_account)
testerchain.transacting_power.activate()
policy_id = os.urandom(16) policy_id = os.urandom(16)
node_addresses = list(staking_agent.sample(quantity=3, duration=1)) node_addresses = list(staking_agent.sample(quantity=3, duration=1))
@ -113,15 +115,19 @@ def test_calculate_refund(testerchain, agency, policy_meta):
worker = staking_agent.get_worker_from_staker(staker) worker = staking_agent.get_worker_from_staker(staker)
# Mock Powerup consumption (Ursula-Worker) # Mock Powerup consumption (Ursula-Worker)
testerchain.transacting_power = TransactingPower(blockchain=testerchain, account=worker) testerchain.transacting_power = TransactingPower(blockchain=testerchain,
testerchain.transacting_power.activate(password=INSECURE_DEVELOPMENT_PASSWORD) password=INSECURE_DEVELOPMENT_PASSWORD,
account=worker)
testerchain.transacting_power.activate()
testerchain.time_travel(hours=9) testerchain.time_travel(hours=9)
_receipt = staking_agent.confirm_activity(worker_address=worker) _receipt = staking_agent.confirm_activity(worker_address=worker)
# Mock Powerup consumption (Alice) # Mock Powerup consumption (Alice)
testerchain.transacting_power = TransactingPower(blockchain=testerchain, account=testerchain.alice_account) testerchain.transacting_power = TransactingPower(blockchain=testerchain,
testerchain.transacting_power.activate(password=INSECURE_DEVELOPMENT_PASSWORD) password=INSECURE_DEVELOPMENT_PASSWORD,
account=testerchain.alice_account)
testerchain.transacting_power.activate()
receipt = agent.calculate_refund(policy_id=policy_meta.policy_id, author_address=policy_meta.author) receipt = agent.calculate_refund(policy_id=policy_meta.policy_id, author_address=policy_meta.author)
assert receipt['status'] == 1, "Transaction Rejected" assert receipt['status'] == 1, "Transaction Rejected"
@ -148,8 +154,10 @@ def test_collect_policy_reward(testerchain, agency, policy_meta, token_economics
worker = staking_agent.get_worker_from_staker(staker) worker = staking_agent.get_worker_from_staker(staker)
# Mock Powerup consumption (Ursula-Worker) # Mock Powerup consumption (Ursula-Worker)
testerchain.transacting_power = TransactingPower(blockchain=testerchain, account=worker) testerchain.transacting_power = TransactingPower(blockchain=testerchain,
testerchain.transacting_power.activate(password=INSECURE_DEVELOPMENT_PASSWORD) password=INSECURE_DEVELOPMENT_PASSWORD,
account=worker)
testerchain.transacting_power.activate()
old_eth_balance = token_agent.blockchain.client.get_balance(staker) old_eth_balance = token_agent.blockchain.client.get_balance(staker)
@ -158,8 +166,10 @@ def test_collect_policy_reward(testerchain, agency, policy_meta, token_economics
testerchain.time_travel(periods=1) testerchain.time_travel(periods=1)
# Mock Powerup consumption (Ursula-Staker) # Mock Powerup consumption (Ursula-Staker)
testerchain.transacting_power = TransactingPower(blockchain=testerchain, account=staker) testerchain.transacting_power = TransactingPower(blockchain=testerchain,
testerchain.transacting_power.activate(password=INSECURE_DEVELOPMENT_PASSWORD) password=INSECURE_DEVELOPMENT_PASSWORD,
account=staker)
testerchain.transacting_power.activate()
receipt = agent.collect_policy_reward(collector_address=staker, staker_address=staker) receipt = agent.collect_policy_reward(collector_address=staker, staker_address=staker)
assert receipt['status'] == 1, "Transaction Rejected" assert receipt['status'] == 1, "Transaction Rejected"

View File

@ -35,8 +35,10 @@ def test_deposit_tokens(testerchain, agency, token_economics):
staker_account = testerchain.unassigned_accounts[0] staker_account = testerchain.unassigned_accounts[0]
# Mock Powerup consumption (Deployer) # Mock Powerup consumption (Deployer)
testerchain.transacting_power = TransactingPower(blockchain=testerchain, account=testerchain.etherbase_account) testerchain.transacting_power = TransactingPower(blockchain=testerchain,
testerchain.transacting_power.activate(password=INSECURE_DEVELOPMENT_PASSWORD) password=INSECURE_DEVELOPMENT_PASSWORD,
account=testerchain.etherbase_account)
testerchain.transacting_power.activate()
balance = token_agent.get_balance(address=staker_account) balance = token_agent.get_balance(address=staker_account)
assert balance == 0 assert balance == 0
@ -47,8 +49,10 @@ def test_deposit_tokens(testerchain, agency, token_economics):
sender_address=testerchain.etherbase_account) sender_address=testerchain.etherbase_account)
# Mock Powerup consumption (Ursula-Staker) # Mock Powerup consumption (Ursula-Staker)
testerchain.transacting_power = TransactingPower(blockchain=testerchain, account=staker_account) testerchain.transacting_power = TransactingPower(blockchain=testerchain,
testerchain.transacting_power.activate(password=INSECURE_DEVELOPMENT_PASSWORD) password=INSECURE_DEVELOPMENT_PASSWORD,
account=staker_account)
testerchain.transacting_power.activate()
# #
# Deposit: The staker deposits tokens in the StakingEscrow contract. # Deposit: The staker deposits tokens in the StakingEscrow contract.
@ -168,8 +172,10 @@ def test_confirm_activity(agency, testerchain):
staker_account, worker_account, *other = testerchain.unassigned_accounts staker_account, worker_account, *other = testerchain.unassigned_accounts
# Mock Powerup consumption (Ursula-Worker) # Mock Powerup consumption (Ursula-Worker)
testerchain.transacting_power = TransactingPower(blockchain=testerchain, account=worker_account) testerchain.transacting_power = TransactingPower(blockchain=testerchain,
testerchain.transacting_power.activate(password=INSECURE_DEVELOPMENT_PASSWORD) password=INSECURE_DEVELOPMENT_PASSWORD,
account=worker_account)
testerchain.transacting_power.activate()
receipt = staking_agent.confirm_activity(worker_address=worker_account) receipt = staking_agent.confirm_activity(worker_address=worker_account)
assert receipt['status'] == 1, "Transaction Rejected" assert receipt['status'] == 1, "Transaction Rejected"
@ -223,8 +229,10 @@ def test_collect_staking_reward(agency, testerchain):
testerchain.time_travel(periods=2) testerchain.time_travel(periods=2)
# Mock Powerup consumption (Ursula-Staker) # Mock Powerup consumption (Ursula-Staker)
testerchain.transacting_power = TransactingPower(blockchain=testerchain, account=staker_account) testerchain.transacting_power = TransactingPower(blockchain=testerchain,
testerchain.transacting_power.activate(password=INSECURE_DEVELOPMENT_PASSWORD) password=INSECURE_DEVELOPMENT_PASSWORD,
account=staker_account)
testerchain.transacting_power.activate()
# Mint # Mint
_receipt = staking_agent.mint(staker_address=staker_account) _receipt = staking_agent.mint(staker_address=staker_account)

View File

@ -68,8 +68,10 @@ def test_approve_transfer(agent, token_economics):
deployer, someone, *everybody_else = testerchain.client.accounts deployer, someone, *everybody_else = testerchain.client.accounts
# Mock Powerup consumption # Mock Powerup consumption
testerchain.transacting_power = TransactingPower(blockchain=testerchain, account=someone) testerchain.transacting_power = TransactingPower(blockchain=testerchain,
testerchain.transacting_power.activate(password=INSECURE_DEVELOPMENT_PASSWORD) password=INSECURE_DEVELOPMENT_PASSWORD,
account=someone)
testerchain.transacting_power.activate()
# Approve # Approve
receipt = agent.approve_transfer(amount=token_economics.minimum_allowed_locked, receipt = agent.approve_transfer(amount=token_economics.minimum_allowed_locked,
@ -85,8 +87,10 @@ def test_transfer(agent, token_economics):
origin, someone, *everybody_else = testerchain.client.accounts origin, someone, *everybody_else = testerchain.client.accounts
# Mock Powerup consumption (Deployer) # Mock Powerup consumption (Deployer)
testerchain.transacting_power = TransactingPower(blockchain=testerchain, account=origin) testerchain.transacting_power = TransactingPower(blockchain=testerchain,
testerchain.transacting_power.activate(password=INSECURE_DEVELOPMENT_PASSWORD) password=INSECURE_DEVELOPMENT_PASSWORD,
account=origin)
testerchain.transacting_power.activate()
old_balance = agent.get_balance(someone) old_balance = agent.get_balance(someone)
receipt = agent.transfer(amount=token_economics.minimum_allowed_locked, receipt = agent.transfer(amount=token_economics.minimum_allowed_locked,

View File

@ -57,8 +57,10 @@ def agent(testerchain, proxy_deployer, allocation_value) -> UserEscrowAgent:
deployer_address, beneficiary_address, *everybody_else = testerchain.client.accounts deployer_address, beneficiary_address, *everybody_else = testerchain.client.accounts
# Mock Powerup consumption (Deployer) # Mock Powerup consumption (Deployer)
testerchain.transacting_power = TransactingPower(blockchain=testerchain, account=deployer_address) testerchain.transacting_power = TransactingPower(blockchain=testerchain,
testerchain.transacting_power.activate(password=INSECURE_DEVELOPMENT_PASSWORD) password=INSECURE_DEVELOPMENT_PASSWORD,
account=deployer_address)
testerchain.transacting_power.activate()
# Escrow # Escrow
escrow_deployer = UserEscrowDeployer(deployer_address=deployer_address, escrow_deployer = UserEscrowDeployer(deployer_address=deployer_address,
@ -143,8 +145,10 @@ def test_deposit_and_withdraw_as_staker(testerchain, agent, agency, allocation_v
assert token_agent.get_balance(address=agent.contract_address) == allocation_value assert token_agent.get_balance(address=agent.contract_address) == allocation_value
# Mock Powerup consumption (Beneficiary) # Mock Powerup consumption (Beneficiary)
testerchain.transacting_power = TransactingPower(blockchain=testerchain, account=agent.beneficiary) testerchain.transacting_power = TransactingPower(blockchain=testerchain,
testerchain.transacting_power.activate(password=INSECURE_DEVELOPMENT_PASSWORD) password=INSECURE_DEVELOPMENT_PASSWORD,
account=agent.beneficiary)
testerchain.transacting_power.activate()
# Move the tokens to the StakingEscrow # Move the tokens to the StakingEscrow
receipt = agent.deposit_as_staker(value=token_economics.minimum_allowed_locked, periods=token_economics.minimum_locked_periods) receipt = agent.deposit_as_staker(value=token_economics.minimum_allowed_locked, periods=token_economics.minimum_locked_periods)
@ -162,8 +166,10 @@ def test_deposit_and_withdraw_as_staker(testerchain, agent, agency, allocation_v
assert staking_agent.get_locked_tokens(staker_address=agent.contract_address, periods=token_economics.minimum_locked_periods+1) == 0 assert staking_agent.get_locked_tokens(staker_address=agent.contract_address, periods=token_economics.minimum_locked_periods+1) == 0
# Mock Powerup consumption (Beneficiary-Worker) # Mock Powerup consumption (Beneficiary-Worker)
testerchain.transacting_power = TransactingPower(blockchain=testerchain, account=worker) testerchain.transacting_power = TransactingPower(blockchain=testerchain,
testerchain.transacting_power.activate(password=INSECURE_DEVELOPMENT_PASSWORD) password=INSECURE_DEVELOPMENT_PASSWORD,
account=worker)
testerchain.transacting_power.activate()
for _ in range(token_economics.minimum_locked_periods): for _ in range(token_economics.minimum_locked_periods):
staking_agent.confirm_activity(worker_address=worker) staking_agent.confirm_activity(worker_address=worker)
@ -171,8 +177,10 @@ def test_deposit_and_withdraw_as_staker(testerchain, agent, agency, allocation_v
testerchain.time_travel(periods=1) testerchain.time_travel(periods=1)
# Mock Powerup consumption (Beneficiary) # Mock Powerup consumption (Beneficiary)
testerchain.transacting_power = TransactingPower(blockchain=testerchain, account=agent.beneficiary) testerchain.transacting_power = TransactingPower(blockchain=testerchain,
testerchain.transacting_power.activate(password=INSECURE_DEVELOPMENT_PASSWORD) password=INSECURE_DEVELOPMENT_PASSWORD,
account=agent.beneficiary)
testerchain.transacting_power.activate()
agent.mint() agent.mint()
@ -195,8 +203,10 @@ def test_collect_policy_reward(testerchain, agent, agency, token_economics):
deployer_address, beneficiary_address, author, ursula, *everybody_else = testerchain.client.accounts deployer_address, beneficiary_address, author, ursula, *everybody_else = testerchain.client.accounts
# Mock Powerup consumption (Beneficiary) # Mock Powerup consumption (Beneficiary)
testerchain.transacting_power = TransactingPower(blockchain=testerchain, account=agent.beneficiary) testerchain.transacting_power = TransactingPower(blockchain=testerchain,
testerchain.transacting_power.activate(password=INSECURE_DEVELOPMENT_PASSWORD) password=INSECURE_DEVELOPMENT_PASSWORD,
account=agent.beneficiary)
testerchain.transacting_power.activate()
_txhash = agent.deposit_as_staker(value=token_economics.minimum_allowed_locked, periods=token_economics.minimum_locked_periods) _txhash = agent.deposit_as_staker(value=token_economics.minimum_allowed_locked, periods=token_economics.minimum_locked_periods)
@ -207,8 +217,10 @@ def test_collect_policy_reward(testerchain, agent, agency, token_economics):
testerchain.time_travel(periods=1) testerchain.time_travel(periods=1)
# Mock Powerup consumption (Alice) # Mock Powerup consumption (Alice)
testerchain.transacting_power = TransactingPower(blockchain=testerchain, account=author) testerchain.transacting_power = TransactingPower(blockchain=testerchain,
testerchain.transacting_power.activate(password=INSECURE_DEVELOPMENT_PASSWORD) password=INSECURE_DEVELOPMENT_PASSWORD,
account=author)
testerchain.transacting_power.activate()
_txhash = policy_agent.create_policy(policy_id=os.urandom(16), _txhash = policy_agent.create_policy(policy_id=os.urandom(16),
author_address=author, author_address=author,
@ -218,8 +230,10 @@ def test_collect_policy_reward(testerchain, agent, agency, token_economics):
node_addresses=[agent.contract_address]) node_addresses=[agent.contract_address])
# Mock Powerup consumption (Beneficiary-Worker) # Mock Powerup consumption (Beneficiary-Worker)
testerchain.transacting_power = TransactingPower(blockchain=testerchain, account=worker) testerchain.transacting_power = TransactingPower(blockchain=testerchain,
testerchain.transacting_power.activate(password=INSECURE_DEVELOPMENT_PASSWORD) password=INSECURE_DEVELOPMENT_PASSWORD,
account=worker)
testerchain.transacting_power.activate()
_txhash = staking_agent.confirm_activity(worker_address=worker) _txhash = staking_agent.confirm_activity(worker_address=worker)
testerchain.time_travel(periods=2) testerchain.time_travel(periods=2)
@ -228,8 +242,10 @@ def test_collect_policy_reward(testerchain, agent, agency, token_economics):
old_balance = testerchain.client.get_balance(account=agent.beneficiary) old_balance = testerchain.client.get_balance(account=agent.beneficiary)
# Mock Powerup consumption (Beneficiary) # Mock Powerup consumption (Beneficiary)
testerchain.transacting_power = TransactingPower(blockchain=testerchain, account=agent.beneficiary) testerchain.transacting_power = TransactingPower(blockchain=testerchain,
testerchain.transacting_power.activate(password=INSECURE_DEVELOPMENT_PASSWORD) password=INSECURE_DEVELOPMENT_PASSWORD,
account=agent.beneficiary)
testerchain.transacting_power.activate()
txhash = agent.collect_policy_reward() txhash = agent.collect_policy_reward()
assert txhash # TODO assert txhash # TODO
@ -241,8 +257,10 @@ def test_withdraw_tokens(testerchain, agent, agency, allocation_value):
deployer_address, beneficiary_address, *everybody_else = testerchain.client.accounts deployer_address, beneficiary_address, *everybody_else = testerchain.client.accounts
# Mock Powerup consumption (Beneficiary) # Mock Powerup consumption (Beneficiary)
testerchain.transacting_power = TransactingPower(blockchain=testerchain, account=agent.beneficiary) testerchain.transacting_power = TransactingPower(blockchain=testerchain,
testerchain.transacting_power.activate(password=INSECURE_DEVELOPMENT_PASSWORD) password=INSECURE_DEVELOPMENT_PASSWORD,
account=agent.beneficiary)
testerchain.transacting_power.activate()
assert token_agent.get_balance(address=agent.contract_address) == agent.unvested_tokens assert token_agent.get_balance(address=agent.contract_address) == agent.unvested_tokens
with pytest.raises((TransactionFailed, ValueError)): with pytest.raises((TransactionFailed, ValueError)):

View File

@ -14,7 +14,9 @@ def test_transacting_power_sign_message(testerchain):
# Manually create a TransactingPower # Manually create a TransactingPower
testerchain.connect() testerchain.connect()
eth_address = testerchain.etherbase_account eth_address = testerchain.etherbase_account
power = TransactingPower(blockchain=testerchain, account=eth_address) power = TransactingPower(blockchain=testerchain,
password=INSECURE_DEVELOPMENT_PASSWORD,
account=eth_address)
# The default state of the account is locked. # The default state of the account is locked.
# Test a signature without unlocking the account # Test a signature without unlocking the account

View File

@ -293,7 +293,6 @@ def capsule_side_channel(enacted_federated_policy):
self.messages = [] self.messages = []
self() self()
return _CapsuleSideChannel() return _CapsuleSideChannel()
@ -313,8 +312,12 @@ def federated_alice(alice_federated_test_config):
@pytest.fixture(scope="module") @pytest.fixture(scope="module")
def blockchain_alice(alice_blockchain_test_config): def blockchain_alice(alice_blockchain_test_config, testerchain):
_alice = alice_blockchain_test_config.produce() transacting_power = TransactingPower(blockchain=testerchain,
account=alice_blockchain_test_config.checksum_address,
password=INSECURE_DEVELOPMENT_PASSWORD)
transacting_power.activate()
_alice = alice_blockchain_test_config.produce(additional_powers=[transacting_power])
return _alice return _alice
@ -325,8 +328,11 @@ def federated_bob(bob_federated_test_config):
@pytest.fixture(scope="module") @pytest.fixture(scope="module")
def blockchain_bob(bob_blockchain_test_config): def blockchain_bob(bob_blockchain_test_config, testerchain):
_bob = bob_blockchain_test_config.produce() transacting_power = TransactingPower(blockchain=testerchain,
account=bob_blockchain_test_config.checksum_address,
password=INSECURE_DEVELOPMENT_PASSWORD)
_bob = bob_blockchain_test_config.produce(additional_powers=[transacting_power])
return _bob return _bob
@ -370,8 +376,10 @@ def testerchain():
# Mock TransactingPower Consumption (Deployer) # Mock TransactingPower Consumption (Deployer)
testerchain.deployer_address = testerchain.etherbase_account testerchain.deployer_address = testerchain.etherbase_account
testerchain.transacting_power = TransactingPower(blockchain=testerchain, account=testerchain.deployer_address) testerchain.transacting_power = TransactingPower(blockchain=testerchain,
testerchain.transacting_power.activate(password=INSECURE_DEVELOPMENT_PASSWORD) password=INSECURE_DEVELOPMENT_PASSWORD,
account=testerchain.deployer_address)
testerchain.transacting_power.activate()
yield testerchain yield testerchain
testerchain.disconnect() testerchain.disconnect()