mirror of https://github.com/nucypher/nucypher.git
Implement and test nucypher stake detach-worker
parent
2a26d54e6d
commit
a9f5c4a12b
|
@ -78,6 +78,7 @@ def stake(click_config,
|
||||||
accounts Show ETH and NU balances for stakeholder's accounts
|
accounts Show ETH and NU balances for stakeholder's accounts
|
||||||
sync Synchronize stake data with on-chain information
|
sync Synchronize stake data with on-chain information
|
||||||
set-worker Bound a worker to a staker
|
set-worker Bound a worker to a staker
|
||||||
|
detach-worker Detach worker currently bound to a staker
|
||||||
init Create a new stake
|
init Create a new stake
|
||||||
divide Create a new stake from part of an existing one
|
divide Create a new stake from part of an existing one
|
||||||
collect-reward Withdraw staking reward
|
collect-reward Withdraw staking reward
|
||||||
|
@ -140,13 +141,18 @@ def stake(click_config,
|
||||||
emitter.echo("OK!", color='green')
|
emitter.echo("OK!", color='green')
|
||||||
return # Exit
|
return # Exit
|
||||||
|
|
||||||
elif action == 'set-worker':
|
elif action in ('set-worker', 'detach-worker'):
|
||||||
|
|
||||||
if not staking_address:
|
if not staking_address:
|
||||||
staking_address = select_stake(stakeholder=STAKEHOLDER, emitter=emitter).owner_address
|
staking_address = select_stake(stakeholder=STAKEHOLDER, emitter=emitter).owner_address
|
||||||
|
|
||||||
|
if action == 'set-worker':
|
||||||
if not worker_address:
|
if not worker_address:
|
||||||
worker_address = click.prompt("Enter worker address", type=EIP55_CHECKSUM_ADDRESS)
|
worker_address = click.prompt("Enter worker address", type=EIP55_CHECKSUM_ADDRESS)
|
||||||
|
elif action == 'detach-worker':
|
||||||
|
if worker_address:
|
||||||
|
raise click.BadOptionUsage(message="detach-worker cannot be used together with --worker-address option")
|
||||||
|
worker_address = BlockchainInterface.NULL_ADDRESS
|
||||||
|
|
||||||
password = None
|
password = None
|
||||||
if not hw_wallet:
|
if not hw_wallet:
|
||||||
|
|
|
@ -499,3 +499,34 @@ def test_collect_rewards_integration(click_runner,
|
||||||
|
|
||||||
# The burner wallet has the reward ethers
|
# The burner wallet has the reward ethers
|
||||||
assert staker.token_agent.get_balance(address=staker_address)
|
assert staker.token_agent.get_balance(address=staker_address)
|
||||||
|
|
||||||
|
|
||||||
|
def test_stake_detach_worker(click_runner,
|
||||||
|
testerchain,
|
||||||
|
manual_staker,
|
||||||
|
manual_worker,
|
||||||
|
stakeholder_configuration_file_location):
|
||||||
|
|
||||||
|
staker = Staker(is_me=True,
|
||||||
|
checksum_address=manual_staker,
|
||||||
|
blockchain=testerchain)
|
||||||
|
|
||||||
|
assert staker.worker_address == manual_worker
|
||||||
|
|
||||||
|
init_args = ('stake', 'detach-worker',
|
||||||
|
'--config-file', stakeholder_configuration_file_location,
|
||||||
|
'--staking-address', manual_staker,
|
||||||
|
'--force')
|
||||||
|
|
||||||
|
user_input = f'{INSECURE_DEVELOPMENT_PASSWORD}'
|
||||||
|
result = click_runner.invoke(nucypher_cli,
|
||||||
|
init_args,
|
||||||
|
input=user_input,
|
||||||
|
catch_exceptions=False)
|
||||||
|
assert result.exit_code == 0
|
||||||
|
|
||||||
|
staker = Staker(is_me=True,
|
||||||
|
checksum_address=manual_staker,
|
||||||
|
blockchain=testerchain)
|
||||||
|
|
||||||
|
assert not staker.worker_address
|
Loading…
Reference in New Issue