Ejemplo n.º 1
0
def create_account(skale, skale_amount, eth_amount, debug=True):
    base_wallet = Web3Wallet(ETH_PRIVATE_KEY, skale.web3)
    wallet_dict = generate_account(skale.web3)
    wallet = Web3Wallet(wallet_dict['private_key'], skale.web3)

    send_tokens(skale, base_wallet, wallet.address, skale_amount, debug)
    send_ether(skale.web3, base_wallet, wallet.address, eth_amount, debug)

    if debug:
        check_ether_balance(skale.web3, wallet.address)
        check_skale_balance(skale, wallet.address)
    return wallet, wallet_dict['private_key']
Ejemplo n.º 2
0
def test_send_ether(skale, empty_account):
    sender_balance = check_ether_balance(skale.web3, skale.wallet.address)

    send_ether(skale.web3, skale.wallet, empty_account.address,
               ETH_TRANSFER_VALUE)

    receiver_balance_after = check_ether_balance(skale.web3,
                                                 empty_account.address)
    sender_balance_after = check_ether_balance(skale.web3, skale.wallet.address)

    assert receiver_balance_after == ETH_TRANSFER_VALUE
    # check that sender_balance_after
    # have decreased by ETH_TRANSFER_VALUE and some gas
    assert sender_balance - 2 * ETH_TRANSFER_VALUE < sender_balance_after < \
        sender_balance - ETH_TRANSFER_VALUE
Ejemplo n.º 3
0
def test_generate_accounts(skale):
    results = generate_accounts(
        skale,
        skale.wallet,
        N_TEST_WALLETS,
        TOKEN_TRANSFER_VALUE,
        ETH_TRANSFER_VALUE,
        debug=True
    )
    assert len(results) == N_TEST_WALLETS

    test_address = results[-1]['address']
    eth_balance = check_ether_balance(skale.web3, test_address)
    token_balance_test = check_skale_balance(skale, test_address)
    token_balance = skale.token.get_balance(test_address)

    token_transfer_value_wei = skale.web3.toWei(TOKEN_TRANSFER_VALUE, 'ether')

    assert TOKEN_TRANSFER_VALUE == token_balance_test
    assert eth_balance == ETH_TRANSFER_VALUE
    assert token_balance == token_transfer_value_wei
Ejemplo n.º 4
0
def get_transfer_amount(skale):
    address = skale.wallet.address
    ether_balance = check_ether_balance(skale.web3, address)
    skale_balance = check_skale_balance(skale, address)
    return float(ether_balance) * GAS_COMMISSION_FACTOR, skale_balance
Ejemplo n.º 5
0
def send_funds(skale, address, skale_amount, eth_amount):
    send_tokens(skale, skale.wallet, address, skale_amount)
    send_ether(skale.web3, skale.wallet, address, eth_amount)
    check_ether_balance(skale.web3, address)
    check_skale_balance(skale, address)