Beispiel #1
0
def test_upgrade_staking_interface(testerchain, test_registry):

    router = testerchain.get_contract_by_name(registry=test_registry,
                                              contract_name=StakingInterfaceRouterDeployer.contract_name)

    contract = testerchain.get_contract_by_name(registry=test_registry,
                                                contract_name=StakingInterfaceDeployer.contract_name,
                                                proxy_name=StakingInterfaceRouterDeployer.contract_name,
                                                use_proxy_address=False)

    target = router.functions.target().call()
    assert target == contract.address

    staking_interface_deployer = StakingInterfaceDeployer(deployer_address=testerchain.etherbase_account,
                                                          registry=test_registry)

    receipts = staking_interface_deployer.upgrade(ignore_deployed=True, confirmations=0)

    assert len(receipts) == 2

    for title, receipt in receipts.items():
        assert receipt['status'] == 1

    for preallocation_escrow_contract in preallocation_escrow_contracts:
        router_address = preallocation_escrow_contract.functions.router().call()
        assert router.address == router_address

    new_target = router.functions.target().call()
    contract = testerchain.get_contract_by_name(registry=test_registry,
                                                contract_name=StakingInterfaceDeployer.contract_name,
                                                proxy_name=StakingInterfaceRouterDeployer.contract_name,
                                                use_proxy_address=False)
    assert new_target == contract.address
    assert new_target != target
Beispiel #2
0
def test_upgrade_staking_interface(testerchain, test_registry):

    old_secret = INSECURE_DEPLOYMENT_SECRET_PLAINTEXT
    new_secret = 'new' + STAKING_INTERFACE_DEPLOYMENT_SECRET
    new_secret_hash = keccak_digest(new_secret.encode())
    router = testerchain.get_contract_by_name(
        registry=test_registry,
        contract_name=StakingInterfaceRouterDeployer.contract_name)

    contract = testerchain.get_contract_by_name(
        registry=test_registry,
        contract_name=StakingInterfaceDeployer.contract_name,
        proxy_name=StakingInterfaceRouterDeployer.contract_name,
        use_proxy_address=False)

    target = router.functions.target().call()
    assert target == contract.address

    staking_interface_deployer = StakingInterfaceDeployer(
        deployer_address=testerchain.etherbase_account, registry=test_registry)

    receipts = staking_interface_deployer.upgrade(
        existing_secret_plaintext=old_secret,
        new_secret_hash=new_secret_hash,
        ignore_deployed=True)

    assert len(receipts) == 2

    for title, receipt in receipts.items():
        assert receipt['status'] == 1

    for preallocation_escrow_contract in preallocation_escrow_contracts:
        router_address = preallocation_escrow_contract.functions.router().call(
        )
        assert router.address == router_address

    new_target = router.functions.target().call()
    contract = testerchain.get_contract_by_name(
        registry=test_registry,
        contract_name=StakingInterfaceDeployer.contract_name,
        proxy_name=StakingInterfaceRouterDeployer.contract_name,
        use_proxy_address=False)
    assert new_target == contract.address
    assert new_target != target