2017-10-19 13:49:20 +00:00
|
|
|
import pytest
|
2018-01-03 09:34:40 +00:00
|
|
|
from selenium.common.exceptions import TimeoutException, NoSuchElementException
|
|
|
|
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)
|
|
|
|
chats = console.get_chat_view()
|
2017-10-19 13:49:20 +00:00
|
|
|
chats.back_button.click()
|
|
|
|
wallet_view = chats.wallet_button.click()
|
|
|
|
wallet_view.send_button.click()
|
2018-01-03 09:34:40 +00:00
|
|
|
send_transaction = wallet_view.get_send_transaction_view()
|
|
|
|
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'])
|
|
|
|
chats_view = console_view.get_chat_view()
|
2017-12-13 13:12:46 +00:00
|
|
|
recipient_key = transaction_users_wallet['B_USER']['public_key']
|
2018-01-03 09:34:40 +00:00
|
|
|
user_flow.add_contact(chats_view, recipient_key)
|
2017-12-13 13:12:46 +00:00
|
|
|
for _ in range(3):
|
2018-01-03 09:34:40 +00:00
|
|
|
try:
|
|
|
|
chats_view.back_button.click()
|
|
|
|
except(TimeoutException, NoSuchElementException):
|
|
|
|
pass
|
|
|
|
wallet_view = chats_view.wallet_button.click()
|
|
|
|
wallet_view.request_button.click()
|
|
|
|
send_transaction_view = wallet_view.get_send_transaction_view()
|
|
|
|
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()
|
|
|
|
user_contact = chats_view.element_by_text(transaction_users_wallet['B_USER']['username'], 'button')
|
2017-12-13 13:12:46 +00:00
|
|
|
user_contact.click()
|
2018-01-03 09:34:40 +00:00
|
|
|
chats_view.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')],
|
2017-11-15 13:44:21 +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'])
|
|
|
|
chats_view = console_view.get_chat_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)
|
|
|
|
user_flow.add_contact(chats_view, recipient_key)
|
2017-11-15 13:44:21 +00:00
|
|
|
for _ in range(3):
|
2018-01-03 09:34:40 +00:00
|
|
|
try:
|
|
|
|
chats_view.back_button.click()
|
|
|
|
except(TimeoutException, NoSuchElementException):
|
|
|
|
pass
|
|
|
|
wallet_view = chats_view.wallet_button.click()
|
|
|
|
wallet_view.send_button.click()
|
|
|
|
send_transaction = wallet_view.get_send_transaction_view()
|
|
|
|
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-03 09:34:40 +00:00
|
|
|
chats_view.wallet_button.click()
|
|
|
|
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'])
|
|
|
|
chats_view = console.get_chat_view()
|
|
|
|
wallet = chats_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))
|