mirror of https://github.com/nucypher/nucypher.git
Test flag for StakingEscrow in administrator class
parent
9b5ef923cb
commit
686a977f43
|
@ -182,7 +182,8 @@ class ContractAdministrator(NucypherTokenActor):
|
||||||
registry: BaseContractRegistry,
|
registry: BaseContractRegistry,
|
||||||
deployer_address: str = None,
|
deployer_address: str = None,
|
||||||
client_password: str = None,
|
client_password: str = None,
|
||||||
economics: TokenEconomics = None):
|
economics: TokenEconomics = None,
|
||||||
|
staking_escrow_test_mode: bool = False):
|
||||||
"""
|
"""
|
||||||
Note: super() is not called here to avoid setting the token agent.
|
Note: super() is not called here to avoid setting the token agent.
|
||||||
TODO: Review this logic ^^ "bare mode". #1510
|
TODO: Review this logic ^^ "bare mode". #1510
|
||||||
|
@ -199,6 +200,7 @@ class ContractAdministrator(NucypherTokenActor):
|
||||||
|
|
||||||
self.transacting_power = TransactingPower(password=client_password, account=deployer_address, cache=True)
|
self.transacting_power = TransactingPower(password=client_password, account=deployer_address, cache=True)
|
||||||
self.transacting_power.activate()
|
self.transacting_power.activate()
|
||||||
|
self.staking_escrow_test_mode = staking_escrow_test_mode
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
r = '{name} - {deployer_address})'.format(name=self.__class__.__name__, deployer_address=self.deployer_address)
|
r = '{name} - {deployer_address})'.format(name=self.__class__.__name__, deployer_address=self.deployer_address)
|
||||||
|
@ -235,6 +237,9 @@ class ContractAdministrator(NucypherTokenActor):
|
||||||
) -> Tuple[dict, BaseContractDeployer]:
|
) -> Tuple[dict, BaseContractDeployer]:
|
||||||
|
|
||||||
Deployer = self.__get_deployer(contract_name=contract_name)
|
Deployer = self.__get_deployer(contract_name=contract_name)
|
||||||
|
if Deployer is StakingEscrowDeployer:
|
||||||
|
kwargs.update({"test_mode": self.staking_escrow_test_mode})
|
||||||
|
|
||||||
deployer = Deployer(registry=self.registry,
|
deployer = Deployer(registry=self.registry,
|
||||||
deployer_address=self.deployer_address,
|
deployer_address=self.deployer_address,
|
||||||
economics=self.economics,
|
economics=self.economics,
|
||||||
|
|
|
@ -61,6 +61,7 @@ def _admin_actor_options(func):
|
||||||
@click.option('--registry-infile', help="Input path for contract registry file", type=EXISTING_READABLE_FILE)
|
@click.option('--registry-infile', help="Input path for contract registry file", type=EXISTING_READABLE_FILE)
|
||||||
@click.option('--registry-outfile', help="Output path for contract registry file", type=click.Path(file_okay=True))
|
@click.option('--registry-outfile', help="Output path for contract registry file", type=click.Path(file_okay=True))
|
||||||
@click.option('--dev', '-d', help="Forcibly use the development registry filepath.", is_flag=True)
|
@click.option('--dev', '-d', help="Forcibly use the development registry filepath.", is_flag=True)
|
||||||
|
@click.option('--se-test-mode', help="Enable test mode for StakingEscrow in deployment.", is_flag=True)
|
||||||
@functools.wraps(func)
|
@functools.wraps(func)
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
return func(*args, **kwargs)
|
return func(*args, **kwargs)
|
||||||
|
@ -138,7 +139,7 @@ def inspect(provider_uri, config_root, registry_infile, deployer_address, poa):
|
||||||
@click.option('--ignore-deployed', help="Ignore already deployed contracts if exist.", is_flag=True)
|
@click.option('--ignore-deployed', help="Ignore already deployed contracts if exist.", is_flag=True)
|
||||||
def upgrade(# Admin Actor Options
|
def upgrade(# Admin Actor Options
|
||||||
provider_uri, contract_name, config_root, poa, force, etherscan, hw_wallet, deployer_address,
|
provider_uri, contract_name, config_root, poa, force, etherscan, hw_wallet, deployer_address,
|
||||||
registry_infile, registry_outfile, dev,
|
registry_infile, registry_outfile, dev, se_test_mode,
|
||||||
|
|
||||||
# Other
|
# Other
|
||||||
retarget, target_address, ignore_deployed):
|
retarget, target_address, ignore_deployed):
|
||||||
|
@ -165,7 +166,8 @@ def upgrade(# Admin Actor Options
|
||||||
registry_outfile,
|
registry_outfile,
|
||||||
hw_wallet,
|
hw_wallet,
|
||||||
dev,
|
dev,
|
||||||
force)
|
force,
|
||||||
|
se_test_mode)
|
||||||
|
|
||||||
if not contract_name:
|
if not contract_name:
|
||||||
raise click.BadArgumentUsage(message="--contract-name is required when using --upgrade")
|
raise click.BadArgumentUsage(message="--contract-name is required when using --upgrade")
|
||||||
|
@ -200,7 +202,7 @@ def upgrade(# Admin Actor Options
|
||||||
@_admin_actor_options
|
@_admin_actor_options
|
||||||
def rollback(# Admin Actor Options
|
def rollback(# Admin Actor Options
|
||||||
provider_uri, contract_name, config_root, poa, force, etherscan, hw_wallet, deployer_address,
|
provider_uri, contract_name, config_root, poa, force, etherscan, hw_wallet, deployer_address,
|
||||||
registry_infile, registry_outfile, dev):
|
registry_infile, registry_outfile, dev, se_test_mode):
|
||||||
"""
|
"""
|
||||||
Rollback a proxy contract's target.
|
Rollback a proxy contract's target.
|
||||||
"""
|
"""
|
||||||
|
@ -224,7 +226,8 @@ def rollback(# Admin Actor Options
|
||||||
registry_outfile,
|
registry_outfile,
|
||||||
hw_wallet,
|
hw_wallet,
|
||||||
dev,
|
dev,
|
||||||
force)
|
force,
|
||||||
|
se_test_mode)
|
||||||
|
|
||||||
if not contract_name:
|
if not contract_name:
|
||||||
raise click.BadArgumentUsage(message="--contract-name is required when using --rollback")
|
raise click.BadArgumentUsage(message="--contract-name is required when using --rollback")
|
||||||
|
@ -242,7 +245,7 @@ def rollback(# Admin Actor Options
|
||||||
@click.option('--ignore-deployed', help="Ignore already deployed contracts if exist.", is_flag=True)
|
@click.option('--ignore-deployed', help="Ignore already deployed contracts if exist.", is_flag=True)
|
||||||
def contracts(# Admin Actor Options
|
def contracts(# Admin Actor Options
|
||||||
provider_uri, contract_name, config_root, poa, force, etherscan, hw_wallet, deployer_address,
|
provider_uri, contract_name, config_root, poa, force, etherscan, hw_wallet, deployer_address,
|
||||||
registry_infile, registry_outfile, dev,
|
registry_infile, registry_outfile, dev, se_test_mode,
|
||||||
|
|
||||||
# Other
|
# Other
|
||||||
bare, gas, ignore_deployed):
|
bare, gas, ignore_deployed):
|
||||||
|
@ -269,7 +272,8 @@ def contracts(# Admin Actor Options
|
||||||
registry_outfile,
|
registry_outfile,
|
||||||
hw_wallet,
|
hw_wallet,
|
||||||
dev,
|
dev,
|
||||||
force)
|
force,
|
||||||
|
se_test_mode)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Deploy Single Contract (Amend Registry)
|
# Deploy Single Contract (Amend Registry)
|
||||||
|
@ -354,7 +358,7 @@ def contracts(# Admin Actor Options
|
||||||
type=click.Path(exists=False, file_okay=True))
|
type=click.Path(exists=False, file_okay=True))
|
||||||
def allocations(# Admin Actor Options
|
def allocations(# Admin Actor Options
|
||||||
provider_uri, contract_name, config_root, poa, force, etherscan, hw_wallet, deployer_address,
|
provider_uri, contract_name, config_root, poa, force, etherscan, hw_wallet, deployer_address,
|
||||||
registry_infile, registry_outfile, dev,
|
registry_infile, registry_outfile, dev, se_test_mode,
|
||||||
|
|
||||||
# Other
|
# Other
|
||||||
allocation_infile, allocation_outfile):
|
allocation_infile, allocation_outfile):
|
||||||
|
@ -381,7 +385,8 @@ def allocations(# Admin Actor Options
|
||||||
registry_outfile,
|
registry_outfile,
|
||||||
hw_wallet,
|
hw_wallet,
|
||||||
dev,
|
dev,
|
||||||
force)
|
force,
|
||||||
|
se_test_mode)
|
||||||
|
|
||||||
if not allocation_infile:
|
if not allocation_infile:
|
||||||
allocation_infile = click.prompt("Enter allocation data filepath")
|
allocation_infile = click.prompt("Enter allocation data filepath")
|
||||||
|
@ -398,7 +403,7 @@ def allocations(# Admin Actor Options
|
||||||
@click.option('--value', help="Amount of tokens to transfer in the smallest denomination", type=click.INT)
|
@click.option('--value', help="Amount of tokens to transfer in the smallest denomination", type=click.INT)
|
||||||
def transfer_tokens(# Admin Actor Options
|
def transfer_tokens(# Admin Actor Options
|
||||||
provider_uri, contract_name, config_root, poa, force, etherscan, hw_wallet, deployer_address,
|
provider_uri, contract_name, config_root, poa, force, etherscan, hw_wallet, deployer_address,
|
||||||
registry_infile, registry_outfile, dev,
|
registry_infile, registry_outfile, dev, se_test_mode,
|
||||||
|
|
||||||
# Other
|
# Other
|
||||||
target_address, value):
|
target_address, value):
|
||||||
|
@ -425,7 +430,8 @@ def transfer_tokens(# Admin Actor Options
|
||||||
registry_outfile,
|
registry_outfile,
|
||||||
hw_wallet,
|
hw_wallet,
|
||||||
dev,
|
dev,
|
||||||
force)
|
force,
|
||||||
|
se_test_mode)
|
||||||
|
|
||||||
token_agent = ContractAgency.get_agent(NucypherTokenAgent, registry=local_registry)
|
token_agent = ContractAgency.get_agent(NucypherTokenAgent, registry=local_registry)
|
||||||
if not target_address:
|
if not target_address:
|
||||||
|
@ -448,7 +454,7 @@ def transfer_tokens(# Admin Actor Options
|
||||||
@click.option('--gas', help="Operate with a specified gas per-transaction limit", type=click.IntRange(min=1))
|
@click.option('--gas', help="Operate with a specified gas per-transaction limit", type=click.IntRange(min=1))
|
||||||
def transfer_ownership(# Admin Actor Options
|
def transfer_ownership(# Admin Actor Options
|
||||||
provider_uri, contract_name, config_root, poa, force, etherscan, hw_wallet, deployer_address,
|
provider_uri, contract_name, config_root, poa, force, etherscan, hw_wallet, deployer_address,
|
||||||
registry_infile, registry_outfile, dev,
|
registry_infile, registry_outfile, dev, se_test_mode,
|
||||||
|
|
||||||
# Other
|
# Other
|
||||||
target_address, gas):
|
target_address, gas):
|
||||||
|
@ -475,7 +481,8 @@ def transfer_ownership(# Admin Actor Options
|
||||||
registry_outfile,
|
registry_outfile,
|
||||||
hw_wallet,
|
hw_wallet,
|
||||||
dev,
|
dev,
|
||||||
force)
|
force,
|
||||||
|
se_test_mode)
|
||||||
|
|
||||||
if not target_address:
|
if not target_address:
|
||||||
target_address = click.prompt("Enter new owner's checksum address", type=EIP55_CHECKSUM_ADDRESS)
|
target_address = click.prompt("Enter new owner's checksum address", type=EIP55_CHECKSUM_ADDRESS)
|
||||||
|
@ -498,7 +505,7 @@ def transfer_ownership(# Admin Actor Options
|
||||||
|
|
||||||
|
|
||||||
def _make_authenticated_deployment_actor(emitter, provider_uri, deployer_address, deployer_interface, contract_name,
|
def _make_authenticated_deployment_actor(emitter, provider_uri, deployer_address, deployer_interface, contract_name,
|
||||||
registry_infile, registry_outfile, hw_wallet, dev, force):
|
registry_infile, registry_outfile, hw_wallet, dev, force, se_test_mode):
|
||||||
#
|
#
|
||||||
# Establish Registry
|
# Establish Registry
|
||||||
#
|
#
|
||||||
|
@ -525,7 +532,8 @@ def _make_authenticated_deployment_actor(emitter, provider_uri, deployer_address
|
||||||
# Produce Actor
|
# Produce Actor
|
||||||
ADMINISTRATOR = ContractAdministrator(registry=local_registry,
|
ADMINISTRATOR = ContractAdministrator(registry=local_registry,
|
||||||
client_password=password,
|
client_password=password,
|
||||||
deployer_address=deployer_address)
|
deployer_address=deployer_address,
|
||||||
|
staking_escrow_test_mode=se_test_mode)
|
||||||
# Verify ETH Balance
|
# Verify ETH Balance
|
||||||
emitter.echo(f"\n\nDeployer ETH balance: {ADMINISTRATOR.eth_balance}")
|
emitter.echo(f"\n\nDeployer ETH balance: {ADMINISTRATOR.eth_balance}")
|
||||||
if ADMINISTRATOR.eth_balance == 0:
|
if ADMINISTRATOR.eth_balance == 0:
|
||||||
|
|
|
@ -220,7 +220,8 @@ class TesterBlockchain(BlockchainDeployerInterface):
|
||||||
origin = testerchain.client.etherbase
|
origin = testerchain.client.etherbase
|
||||||
deployer = ContractAdministrator(deployer_address=origin,
|
deployer = ContractAdministrator(deployer_address=origin,
|
||||||
registry=registry,
|
registry=registry,
|
||||||
economics=economics or cls._default_token_economics)
|
economics=economics or cls._default_token_economics,
|
||||||
|
staking_escrow_test_mode=True)
|
||||||
secrets = dict()
|
secrets = dict()
|
||||||
for deployer_class in deployer.upgradeable_deployer_classes:
|
for deployer_class in deployer.upgradeable_deployer_classes:
|
||||||
secrets[deployer_class.contract_name] = INSECURE_DEVELOPMENT_PASSWORD
|
secrets[deployer_class.contract_name] = INSECURE_DEVELOPMENT_PASSWORD
|
||||||
|
|
|
@ -55,7 +55,8 @@ def test_nucypher_deploy_contracts(click_runner,
|
||||||
command = ['contracts',
|
command = ['contracts',
|
||||||
'--registry-outfile', registry_filepath,
|
'--registry-outfile', registry_filepath,
|
||||||
'--provider', TEST_PROVIDER_URI,
|
'--provider', TEST_PROVIDER_URI,
|
||||||
'--poa']
|
'--poa',
|
||||||
|
'--se-test-mode']
|
||||||
|
|
||||||
user_input = '0\n' + 'Y\n' + (f'{INSECURE_SECRETS[1]}\n' * 8) + 'DEPLOY'
|
user_input = '0\n' + 'Y\n' + (f'{INSECURE_SECRETS[1]}\n' * 8) + 'DEPLOY'
|
||||||
result = click_runner.invoke(deploy, command, input=user_input, catch_exceptions=False)
|
result = click_runner.invoke(deploy, command, input=user_input, catch_exceptions=False)
|
||||||
|
@ -101,6 +102,7 @@ def test_nucypher_deploy_contracts(click_runner,
|
||||||
assert token_agent.get_balance() == 0
|
assert token_agent.get_balance() == 0
|
||||||
staking_agent = ContractAgency.get_agent(StakingEscrowAgent, registry=registry)
|
staking_agent = ContractAgency.get_agent(StakingEscrowAgent, registry=registry)
|
||||||
assert staking_agent.get_current_period()
|
assert staking_agent.get_current_period()
|
||||||
|
assert staking_agent.contract.functions.isTestContract().call()
|
||||||
|
|
||||||
# and at least the others can be instantiated
|
# and at least the others can be instantiated
|
||||||
assert PolicyManagerAgent(registry=registry)
|
assert PolicyManagerAgent(registry=registry)
|
||||||
|
|
|
@ -457,7 +457,7 @@ def _make_agency(testerchain, test_registry):
|
||||||
token_deployer = NucypherTokenDeployer(deployer_address=origin, registry=test_registry)
|
token_deployer = NucypherTokenDeployer(deployer_address=origin, registry=test_registry)
|
||||||
token_deployer.deploy()
|
token_deployer.deploy()
|
||||||
|
|
||||||
staking_escrow_deployer = StakingEscrowDeployer(deployer_address=origin, registry=test_registry)
|
staking_escrow_deployer = StakingEscrowDeployer(deployer_address=origin, registry=test_registry, test_mode=True)
|
||||||
staking_escrow_deployer.deploy(secret_hash=INSECURE_DEPLOYMENT_SECRET_HASH)
|
staking_escrow_deployer.deploy(secret_hash=INSECURE_DEPLOYMENT_SECRET_HASH)
|
||||||
|
|
||||||
policy_manager_deployer = PolicyManagerDeployer(deployer_address=origin, registry=test_registry)
|
policy_manager_deployer = PolicyManagerDeployer(deployer_address=origin, registry=test_registry)
|
||||||
|
|
Loading…
Reference in New Issue