コード例 #1
0
ファイル: account.py プロジェクト: BlueSpaceCookie/blockchain
def get_or_create_username(config, machine_auth):
    """ Gets an existing username or creates a new account

        On a bitcoin computer a user can create one account per
        machine auth wallet. When not on a BC a user must log into
        an existing account created at the free signup page.

    Args:
        config (Config): config object used for getting .two1 information
        machine_auth (MachineAuthWallet): machine auth wallet used for authentication

    Returns:
        str: username of the current user on the system
    """
    # User hasn't logged in with the wallet
    if not config.mining_auth_pubkey:
        # A user can create an account on a BC
        if two1.TWO1_DEVICE_ID:
            login.create_account_on_bc(config, machine_auth)

        # log into an existing account
        else:
            login.login_account(config, machine_auth)

    if not config.username:
        raise exceptions.Two1Error(uxstring.UxString.Error.login_error_username)

    if not config.mining_auth_pubkey:
        exceptions.Two1Error(uxstring.UxString.Error.login_error_mining_auth_pubkey)

    return config.username
コード例 #2
0
def test_mine_log(patch_click, config, rest_client, machine_auth_wallet,
                  username, password):
    # first log into the test account given by PASSWORD and USER_NAME
    login.login_account(config, machine_auth_wallet, username, password)
    click.confirm.assert_called_with(uxstring.UxString.analytics_optin)

    # cannot make an assumption of zero balance for now
    pre_status_dict = status._status(config, rest_client,
                                     machine_auth_wallet.wallet, False)
    pre_balance = pre_status_dict['wallet']['wallet']['twentyone_balance']

    # run mine to get an expected amount of off chain balance
    mine._mine(config, rest_client, machine_auth_wallet.wallet)

    # Status now should have an offchain balance
    post_status_dict = status._status(config, rest_client,
                                      machine_auth_wallet.wallet, False)
    post_balance = post_status_dict['wallet']['wallet']['twentyone_balance']

    # payout is higher for BCs
    # FIXME: prod temporarily has the payout at 20k
    payout = 20000
    # payout = 20000 if bitcoin_computer.has_mining_chip() else 10000

    # esure payout shows in status
    assert post_balance == pre_balance + payout

    # check logs to ensure payout is theres
    logs = log.get_bc_logs(rest_client, False)
    assert str(payout) in logs[1]
コード例 #3
0
ファイル: test_commands.py プロジェクト: 0xDeX/two1-python
def test_mine_log(patch_click, config, rest_client, machine_auth_wallet, username, password):
    # first log into the test account given by PASSWORD and USER_NAME
    login.login_account(config, machine_auth_wallet, username, password)
    click.confirm.assert_called_with(uxstring.UxString.analytics_optin)

    # cannot make an assumption of zero balance for now
    pre_status_dict = status._status(config, rest_client, machine_auth_wallet.wallet, False)
    pre_balance = pre_status_dict['wallet']['wallet']['twentyone_balance']

    # run mine to get an expected amount of off chain balance
    mine._mine(config, rest_client, machine_auth_wallet.wallet)

    # Status now should have an offchain balance
    post_status_dict = status._status(config, rest_client, machine_auth_wallet.wallet, False)
    post_balance = post_status_dict['wallet']['wallet']['twentyone_balance']

    # payout is higher for BCs
    # FIXME: prod temporarily has the payout at 20k
    payout = 20000
    # payout = 20000 if bitcoin_computer.has_mining_chip() else 10000

    # esure payout shows in status
    assert post_balance == pre_balance + payout

    # check logs to ensure payout is theres
    logs = log.get_bc_logs(rest_client, False)
    assert str(payout) in logs[1]