2017-10-19 13:49:20 +00:00
|
|
|
import pytest
|
2017-11-09 10:55:02 +00:00
|
|
|
|
|
|
|
from apis.ropsten_api import get_balance, verify_balance_is_updated
|
|
|
|
from apis.third_party_apis import get_ethereum_price_in_usd
|
2017-10-19 13:49:20 +00:00
|
|
|
from tests.basetestcase import SingleDeviceTestCase
|
2017-11-09 10:55:02 +00:00
|
|
|
from views.base_view import verify_transaction_in_ropsten
|
|
|
|
from views.chats import get_unique_amount
|
2017-10-19 13:49:20 +00:00
|
|
|
from views.home import HomeView
|
|
|
|
from tests.preconditions import set_password_as_new_user, recover_access
|
2017-12-07 13:14:45 +00:00
|
|
|
from tests import transaction_users_wallet
|
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):
|
2017-10-19 13:49:20 +00:00
|
|
|
home = HomeView(self.driver)
|
|
|
|
set_password_as_new_user(home)
|
|
|
|
chats = home.get_chats()
|
|
|
|
chats.back_button.click()
|
2017-10-23 10:23:14 +00:00
|
|
|
|
2017-10-19 13:49:20 +00:00
|
|
|
wallet_view = chats.wallet_button.click()
|
|
|
|
wallet_view.send_button.click()
|
2017-10-23 10:23:14 +00:00
|
|
|
wallet_view.amount_edit_box.send_keys('asd')
|
|
|
|
wallet_view.find_full_text('Amount is not a valid number')
|
2017-10-19 13:49:20 +00:00
|
|
|
wallet_view.amount_edit_box.send_keys('0,1')
|
|
|
|
wallet_view.find_full_text('Insufficient funds')
|
|
|
|
|
|
|
|
@pytest.mark.wallet
|
|
|
|
@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):
|
|
|
|
home = HomeView(self.driver)
|
2017-10-23 10:23:14 +00:00
|
|
|
recover_access(home,
|
2017-12-07 13:14:45 +00:00
|
|
|
transaction_users_wallet[sender]['passphrase'],
|
|
|
|
transaction_users_wallet[sender]['password'],
|
|
|
|
transaction_users_wallet[sender]['username'])
|
2017-10-23 10:23:14 +00:00
|
|
|
chats = home.get_chats()
|
2017-10-19 13:49:20 +00:00
|
|
|
chats.wait_for_syncing_complete()
|
2017-10-23 10:23:14 +00:00
|
|
|
|
2017-12-07 13:14:45 +00:00
|
|
|
recipient_key = transaction_users_wallet[recipient]['public_key']
|
|
|
|
recipient_address = transaction_users_wallet[recipient]['address']
|
2017-11-09 10:55:02 +00:00
|
|
|
initial_balance_recipient = get_balance(recipient_address)
|
2017-10-23 10:23:14 +00:00
|
|
|
|
2017-10-19 13:49:20 +00:00
|
|
|
chats.plus_button.click()
|
|
|
|
chats.add_new_contact.click()
|
|
|
|
chats.public_key_edit_box.send_keys(recipient_key)
|
|
|
|
chats.confirm()
|
|
|
|
chats.confirm_public_key_button.click()
|
2017-10-23 10:23:14 +00:00
|
|
|
|
2017-11-15 13:44:21 +00:00
|
|
|
for _ in range(3):
|
2017-10-19 13:49:20 +00:00
|
|
|
chats.back_button.click()
|
|
|
|
wallet = chats.wallet_button.click()
|
|
|
|
wallet.send_button.click()
|
|
|
|
wallet.amount_edit_box.click()
|
2017-11-09 10:55:02 +00:00
|
|
|
amount = get_unique_amount()
|
2017-10-23 20:46:49 +00:00
|
|
|
wallet.send_as_keyevent(amount)
|
2017-10-19 13:49:20 +00:00
|
|
|
wallet.confirm()
|
|
|
|
wallet.chose_recipient_button.click()
|
|
|
|
wallet.deny_button.click()
|
|
|
|
wallet.chose_from_contacts_button.click()
|
2017-12-07 13:14:45 +00:00
|
|
|
user_contact = chats.element_by_text(transaction_users_wallet[recipient]['username'], 'button')
|
2017-10-19 13:49:20 +00:00
|
|
|
user_contact.click()
|
2017-10-23 10:23:14 +00:00
|
|
|
|
2017-10-19 13:49:20 +00:00
|
|
|
if test == 'sign_later':
|
|
|
|
chats.sign_later_button.click()
|
|
|
|
wallet.yes_button.click()
|
|
|
|
wallet.ok_button_apk.click()
|
2017-10-23 20:46:49 +00:00
|
|
|
tr_view = wallet.transactions_button.click()
|
|
|
|
tr_view.unsigned_tab.click()
|
|
|
|
tr_view.sign_button.click()
|
2017-10-23 10:23:14 +00:00
|
|
|
|
2017-10-19 13:49:20 +00:00
|
|
|
chats.sign_transaction_button.click()
|
2017-12-07 13:14:45 +00:00
|
|
|
chats.enter_password_input.send_keys(transaction_users_wallet[sender]['password'])
|
2017-10-19 13:49:20 +00:00
|
|
|
chats.sign_transaction_button.click()
|
|
|
|
chats.got_it_button.click()
|
2017-11-09 10:55:02 +00:00
|
|
|
verify_balance_is_updated(initial_balance_recipient, recipient_address)
|
2017-10-23 20:46:49 +00:00
|
|
|
if test == 'sign_later':
|
|
|
|
tr_view.history_tab.click()
|
|
|
|
else:
|
|
|
|
chats.wallet_button.click()
|
|
|
|
tr_view = wallet.transactions_button.click()
|
2017-11-09 10:55:02 +00:00
|
|
|
transaction = tr_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()
|
2017-12-07 13:14:45 +00:00
|
|
|
verify_transaction_in_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
|
|
|
|
def test_balance_and_eth_rate(self):
|
|
|
|
errors = list()
|
|
|
|
home = HomeView(self.driver)
|
|
|
|
recover_access(home,
|
2017-12-07 13:14:45 +00:00
|
|
|
passphrase=transaction_users_wallet['A_USER']['passphrase'],
|
|
|
|
password=transaction_users_wallet['A_USER']['password'],
|
|
|
|
username=transaction_users_wallet['A_USER']['username'])
|
2017-10-23 20:46:49 +00:00
|
|
|
chats = home.get_chats()
|
2017-12-07 13:14:45 +00:00
|
|
|
address = transaction_users_wallet['A_USER']['address']
|
2017-11-09 10:55:02 +00:00
|
|
|
balance = get_balance(address) / 1000000000000000000
|
2017-10-23 20:46:49 +00:00
|
|
|
eth_rate = get_ethereum_price_in_usd()
|
|
|
|
wallet = chats.wallet_button.click()
|
|
|
|
wallet_balance = wallet.get_eth_value()
|
|
|
|
if wallet_balance != balance:
|
|
|
|
errors.append('Balance %s is not equal to the expected %s' % (wallet_balance, balance))
|
|
|
|
wallet.verify_eth_rate(eth_rate, errors)
|
|
|
|
assert not errors, 'errors occurred:\n{}'.format('\n'.join(errors))
|