Formalize upgrade, rollback, and deploy as deploy CLI actions, dehydrate tests and check every upgrade / rollback opportunity.

pull/1040/head
Kieran Prasch 2019-03-26 11:34:47 -07:00
parent 142bc1d398
commit a317e7f5e4
No known key found for this signature in database
GPG Key ID: 199AB839D4125A62
2 changed files with 25 additions and 26 deletions

View File

@ -34,7 +34,6 @@ from nucypher.config.constants import DEFAULT_CONFIG_ROOT
@click.argument('action')
@click.option('--force', is_flag=True)
@click.option('--poa', help="Inject POA middleware", is_flag=True)
@click.option('--upgrade', help="Upgrade an already deployed contract", is_flag=True)
@click.option('--no-compile', help="Disables solidity contract compilation", is_flag=True)
@click.option('--provider-uri', help="Blockchain provider's URI", type=click.STRING)
@click.option('--config-root', help="Custom configuration directory", type=click.Path())
@ -50,7 +49,6 @@ from nucypher.config.constants import DEFAULT_CONFIG_ROOT
def deploy(click_config,
action,
poa,
upgrade,
provider_uri,
deployer_address,
contract_name,

View File

@ -89,6 +89,10 @@ def test_nucypher_deploy_all_contracts(testerchain, click_runner, mock_primary_r
def test_upgrade_contracts(click_runner):
contracts_to_upgrade = ('MinersEscrow', # Initial upgrades (version 2)
'PolicyManager',
'MiningAdjudicator',
'UserEscrowProxy',
#
# Setup
@ -280,35 +284,32 @@ def test_rollback(click_runner):
'--provider-uri', TEST_PROVIDER_URI,
'--poa')
result = click_runner.invoke(deploy, command, input=user_input, catch_exceptions=False)
assert result.exit_code == 0
records = blockchain.interface.registry.search(contract_name='PolicyManager')
assert len(records) == 2
for contract_name in contracts_to_rollback:
command = ('contracts',
'--upgrade',
'--contract-name', 'MiningAdjudicator',
command = ('rollback',
'--contract-name', contract_name,
'--registry-infile', MOCK_REGISTRY_FILEPATH,
'--provider-uri', TEST_PROVIDER_URI,
'--poa')
result = click_runner.invoke(deploy, command, input=user_input, catch_exceptions=False)
assert result.exit_code == 0
records = blockchain.interface.registry.search(contract_name='MiningAdjudicator')
assert len(records) == 2
command = ('contracts',
'--upgrade',
'--contract-name', 'UserEscrowProxy',
'--registry-infile', MOCK_REGISTRY_FILEPATH,
'--provider-uri', TEST_PROVIDER_URI,
'--poa')
result = click_runner.invoke(deploy, command, input=user_input, catch_exceptions=False)
assert result.exit_code == 0
records = blockchain.interface.registry.search(contract_name='UserEscrowProxy')
assert len(records) == 2
old, new = records
_name, old_address, *abi = old
_name, new_address, *abi = new
assert old_address != new_address
# Ensure the proxy targets the old deployment
proxy_name = 'Dispatcher'
proxy = blockchain.interface.get_proxy(target_address=new_address, proxy_name=proxy_name)
targeted_address = proxy.functions.target().call()
assert targeted_address != new_address
assert targeted_address == old_address
def test_nucypher_deploy_allocations(testerchain, click_runner, mock_allocation_infile, token_economics):