Exemple #1
0
    def deploy_escrow_proxy(self, secret):

        escrow_proxy_deployer = UserEscrowProxyDeployer(
            deployer_address=self.deployer_address, secret_hash=secret)

        escrow_proxy_deployer.deploy()
        return escrow_proxy_deployer
Exemple #2
0
def proxy_deployer(testerchain, agency) -> UserEscrowAgent:
    deployer_address, beneficiary_address, *everybody_else = testerchain.client.accounts

    # Proxy
    proxy_secret = os.urandom(DispatcherDeployer.DISPATCHER_SECRET_LENGTH)
    proxy_deployer = UserEscrowProxyDeployer(deployer_address=deployer_address, blockchain=testerchain)

    proxy_deployer.deploy(secret_hash=proxy_secret)
    yield proxy_deployer
Exemple #3
0
def proxy_deployer(testerchain) -> UserEscrowAgent:
    deployer_address, beneficiary_address, *everybody_else = testerchain.interface.w3.eth.accounts

    # Proxy
    proxy_secret = os.urandom(DispatcherDeployer.DISPATCHER_SECRET_LENGTH)
    proxy_deployer = UserEscrowProxyDeployer(deployer_address=deployer_address, secret_hash=proxy_secret)

    proxy_deployer.deploy()
    yield proxy_deployer
Exemple #4
0
def _make_agency(testerchain, test_registry):
    """
    Launch the big three contracts on provided chain,
    make agents for each and return them.
    """
    origin = testerchain.etherbase_account

    token_deployer = NucypherTokenDeployer(deployer_address=origin,
                                           registry=test_registry)
    token_deployer.deploy()

    staking_escrow_deployer = StakingEscrowDeployer(deployer_address=origin,
                                                    registry=test_registry)
    staking_escrow_deployer.deploy(secret_hash=INSECURE_DEPLOYMENT_SECRET_HASH)

    policy_manager_deployer = PolicyManagerDeployer(deployer_address=origin,
                                                    registry=test_registry)
    policy_manager_deployer.deploy(secret_hash=INSECURE_DEPLOYMENT_SECRET_HASH)

    adjudicator_deployer = AdjudicatorDeployer(deployer_address=origin,
                                               registry=test_registry)
    adjudicator_deployer.deploy(secret_hash=INSECURE_DEPLOYMENT_SECRET_HASH)

    user_escrow_proxy_deployer = UserEscrowProxyDeployer(
        deployer_address=origin, registry=test_registry)
    user_escrow_proxy_deployer.deploy(
        secret_hash=INSECURE_DEPLOYMENT_SECRET_HASH)

    token_agent = token_deployer.make_agent()  # 1 Token
    staking_agent = staking_escrow_deployer.make_agent()  # 2 Staking Escrow
    policy_agent = policy_manager_deployer.make_agent()  # 3 Policy Agent
    _adjudicator_agent = adjudicator_deployer.make_agent()  # 4 Adjudicator

    # TODO: Get rid of returning these agents here.
    # What's important is deploying and creating the first agent for each contract,
    # and since agents are singletons, in tests it's only necessary to call the agent
    # constructor again to receive the existing agent.
    #
    # For example:
    #     staking_agent = StakingEscrowAgent()
    #
    # This is more clear than how we currently obtain an agent instance in tests:
    #     _, staking_agent, _ = agency
    #
    # Other advantages is that it's closer to how agents should be use (i.e., there
    # are no fixtures IRL) and it's more extensible (e.g., AdjudicatorAgent)

    return token_agent, staking_agent, policy_agent
Exemple #5
0
    def deploy_escrow_proxy(self, secret: bytes):

        escrow_proxy_deployer = UserEscrowProxyDeployer(blockchain=self.blockchain,
                                                        deployer_address=self.deployer_address,
                                                        secret_hash=secret)

        txhashes = escrow_proxy_deployer.deploy()
        return txhashes
    def deploy_escrow_proxy(self, secret: bytes) -> dict:
        secret = self.blockchain.interface.w3.keccak(secret)
        escrow_proxy_deployer = UserEscrowProxyDeployer(blockchain=self.blockchain,
                                                        deployer_address=self.deployer_address,
                                                        secret_hash=secret)

        txhashes = escrow_proxy_deployer.deploy()
        return txhashes
def user_escrow_proxy(three_agents):
    token_agent, miner_agent, policy_agent = three_agents
    testerchain = policy_agent.blockchain
    deployer = testerchain.etherbase_account

    escrow_proxy_deployer = UserEscrowProxyDeployer(deployer_address=deployer)

    _escrow_proxy_deployments_txhashes = escrow_proxy_deployer.deploy(secret_hash=os.urandom(32))
    testerchain.time_travel(seconds=120)
    yield escrow_proxy_deployer.contract_address
    testerchain.interface.registry.clear()
    testerchain.sever_connection()
def user_escrow_proxy(agency):
    token_agent, staking_agent, policy_agent = agency
    testerchain = policy_agent.blockchain
    deployer = testerchain.etherbase_account

    escrow_proxy_deployer = UserEscrowProxyDeployer(deployer_address=deployer)

    _escrow_proxy_deployments_txhashes = escrow_proxy_deployer.deploy(
        secret_hash=os.urandom(32))
    testerchain.time_travel(seconds=120)
    yield escrow_proxy_deployer.contract_address
    testerchain.registry.clear()
    testerchain.disconnect()
def test_user_escrow_deployer(three_agents, testerchain):
    deployer = testerchain.etherbase_account

    escrow_proxy_deployer = UserEscrowProxyDeployer(deployer_address=deployer, secret_hash=os.urandom(32))

    _escrow_proxy_deployments_txhashes = escrow_proxy_deployer.deploy()

    deployer = UserEscrowDeployer(deployer_address=deployer)

    deployment_txhashes = deployer.deploy()

    for title, txhash in deployment_txhashes.items():
        receipt = testerchain.wait_for_receipt(txhash=txhash)
        assert receipt['status'] == 1, "Transaction Rejected {}:{}".format(title, txhash)
def test_user_escrow_proxy_deployer(testerchain, deployment_progress,
                                    test_registry):

    #
    # Setup
    #

    origin = testerchain.etherbase_account

    token_deployer = NucypherTokenDeployer(deployer_address=origin,
                                           registry=test_registry)
    token_deployer.deploy()

    staking_escrow_deployer = StakingEscrowDeployer(deployer_address=origin,
                                                    registry=test_registry)
    staking_escrow_deployer.deploy(secret_hash=INSECURE_DEPLOYMENT_SECRET_HASH)

    policy_manager_deployer = PolicyManagerDeployer(deployer_address=origin,
                                                    registry=test_registry)
    policy_manager_deployer.deploy(secret_hash=INSECURE_DEPLOYMENT_SECRET_HASH)

    adjudicator_deployer = AdjudicatorDeployer(deployer_address=origin,
                                               registry=test_registry)
    adjudicator_deployer.deploy(secret_hash=INSECURE_DEPLOYMENT_SECRET_HASH)

    #
    # Test
    #

    user_escrow_proxy_deployer = UserEscrowProxyDeployer(
        deployer_address=origin, registry=test_registry)
    user_escrow_proxy_receipts = user_escrow_proxy_deployer.deploy(
        secret_hash=INSECURE_DEPLOYMENT_SECRET_HASH,
        progress=deployment_progress)

    # deployment steps must match expected number of steps
    assert deployment_progress.num_steps == len(
        user_escrow_proxy_deployer.deployment_steps) == 2
    assert len(user_escrow_proxy_receipts) == 2

    for step in user_escrow_proxy_deployer.deployment_steps:
        assert user_escrow_proxy_receipts[step]['status'] == 1