def test_rollback(testerchain, test_registry, transacting_power): deployer = StakingEscrowDeployer(registry=test_registry) staking_agent = ContractAgency.get_agent(StakingEscrowAgent, registry=test_registry) current_target = staking_agent.contract.functions.target().call() # Let's do one more upgrade receipts = deployer.upgrade(ignore_deployed=True, confirmations=0, transacting_power=transacting_power) for title, receipt in receipts.items(): assert receipt['status'] == 1 old_target = current_target current_target = staking_agent.contract.functions.target().call() assert current_target != old_target # It's time to rollback. receipt = deployer.rollback(transacting_power=transacting_power) assert receipt['status'] == 1 new_target = staking_agent.contract.functions.target().call() assert new_target != current_target assert new_target == old_target
def test_rollback(testerchain, test_registry, transacting_power, threshold_staking): deployer = StakingEscrowDeployer( staking_interface=threshold_staking.address, registry=test_registry) contract = testerchain.get_contract_by_name( registry=test_registry, contract_name=deployer.contract_name, proxy_name=DispatcherDeployer.contract_name, use_proxy_address=True) current_target = contract.functions.target().call() # Let's do one more upgrade receipts = deployer.upgrade(ignore_deployed=True, confirmations=0, transacting_power=transacting_power) for title, receipt in receipts.items(): assert receipt['status'] == 1 old_target = current_target current_target = contract.functions.target().call() assert current_target != old_target # It's time to rollback. receipt = deployer.rollback(transacting_power=transacting_power) assert receipt['status'] == 1 new_target = contract.functions.target().call() assert new_target != current_target assert new_target == old_target
def test_rollback(testerchain, test_registry): old_secret = bytes('new' + STAKING_ESCROW_DEPLOYMENT_SECRET, encoding='utf-8') new_secret_hash = keccak(text="third time's the charm") deployer = StakingEscrowDeployer( registry=test_registry, deployer_address=testerchain.etherbase_account) staking_agent = ContractAgency.get_agent(StakingEscrowAgent, registry=test_registry) current_target = staking_agent.contract.functions.target().call() # Let's do one more upgrade receipts = deployer.upgrade(existing_secret_plaintext=old_secret, new_secret_hash=new_secret_hash, ignore_deployed=True) for title, receipt in receipts.items(): assert receipt['status'] == 1 old_target = current_target current_target = staking_agent.contract.functions.target().call() assert current_target != old_target # It's time to rollback. But first... wrong_secret = b"WRONG!!" with pytest.raises(deployer.ContractDeploymentError): deployer.rollback(existing_secret_plaintext=wrong_secret, new_secret_hash=new_secret_hash) # OK, *now* is time for rollback old_secret = b"third time's the charm" new_secret_hash = keccak(text="...maybe not.") receipt = deployer.rollback(existing_secret_plaintext=old_secret, new_secret_hash=new_secret_hash) assert receipt['status'] == 1 new_target = staking_agent.contract.functions.target().call() assert new_target != current_target assert new_target == old_target