예제 #1
0
파일: fixtures.py 프로젝트: gs455/nucypher
def _make_agency(testerchain, test_registry):
    """
    Launch the big three contracts on provided chain,
    make agents for each and return them.
    """

    # Mock TransactingPower Consumption (Deployer)
    testerchain.transacting_power = TransactingPower(
        password=INSECURE_DEVELOPMENT_PASSWORD,
        account=testerchain.etherbase_account)
    testerchain.transacting_power.activate()

    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,
                                                    test_mode=True)
    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)

    staking_interface_deployer = StakingInterfaceDeployer(
        deployer_address=origin, registry=test_registry)
    staking_interface_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
예제 #2
0
def _make_agency(testerchain, test_registry, token_economics,
                 deployer_transacting_power):

    transacting_power = deployer_transacting_power

    token_deployer = NucypherTokenDeployer(economics=token_economics,
                                           registry=test_registry)
    token_deployer.deploy(transacting_power=transacting_power)

    staking_escrow_deployer = StakingEscrowDeployer(economics=token_economics,
                                                    registry=test_registry)
    staking_escrow_deployer.deploy(deployment_mode=INIT,
                                   transacting_power=transacting_power)

    policy_manager_deployer = PolicyManagerDeployer(economics=token_economics,
                                                    registry=test_registry)
    policy_manager_deployer.deploy(transacting_power=transacting_power)

    adjudicator_deployer = AdjudicatorDeployer(economics=token_economics,
                                               registry=test_registry)
    adjudicator_deployer.deploy(transacting_power=transacting_power)

    staking_interface_deployer = StakingInterfaceDeployer(
        economics=token_economics, registry=test_registry)
    staking_interface_deployer.deploy(transacting_power=transacting_power)

    worklock_deployer = WorklockDeployer(economics=token_economics,
                                         registry=test_registry)
    worklock_deployer.deploy(transacting_power=transacting_power)

    staking_escrow_deployer = StakingEscrowDeployer(economics=token_economics,
                                                    registry=test_registry)
    staking_escrow_deployer.deploy(deployment_mode=FULL,
                                   transacting_power=transacting_power)

    # Set additional parameters
    minimum, default, maximum = FEE_RATE_RANGE
    policy_agent = policy_manager_deployer.make_agent()
    txhash = policy_agent.contract.functions.setFeeRateRange(
        minimum, default, maximum).transact()
    testerchain.wait_for_receipt(txhash)
예제 #3
0
def test_staking_interface_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
    #

    staking_interface_deployer = StakingInterfaceDeployer(
        deployer_address=origin, registry=test_registry)
    staking_interface_receipts = staking_interface_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(
        staking_interface_deployer.deployment_steps) == 2
    assert len(staking_interface_receipts) == 2

    for step in staking_interface_deployer.deployment_steps:
        assert staking_interface_receipts[step]['status'] == 1
예제 #4
0
def _make_agency(
    testerchain, test_registry, token_economics
) -> Tuple[NucypherTokenAgent, StakingEscrowAgent, PolicyManagerAgent]:
    """
    Launch the big three contracts on provided chain,
    make agents for each and return them.
    """

    # Mock TransactingPower Consumption (Deployer)
    testerchain.transacting_power = TransactingPower(
        password=INSECURE_DEVELOPMENT_PASSWORD,
        signer=Web3Signer(client=testerchain.client),
        account=testerchain.etherbase_account)
    testerchain.transacting_power.activate()

    origin = testerchain.etherbase_account

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

    staking_escrow_deployer = StakingEscrowDeployer(deployer_address=origin,
                                                    economics=token_economics,
                                                    registry=test_registry,
                                                    test_mode=True)
    staking_escrow_deployer.deploy()

    policy_manager_deployer = PolicyManagerDeployer(deployer_address=origin,
                                                    economics=token_economics,
                                                    registry=test_registry)
    policy_manager_deployer.deploy()

    adjudicator_deployer = AdjudicatorDeployer(deployer_address=origin,
                                               economics=token_economics,
                                               registry=test_registry)
    adjudicator_deployer.deploy()

    staking_interface_deployer = StakingInterfaceDeployer(
        deployer_address=origin,
        economics=token_economics,
        registry=test_registry)
    staking_interface_deployer.deploy()

    worklock_deployer = WorklockDeployer(deployer_address=origin,
                                         economics=token_economics,
                                         registry=test_registry)
    worklock_deployer.deploy()

    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
    _worklock_agent = worklock_deployer.make_agent()  # 5 Worklock

    # Set additional parameters
    minimum, default, maximum = FEE_RATE_RANGE
    txhash = policy_agent.contract.functions.setFeeRateRange(
        minimum, default, maximum).transact()
    _receipt = testerchain.wait_for_receipt(txhash)

    # 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