def test_manual_proxy_retargeting(testerchain, test_registry, token_economics): deployer = StakingEscrowDeployer( registry=test_registry, deployer_address=testerchain.etherbase_account, economics=token_economics) # Get Proxy-Direct proxy_deployer = deployer.get_proxy_deployer( registry=test_registry, provider_uri=TEST_PROVIDER_URI) # Re-Deploy Staking Escrow old_target = proxy_deployer.target_contract.address old_secret = bytes("...maybe not.", encoding='utf-8') new_secret = keccak_digest(bytes('thistimeforsure', encoding='utf-8')) # Get the latest un-targeted contract from the registry latest_deployment = deployer.get_latest_enrollment(registry=test_registry) receipt = deployer.retarget(target_address=latest_deployment.address, existing_secret_plaintext=old_secret, new_secret_hash=new_secret) assert receipt['status'] == 1 # Check proxy targets new_target = proxy_deployer.contract.functions.target().call() assert old_target != new_target assert new_target == latest_deployment.address # Check address consistency new_bare_contract = deployer.get_principal_contract( registry=test_registry, provider_uri=TEST_PROVIDER_URI) assert new_bare_contract.address == latest_deployment.address == new_target
def test_deployer_version_management(testerchain, test_registry, token_economics): deployer = StakingEscrowDeployer(registry=test_registry, economics=token_economics) untargeted_deployment = deployer.get_latest_enrollment() latest_targeted_deployment = deployer.get_principal_contract() proxy_deployer = deployer.get_proxy_deployer() proxy_target = proxy_deployer.target_contract.address assert latest_targeted_deployment.address == proxy_target assert untargeted_deployment.address != latest_targeted_deployment.address
def test_manual_proxy_retargeting(testerchain, test_registry, token_economics): deployer = StakingEscrowDeployer( registry=test_registry, deployer_address=testerchain.etherbase_account, economics=token_economics) # Get Proxy-Direct proxy_deployer = deployer.get_proxy_deployer( registry=test_registry, provider_uri=TEST_PROVIDER_URI) # Re-Deploy Staking Escrow old_target = proxy_deployer.target_contract.address old_secret = bytes("...maybe not.", encoding='utf-8') new_secret = keccak_digest(bytes('thistimeforsure', encoding='utf-8')) # Get the latest un-targeted contract from the registry latest_deployment = deployer.get_latest_enrollment(registry=test_registry) # Build retarget transaction (just for informational purposes) transaction = deployer.retarget(target_address=latest_deployment.address, existing_secret_plaintext=old_secret, new_secret_hash=new_secret, just_build_transaction=True) assert transaction['to'] == proxy_deployer.contract.address upgrade_function, _params = proxy_deployer.contract.decode_function_input( transaction['data']) assert upgrade_function.fn_name == proxy_deployer.contract.functions.upgrade.fn_name # Retarget, for real receipt = deployer.retarget(target_address=latest_deployment.address, existing_secret_plaintext=old_secret, new_secret_hash=new_secret) assert receipt['status'] == 1 # Check proxy targets new_target = proxy_deployer.contract.functions.target().call() assert old_target != new_target assert new_target == latest_deployment.address # Check address consistency new_bare_contract = deployer.get_principal_contract( registry=test_registry, provider_uri=TEST_PROVIDER_URI) assert new_bare_contract.address == latest_deployment.address == new_target
def test_deployer_version_management(testerchain, test_registry, token_economics): deployer = StakingEscrowDeployer( deployer_address=testerchain.etherbase_account, registry=test_registry, economics=token_economics) untargeted_deployment = deployer.get_latest_enrollment( registry=test_registry) latest_targeted_deployment = deployer.get_principal_contract( registry=test_registry) proxy_deployer = deployer.get_proxy_deployer( registry=test_registry, provider_uri=TEST_PROVIDER_URI) proxy_target = proxy_deployer.target_contract.address assert latest_targeted_deployment.address == proxy_target assert untargeted_deployment.address != latest_targeted_deployment.address
def test_manual_proxy_retargeting(testerchain, test_registry, token_economics, transacting_power): deployer = StakingEscrowDeployer(registry=test_registry, economics=token_economics) # Get Proxy-Direct proxy_deployer = deployer.get_proxy_deployer() # Re-Deploy Staking Escrow old_target = proxy_deployer.target_contract.address # Get the latest un-targeted contract from the registry latest_deployment = deployer.get_latest_enrollment() # Build retarget transaction (just for informational purposes) transaction = deployer.retarget(transacting_power=transacting_power, target_address=latest_deployment.address, just_build_transaction=True, confirmations=0) assert transaction['to'] == proxy_deployer.contract.address upgrade_function, _params = proxy_deployer.contract.decode_function_input( transaction['data']) # TODO: this only tests for ethtester assert upgrade_function.fn_name == proxy_deployer.contract.functions.upgrade.fn_name # Retarget, for real receipt = deployer.retarget(transacting_power=transacting_power, target_address=latest_deployment.address, confirmations=0) assert receipt['status'] == 1 # Check proxy targets new_target = proxy_deployer.contract.functions.target().call() assert old_target != new_target assert new_target == latest_deployment.address # Check address consistency new_bare_contract = deployer.get_principal_contract() assert new_bare_contract.address == latest_deployment.address == new_target