diff --git a/nucypher/cli/deploy.py b/nucypher/cli/deploy.py index cd64146fc..f70144a3e 100644 --- a/nucypher/cli/deploy.py +++ b/nucypher/cli/deploy.py @@ -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, diff --git a/tests/cli/test_deploy.py b/tests/cli/test_deploy.py index 6d8756968..bfed45fdc 100644 --- a/tests/cli/test_deploy.py +++ b/tests/cli/test_deploy.py @@ -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,34 +284,31 @@ 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', - '--registry-infile', MOCK_REGISTRY_FILEPATH, - '--provider-uri', TEST_PROVIDER_URI, - '--poa') + 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 + result = click_runner.invoke(deploy, command, input=user_input, catch_exceptions=False) + assert result.exit_code == 0 - command = ('contracts', - '--upgrade', - '--contract-name', 'UserEscrowProxy', - '--registry-infile', MOCK_REGISTRY_FILEPATH, - '--provider-uri', TEST_PROVIDER_URI, - '--poa') + records = blockchain.interface.registry.search(contract_name='UserEscrowProxy') + assert len(records) == 2 - 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):