2020-05-14 10:41:09 +00:00
|
|
|
from support.utilities import get_merged_txs_list
|
2021-11-18 15:16:48 +00:00
|
|
|
from tests import marks
|
2020-05-14 10:41:09 +00:00
|
|
|
from tests.base_test_case import SingleDeviceTestCase
|
|
|
|
from tests.users import transaction_senders, basic_user, wallet_users
|
|
|
|
from views.sign_in_view import SignInView
|
|
|
|
|
|
|
|
|
|
|
|
class TestTransactionWalletSingleDevice(SingleDeviceTestCase):
|
|
|
|
|
|
|
|
@marks.testrail_id(6289)
|
|
|
|
@marks.critical
|
2021-08-20 09:47:30 +00:00
|
|
|
@marks.transaction
|
2020-05-14 10:41:09 +00:00
|
|
|
def test_keycard_send_eth_from_wallet_to_address(self):
|
|
|
|
recipient = basic_user
|
|
|
|
sender = transaction_senders['P']
|
2021-11-18 15:16:48 +00:00
|
|
|
sign_in = SignInView(self.driver)
|
|
|
|
home = sign_in.recover_access(sender['passphrase'], keycard=True)
|
|
|
|
wallet = home.wallet_button.click()
|
|
|
|
wallet.wait_balance_is_changed()
|
|
|
|
transaction_amount = wallet.get_unique_amount()
|
|
|
|
wallet.send_transaction(amount=transaction_amount, sign_transaction=True, keycard=True, recipient='0x%s' % recipient['address'])
|
2020-05-14 10:41:09 +00:00
|
|
|
|
2021-11-18 15:16:48 +00:00
|
|
|
wallet.just_fyi('Check that transaction is appeared in transaction history')
|
|
|
|
transaction = wallet.find_transaction_in_history(amount=transaction_amount, return_hash=True)
|
|
|
|
self.network_api.find_transaction_by_hash(transaction)
|
2020-05-14 10:41:09 +00:00
|
|
|
|
|
|
|
@marks.testrail_id(6291)
|
|
|
|
@marks.critical
|
2021-08-20 09:47:30 +00:00
|
|
|
@marks.transaction
|
2020-05-14 10:41:09 +00:00
|
|
|
def test_keycard_can_see_all_transactions_in_history(self):
|
|
|
|
address = wallet_users['D']['address']
|
|
|
|
passphrase = wallet_users['D']['passphrase']
|
|
|
|
|
|
|
|
ropsten_txs = self.network_api.get_transactions(address)
|
|
|
|
ropsten_tokens = self.network_api.get_token_transactions(address)
|
|
|
|
expected_txs_list = get_merged_txs_list(ropsten_txs, ropsten_tokens)
|
|
|
|
signin_view = SignInView(self.driver)
|
|
|
|
home_view = signin_view.recover_access(passphrase=passphrase, keycard=True)
|
|
|
|
wallet_view = home_view.wallet_button.click()
|
|
|
|
wallet_view.accounts_status_account.click()
|
|
|
|
transaction_view = wallet_view.transaction_history_button.click()
|
|
|
|
|
|
|
|
status_tx_number = transaction_view.transactions_table.get_transactions_number()
|
|
|
|
if status_tx_number < 1:
|
|
|
|
self.driver.fail('No transactions found')
|
|
|
|
|
|
|
|
for n in range(status_tx_number):
|
|
|
|
transactions_details = transaction_view.transactions_table.transaction_by_index(n).click()
|
|
|
|
tx_hash = transactions_details.get_transaction_hash()
|
|
|
|
tx_from = transactions_details.get_sender_address()
|
|
|
|
tx_to = transactions_details.get_recipient_address()
|
|
|
|
if tx_from != expected_txs_list[tx_hash]['from']:
|
|
|
|
self.errors.append('Transactions senders do not match!')
|
|
|
|
if tx_to != expected_txs_list[tx_hash]['to']:
|
|
|
|
self.errors.append('Transactions recipients do not match!')
|
2021-06-18 11:09:03 +00:00
|
|
|
transactions_details.close_button.click_until_presence_of_element(wallet_view.send_transaction_button)
|
2020-05-14 10:41:09 +00:00
|
|
|
|
|
|
|
self.errors.verify_no_errors()
|
|
|
|
|
|
|
|
@marks.testrail_id(6292)
|
2020-11-26 17:33:43 +00:00
|
|
|
@marks.transaction
|
2020-05-14 10:41:09 +00:00
|
|
|
@marks.medium
|
2021-08-20 09:47:30 +00:00
|
|
|
def test_keycard_send_funds_between_accounts_set_max_in_multiaccount_instance(self):
|
2020-12-09 16:37:47 +00:00
|
|
|
sign_in_view = SignInView(self.driver).create_user(keycard=True)
|
2021-08-19 11:41:41 +00:00
|
|
|
wallet = sign_in_view.wallet_button.click()
|
|
|
|
status_account_address = wallet.get_wallet_address()[2:]
|
2020-12-04 17:27:21 +00:00
|
|
|
self.network_api.get_donate(status_account_address, external_faucet=True)
|
2021-08-19 11:41:41 +00:00
|
|
|
wallet.wait_balance_is_changed()
|
2020-05-14 10:41:09 +00:00
|
|
|
account_name = 'subaccount'
|
2021-08-19 11:41:41 +00:00
|
|
|
wallet.add_account(account_name, keycard=True)
|
|
|
|
wallet.get_account_by_name(account_name).click()
|
|
|
|
wallet.get_account_options_by_name(account_name).click()
|
|
|
|
wallet.account_settings_button.click()
|
|
|
|
wallet.swipe_up()
|
|
|
|
|
|
|
|
wallet.just_fyi("Checking that delete account and importing account are not available on keycard")
|
|
|
|
if wallet.delete_account_button.is_element_displayed(10):
|
|
|
|
self.errors.append('Delete account option is shown on added account "On Status Tree"!')
|
|
|
|
wallet.wallet_button.double_click()
|
|
|
|
wallet.add_account_button.click()
|
|
|
|
if wallet.enter_a_seed_phrase_button.is_element_displayed():
|
|
|
|
self.errors.append('Importing account option is available on keycard!')
|
|
|
|
wallet.click_system_back_button()
|
|
|
|
|
|
|
|
wallet.just_fyi("Send transaction to new account")
|
2021-06-08 10:58:26 +00:00
|
|
|
transaction_amount = '0.004'
|
2020-12-08 15:56:57 +00:00
|
|
|
initial_balance = self.network_api.get_balance(status_account_address)
|
2021-11-18 15:16:48 +00:00
|
|
|
wallet.send_transaction(account_name=account_name, amount=transaction_amount, keycard=True)
|
2020-05-14 10:41:09 +00:00
|
|
|
self.network_api.wait_for_confirmation_of_transaction(status_account_address, transaction_amount)
|
2020-12-08 15:56:57 +00:00
|
|
|
self.network_api.verify_balance_is_updated(str(initial_balance), status_account_address)
|
2020-05-14 10:41:09 +00:00
|
|
|
|
2021-08-19 11:41:41 +00:00
|
|
|
wallet.just_fyi("Verifying previously sent transaction in new account")
|
|
|
|
wallet.get_account_by_name(account_name).click()
|
|
|
|
wallet.send_transaction_button.click()
|
|
|
|
wallet.close_send_transaction_view_button.click()
|
|
|
|
balance_after_receiving_tx = float(wallet.get_asset_amount_by_name('ETH'))
|
2020-05-14 10:41:09 +00:00
|
|
|
expected_balance = self.network_api.get_rounded_balance(balance_after_receiving_tx, transaction_amount)
|
|
|
|
if balance_after_receiving_tx != expected_balance:
|
|
|
|
self.driver.fail('New account balance %s does not match expected %s after receiving a transaction' % (
|
|
|
|
balance_after_receiving_tx, transaction_amount))
|
|
|
|
|
2021-08-19 11:41:41 +00:00
|
|
|
wallet.just_fyi("Sending eth from new account to main account")
|
2020-05-14 10:41:09 +00:00
|
|
|
updated_balance = self.network_api.get_balance(status_account_address)
|
2021-06-08 10:58:26 +00:00
|
|
|
transaction_amount_1 = round(float(transaction_amount) * 0.2, 11)
|
2021-08-19 11:41:41 +00:00
|
|
|
wallet.wait_balance_is_changed()
|
|
|
|
wallet.get_account_by_name(account_name).click()
|
2021-11-18 15:16:48 +00:00
|
|
|
send_transaction = wallet.send_transaction(from_main_wallet=False, account_name=wallet.status_account_name,
|
|
|
|
amount=transaction_amount_1, keycard=True)
|
2021-08-19 11:41:41 +00:00
|
|
|
wallet.close_button.click()
|
|
|
|
sub_account_address = wallet.get_wallet_address(account_name)[2:]
|
2020-05-14 10:41:09 +00:00
|
|
|
self.network_api.wait_for_confirmation_of_transaction(sub_account_address, transaction_amount_1)
|
2021-11-18 15:16:48 +00:00
|
|
|
wallet.find_transaction_in_history(amount=format(float(transaction_amount_1), '.11f').rstrip('0'))
|
2020-05-14 10:41:09 +00:00
|
|
|
|
2021-08-19 11:41:41 +00:00
|
|
|
wallet.just_fyi("Check transactions on subaccount")
|
2020-05-14 10:41:09 +00:00
|
|
|
self.network_api.verify_balance_is_updated(updated_balance, status_account_address)
|
|
|
|
|
2021-08-19 11:41:41 +00:00
|
|
|
wallet.just_fyi("Verify total ETH on main wallet view")
|
2021-06-08 10:58:26 +00:00
|
|
|
self.network_api.wait_for_confirmation_of_transaction(status_account_address, transaction_amount_1)
|
2020-05-14 10:41:09 +00:00
|
|
|
self.network_api.verify_balance_is_updated((updated_balance + transaction_amount_1), status_account_address)
|
2021-08-19 11:41:41 +00:00
|
|
|
wallet.close_button.click()
|
2020-05-14 10:41:09 +00:00
|
|
|
balance_of_sub_account = float(self.network_api.get_balance(sub_account_address)) / 1000000000000000000
|
|
|
|
balance_of_status_account = float(self.network_api.get_balance(status_account_address)) / 1000000000000000000
|
2021-08-19 11:41:41 +00:00
|
|
|
wallet.scan_tokens()
|
|
|
|
total_eth_from_two_accounts = float(wallet.get_asset_amount_by_name('ETH'))
|
2020-05-14 10:41:09 +00:00
|
|
|
expected_balance = self.network_api.get_rounded_balance(total_eth_from_two_accounts,
|
|
|
|
(balance_of_status_account + balance_of_sub_account))
|
|
|
|
|
|
|
|
if total_eth_from_two_accounts != expected_balance:
|
|
|
|
self.driver.fail('Total wallet balance %s != of Status account (%s) + SubAccount (%s)' % (
|
|
|
|
total_eth_from_two_accounts, balance_of_status_account, balance_of_sub_account))
|
2020-07-29 15:54:45 +00:00
|
|
|
|
2021-08-19 11:41:41 +00:00
|
|
|
wallet.just_fyi("Check that can set max and send transaction with max amount from subaccount")
|
|
|
|
wallet.get_account_by_name(account_name).click()
|
|
|
|
wallet.send_transaction_button.click()
|
2020-07-29 15:54:45 +00:00
|
|
|
send_transaction.set_max_button.click()
|
|
|
|
set_amount = float(send_transaction.amount_edit_box.text)
|
|
|
|
if set_amount == 0.0 or set_amount >= balance_of_sub_account:
|
|
|
|
self.driver.fail('Value after setting up max amount is set to %s' % str(set_amount))
|
|
|
|
send_transaction.confirm()
|
|
|
|
send_transaction.chose_recipient_button.click()
|
|
|
|
send_transaction.accounts_button.click()
|
2021-08-19 11:41:41 +00:00
|
|
|
send_transaction.element_by_text(wallet.status_account_name).click()
|
2020-07-29 15:54:45 +00:00
|
|
|
send_transaction.sign_transaction_button.click()
|
2021-09-17 16:20:12 +00:00
|
|
|
send_transaction.sign_transaction(keycard=True)
|
2021-08-19 11:41:41 +00:00
|
|
|
wallet.element_by_text('Assets').click()
|
|
|
|
wallet.wait_balance_is_equal_expected_amount(asset='ETH', expected_balance=0)
|