Exemplo n.º 1
0
def another_testerchain():
    testerchain = _TesterBlockchain(eth_airdrop=True,
                                    free_transactions=True,
                                    light=True)
    testerchain.deployer_address = testerchain.etherbase_account
    assert testerchain.is_light
    yield testerchain
Exemplo n.º 2
0
def test_rapid_deployment(token_economics, test_registry, tmpdir,
                          get_random_checksum_address):

    blockchain = _TesterBlockchain(eth_airdrop=False, test_accounts=4)

    # TODO: #1092 - TransactingPower
    blockchain.transacting_power = TransactingPower(
        password=INSECURE_DEVELOPMENT_PASSWORD,
        account=blockchain.etherbase_account)
    blockchain.transacting_power.activate()
    deployer_address = blockchain.etherbase_account

    administrator = ContractAdministrator(deployer_address=deployer_address,
                                          registry=test_registry)
    blockchain.bootstrap_network(registry=test_registry)

    all_yall = blockchain.unassigned_accounts

    # Start with some hard-coded cases...
    allocation_data = [
        {
            'checksum_address': all_yall[1],
            'amount': token_economics.maximum_allowed_locked,
            'lock_periods': token_economics.minimum_locked_periods
        },
        {
            'checksum_address': all_yall[2],
            'amount': token_economics.minimum_allowed_locked,
            'lock_periods': token_economics.minimum_locked_periods
        },
        {
            'checksum_address': all_yall[3],
            'amount': token_economics.minimum_allowed_locked * 100,
            'lock_periods': token_economics.minimum_locked_periods
        },
    ]

    # Pile on the rest
    for _ in range(NUMBER_OF_ALLOCATIONS_IN_TESTS - len(allocation_data)):
        checksum_address = get_random_checksum_address()
        amount = random.randint(token_economics.minimum_allowed_locked,
                                token_economics.maximum_allowed_locked)
        duration = random.randint(token_economics.minimum_locked_periods,
                                  token_economics.maximum_rewarded_periods)
        random_allocation = {
            'checksum_address': checksum_address,
            'amount': amount,
            'lock_periods': duration
        }
        allocation_data.append(random_allocation)

    filepath = tmpdir / "allocations.json"
    with open(filepath, 'w') as f:
        json.dump(allocation_data, f)

    administrator.batch_deposits(allocation_data_filepath=str(filepath),
                                 interactive=False)

    minimum, default, maximum = 10, 20, 30
    administrator.set_fee_rate_range(minimum, default, maximum)
Exemplo n.º 3
0
def test_rapid_deployment(token_economics, test_registry, temp_dir_path,
                          get_random_checksum_address):

    blockchain = _TesterBlockchain(eth_airdrop=False, test_accounts=4)

    deployer_address = blockchain.etherbase_account
    deployer_power = TransactingPower(signer=Web3Signer(blockchain.client),
                                      account=deployer_address)

    administrator = ContractAdministrator(transacting_power=deployer_power,
                                          domain=TEMPORARY_DOMAIN,
                                          registry=test_registry)
    blockchain.bootstrap_network(registry=test_registry)

    all_yall = blockchain.unassigned_accounts

    # Start with some hard-coded cases...
    allocation_data = [
        {
            'checksum_address': all_yall[1],
            'amount': token_economics.maximum_allowed_locked,
            'lock_periods': token_economics.minimum_locked_periods
        },
        {
            'checksum_address': all_yall[2],
            'amount': token_economics.minimum_allowed_locked,
            'lock_periods': token_economics.minimum_locked_periods
        },
        {
            'checksum_address': all_yall[3],
            'amount': token_economics.minimum_allowed_locked * 100,
            'lock_periods': token_economics.minimum_locked_periods
        },
    ]

    # Pile on the rest
    for _ in range(NUMBER_OF_ALLOCATIONS_IN_TESTS - len(allocation_data)):
        checksum_address = get_random_checksum_address()
        amount = random.randint(token_economics.minimum_allowed_locked,
                                token_economics.maximum_allowed_locked)
        duration = random.randint(token_economics.minimum_locked_periods,
                                  token_economics.maximum_rewarded_periods)
        random_allocation = {
            'checksum_address': checksum_address,
            'amount': amount,
            'lock_periods': duration
        }
        allocation_data.append(random_allocation)

    filepath = temp_dir_path / "allocations.json"
    with open(filepath, 'w') as f:
        json.dump(allocation_data, f)

    minimum, default, maximum = 10, 20, 30
    administrator.set_fee_rate_range(minimum, default, maximum)