def test_account_selection(click_runner, mocker, mock_testerchain,
                           mock_worklock_agent, test_registry_source_manager):
    accounts = list(mock_testerchain.client.accounts)
    index = random.choice(range(len(accounts)))
    the_chosen_one = accounts[index]

    # I spy
    mock_select = mocker.spy(worklock_command, 'select_client_account')

    command = ('cancel-bid', '--provider', MOCK_PROVIDER_URI, '--network',
               TEMPORARY_DOMAIN)

    user_input = '\n'.join((str(index), INSECURE_DEVELOPMENT_PASSWORD, YES))
    result = click_runner.invoke(worklock,
                                 command,
                                 input=user_input,
                                 catch_exceptions=False)
    assert result.exit_code == 0

    # Check call
    mock_select.assert_called_once()

    # Check output
    assert GENERIC_SELECT_ACCOUNT in result.output
    assert SELECTED_ACCOUNT.format(
        choice=index, chosen_account=the_chosen_one) in result.output
    assert COLLECT_ETH_PASSWORD.format(
        checksum_address=the_chosen_one) in result.output
Пример #2
0
def get_client_password(checksum_address: str,
                        envvar: str = None,
                        confirm: bool = False) -> str:
    """Interactively collect an ethereum client password"""
    client_password = get_password_from_prompt(
        prompt=COLLECT_ETH_PASSWORD.format(checksum_address=checksum_address),
        envvar=envvar,
        confirm=confirm)
    return client_password
Пример #3
0
def test_get_client_password(mock_stdin, mock_account, confirm, capsys):
    mock_stdin.password(INSECURE_DEVELOPMENT_PASSWORD, confirm=confirm)
    result = get_client_password(checksum_address=mock_account.address,
                                 confirm=confirm)
    assert result == INSECURE_DEVELOPMENT_PASSWORD
    assert mock_stdin.empty()
    message = COLLECT_ETH_PASSWORD.format(
        checksum_address=mock_account.address)
    captured = capsys.readouterr()
    assert message in captured.out
    if confirm:
        assert "Repeat for confirmation:" in captured.out