2017-10-19 13:49:20 +00:00
|
|
|
import pytest
|
2018-01-03 09:34:40 +00:00
|
|
|
from tests import api_requests, user_flow, transaction_users_wallet
|
|
|
|
from tests.base_test_case import SingleDeviceTestCase
|
|
|
|
from views.console_view import ConsoleView
|
2017-10-19 13:49:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.all
|
|
|
|
class TestWallet(SingleDeviceTestCase):
|
|
|
|
|
|
|
|
@pytest.mark.wallet
|
2017-10-23 10:23:14 +00:00
|
|
|
def test_wallet_error_messages(self):
|
2018-01-03 09:34:40 +00:00
|
|
|
console = ConsoleView(self.driver)
|
|
|
|
user_flow.create_user(console)
|
2018-01-14 17:43:36 +00:00
|
|
|
console.back_button.click()
|
|
|
|
wallet_view = console.wallet_button.click()
|
|
|
|
send_transaction = wallet_view.send_button.click()
|
2018-01-03 09:34:40 +00:00
|
|
|
send_transaction.amount_edit_box.send_keys('asd')
|
|
|
|
send_transaction.find_full_text('Amount is not a valid number')
|
|
|
|
send_transaction.amount_edit_box.send_keys('0,1')
|
|
|
|
send_transaction.find_full_text('Insufficient funds')
|
2017-10-19 13:49:20 +00:00
|
|
|
|
|
|
|
@pytest.mark.wallet
|
2017-12-13 13:12:46 +00:00
|
|
|
def test_request_transaction_from_wallet(self):
|
2018-01-03 09:34:40 +00:00
|
|
|
console_view = ConsoleView(self.driver)
|
|
|
|
user_flow.recover_access(console_view,
|
|
|
|
transaction_users_wallet['A_USER']['passphrase'],
|
|
|
|
transaction_users_wallet['A_USER']['password'],
|
|
|
|
transaction_users_wallet['A_USER']['username'])
|
2018-01-14 17:43:36 +00:00
|
|
|
home_view = console_view.get_home_view()
|
2017-12-13 13:12:46 +00:00
|
|
|
recipient_key = transaction_users_wallet['B_USER']['public_key']
|
2018-01-14 17:43:36 +00:00
|
|
|
user_flow.add_contact(home_view, recipient_key)
|
|
|
|
home_view.back_button.click(times_to_click=3)
|
|
|
|
wallet_view = home_view.wallet_button.click()
|
|
|
|
send_transaction_view = wallet_view.request_button.click()
|
2018-01-03 09:34:40 +00:00
|
|
|
send_transaction_view.amount_edit_box.scroll_to_element()
|
|
|
|
send_transaction_view.amount_edit_box.send_keys('0.1')
|
|
|
|
wallet_view.send_request_button.click()
|
2018-01-14 17:43:36 +00:00
|
|
|
user_chat = home_view.get_chat_with_user(transaction_users_wallet['B_USER']['username']).click()
|
|
|
|
user_chat.find_text_part('Requesting 0.1 ETH')
|
2017-12-13 13:12:46 +00:00
|
|
|
|
2017-10-19 13:49:20 +00:00
|
|
|
@pytest.mark.parametrize("test, recipient, sender", [('sign_now', 'A_USER', 'B_USER'),
|
|
|
|
('sign_later', 'B_USER', 'A_USER')],
|
2018-01-14 17:43:36 +00:00
|
|
|
ids=['sign_now','sign_later'])
|
2017-10-19 13:49:20 +00:00
|
|
|
def test_send_transaction_from_wallet(self, test, recipient, sender):
|
2018-01-03 09:34:40 +00:00
|
|
|
console_view = ConsoleView(self.driver)
|
|
|
|
user_flow.recover_access(console_view,
|
|
|
|
transaction_users_wallet[sender]['passphrase'],
|
|
|
|
transaction_users_wallet[sender]['password'],
|
|
|
|
transaction_users_wallet[sender]['username'])
|
2018-01-14 17:43:36 +00:00
|
|
|
home_view = console_view.get_home_view()
|
2017-12-07 13:14:45 +00:00
|
|
|
recipient_key = transaction_users_wallet[recipient]['public_key']
|
|
|
|
recipient_address = transaction_users_wallet[recipient]['address']
|
2018-01-03 09:34:40 +00:00
|
|
|
initial_balance_recipient = api_requests.get_balance(recipient_address)
|
2018-01-14 17:43:36 +00:00
|
|
|
user_flow.add_contact(home_view, recipient_key)
|
|
|
|
home_view.back_button.click(times_to_click=3)
|
|
|
|
wallet_view = home_view.wallet_button.click()
|
|
|
|
send_transaction = wallet_view.send_button.click()
|
2018-01-03 09:34:40 +00:00
|
|
|
send_transaction.amount_edit_box.click()
|
|
|
|
amount = send_transaction.get_unique_amount()
|
|
|
|
send_transaction.send_as_keyevent(amount)
|
|
|
|
send_transaction.confirm()
|
|
|
|
send_transaction.chose_recipient_button.click()
|
|
|
|
send_transaction.deny_button.click()
|
|
|
|
send_transaction.chose_from_contacts_button.click()
|
|
|
|
user_contact = send_transaction.element_by_text(transaction_users_wallet[recipient]['username'], 'button')
|
2017-10-19 13:49:20 +00:00
|
|
|
user_contact.click()
|
|
|
|
if test == 'sign_later':
|
2018-01-03 09:34:40 +00:00
|
|
|
send_transaction.sign_later_button.click()
|
|
|
|
send_transaction.yes_button.click()
|
|
|
|
send_transaction.ok_button_apk.click()
|
|
|
|
transactions_view = wallet_view.transactions_button.click()
|
|
|
|
transactions_view.unsigned_tab.click()
|
|
|
|
transactions_view.sign_button.click()
|
|
|
|
send_transaction.sign_transaction_button.click()
|
|
|
|
send_transaction.enter_password_input.send_keys(transaction_users_wallet[sender]['password'])
|
|
|
|
send_transaction.sign_transaction_button.click()
|
|
|
|
send_transaction.got_it_button.click()
|
|
|
|
api_requests.verify_balance_is_updated(initial_balance_recipient, recipient_address)
|
2017-10-23 20:46:49 +00:00
|
|
|
if test == 'sign_later':
|
2018-01-03 09:34:40 +00:00
|
|
|
transactions_view.history_tab.click()
|
2017-10-23 20:46:49 +00:00
|
|
|
else:
|
2018-01-14 17:43:36 +00:00
|
|
|
home_view.wallet_button.click()
|
2018-01-03 09:34:40 +00:00
|
|
|
transactions_view = wallet_view.transactions_button.click()
|
|
|
|
transaction = transactions_view.transactions_table.find_transaction(amount=amount)
|
2017-10-23 20:46:49 +00:00
|
|
|
details_view = transaction.click()
|
|
|
|
transaction_hash = details_view.get_transaction_hash()
|
2018-01-03 09:34:40 +00:00
|
|
|
api_requests.find_transaction_on_ropsten(address=transaction_users_wallet[sender]['address'],
|
|
|
|
transaction_hash=transaction_hash)
|
2017-10-19 13:49:20 +00:00
|
|
|
|
2017-10-23 20:46:49 +00:00
|
|
|
@pytest.mark.wallet
|
2017-12-27 18:03:57 +00:00
|
|
|
def test_eth_and_currency_balance(self):
|
2017-10-23 20:46:49 +00:00
|
|
|
errors = list()
|
2018-01-03 09:34:40 +00:00
|
|
|
console = ConsoleView(self.driver)
|
|
|
|
user_flow.recover_access(console,
|
|
|
|
passphrase=transaction_users_wallet['A_USER']['passphrase'],
|
|
|
|
password=transaction_users_wallet['A_USER']['password'],
|
|
|
|
username=transaction_users_wallet['A_USER']['username'])
|
2018-01-14 17:43:36 +00:00
|
|
|
home_view = console.get_home_view()
|
|
|
|
wallet = home_view.wallet_button.click()
|
2017-12-07 13:14:45 +00:00
|
|
|
address = transaction_users_wallet['A_USER']['address']
|
2018-01-03 09:34:40 +00:00
|
|
|
balance = api_requests.get_balance(address) / 1000000000000000000
|
|
|
|
eth_rate = api_requests.get_ethereum_price_in_usd()
|
2017-10-23 20:46:49 +00:00
|
|
|
wallet_balance = wallet.get_eth_value()
|
|
|
|
if wallet_balance != balance:
|
|
|
|
errors.append('Balance %s is not equal to the expected %s' % (wallet_balance, balance))
|
2017-12-27 18:03:57 +00:00
|
|
|
wallet.verify_currency_balance(eth_rate, errors)
|
2017-10-23 20:46:49 +00:00
|
|
|
assert not errors, 'errors occurred:\n{}'.format('\n'.join(errors))
|