Skip to content

Commit

Permalink
Fixed multipleaccount test
Browse files Browse the repository at this point in the history
  • Loading branch information
Serhy committed Sep 26, 2019
1 parent 0a5acfb commit 290afa2
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def test_contact_profile_view(self):
chat_view = home_view.get_chat_view()
chat_view.chat_options.click_until_presence_of_element(chat_view.view_profile_button)
chat_view.view_profile_button.click()
for text in basic_user['username'], 'In contacts', 'Send message', 'Chat key':
for text in basic_user['username'], 'Remove from contacts', 'Send message', 'Block this user':
if not chat_view.element_by_text(text).scroll_to_element():
self.errors.append('%s is not visible' % text)
self.verify_no_errors()
Expand Down
41 changes: 25 additions & 16 deletions test/appium/tests/atomic/transactions/test_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,12 +434,13 @@ def test_send_funds_between_accounts_in_multiaccount_instance(self):
sign_in_view.create_user()
wallet_view = sign_in_view.wallet_button.click()
wallet_view.set_up_wallet()
address = wallet_view.get_wallet_address()[2:]
status_account_address = wallet_view.get_wallet_address()[2:]
wallet_view.back_button.click()
self.network_api.get_donate(address)

account_name = 'test account'
self.network_api.get_donate(status_account_address)
account_name = 'subaccount'
wallet_view.add_account(account_name)

wallet_view.just_fyi("Send transaction to new account")
wallet_view.accounts_status_account.click()
send_transaction = wallet_view.send_transaction_button.click()
send_transaction.amount_edit_box.click()
Expand All @@ -451,8 +452,10 @@ def test_send_funds_between_accounts_in_multiaccount_instance(self):
send_transaction.element_by_text(account_name).click()
send_transaction.sign_transaction_button.click()
send_transaction.sign_transaction()
self.network_api.wait_for_confirmation_of_transaction(address, transaction_amount)
self.network_api.verify_balance_is_updated('0.1', address)
self.network_api.wait_for_confirmation_of_transaction(status_account_address, transaction_amount)
self.network_api.verify_balance_is_updated('0.1', status_account_address)

wallet_view.just_fyi("Verifying previously sent transaction in new account")
wallet_view.back_button.click()
wallet_view.get_account_by_name(account_name).click()
wallet_view.send_transaction_button.click()
Expand All @@ -461,11 +464,12 @@ def test_send_funds_between_accounts_in_multiaccount_instance(self):
if balance_after_receiving_tx != float(transaction_amount):
self.driver.fail('New account balance %s does not match expected %s after receiving a transaction' % (
balance_after_receiving_tx, transaction_amount))
updated_balance = self.network_api.get_balance(address)

wallet_view.just_fyi("Sending eth from new account to main account")
updated_balance = self.network_api.get_balance(status_account_address)
wallet_view.send_transaction_button.click()
send_transaction.amount_edit_box.click()
transaction_amount_1 = round(float(transaction_amount) * 0.7, 11)
transaction_amount_1 = round(float(transaction_amount) * 0.05, 11)
send_transaction.amount_edit_box.set_value(str(transaction_amount_1))
send_transaction.confirm()
send_transaction.chose_recipient_button.click()
Expand All @@ -474,15 +478,20 @@ def test_send_funds_between_accounts_in_multiaccount_instance(self):
send_transaction.sign_transaction_button.click()
total_fee = send_transaction.get_transaction_fee_total()
send_transaction.sign_transaction()
if not wallet_view.wait_for_element_starts_with_text('Transaction sent').is_element_displayed():
self.driver.fail('Transaction was not sent from the new account')
self.network_api.wait_for_confirmation_of_transaction(address, transaction_amount)
self.network_api.verify_balance_is_updated(updated_balance, address)
balance_after_sending_tx = wallet_view.eth_asset_value.text
send_transaction.back_button.click()
sub_account_address = wallet_view.get_wallet_address(account_name)[2:]
self.network_api.wait_for_confirmation_of_transaction(status_account_address, transaction_amount)
self.network_api.verify_balance_is_updated(updated_balance, status_account_address)

wallet_view.just_fyi("Verify total ETH on main wallet view")
send_transaction.back_button.click()
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
expected_balance = str(float(balance_after_receiving_tx) - transaction_amount_1 - float(total_fee))
if balance_after_sending_tx != expected_balance:
self.driver.fail('New account balance %s does not match expected %s after sending a transaction' % (
balance_after_sending_tx, transaction_amount))
total_eth_from_two_accounts = float(wallet_view.eth_asset_value.text)
if total_eth_from_two_accounts != (balance_of_status_account + balance_of_sub_account):
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))


@marks.transaction
Expand Down
3 changes: 3 additions & 0 deletions test/appium/views/base_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,9 @@ def confirm_until_presence_of_element(self, desired_element, attempts=3):
except TimeoutException:
counter += 1

def just_fyi(self, string):
self.driver.info(string)

def click_system_back_button(self):
self.driver.info('Click system back button')
self.driver.press_keycode(4)
Expand Down
9 changes: 6 additions & 3 deletions test/appium/views/wallet_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def __init__(self, driver):

# elements for multiaccount
self.multiaccount_more_options = MultiaccountMoreOptions(self.driver)
self.accounts_status_account = AccountElementButton(self.driver, 'Status account')
self.accounts_status_account = AccountElementButton(self.driver, account_name="Status account")
self.collectibles_button = CollectiblesButton(self.driver)
self.set_currency_button = SetCurrencyButton(self.driver)
self.add_account_button = AddAccountButton(self.driver)
Expand Down Expand Up @@ -385,13 +385,16 @@ def set_up_wallet(self):
self.ok_got_it_button.click()
return phrase

def get_wallet_address(self):
self.accounts_status_account.click()
def get_wallet_address(self, account_name="Status account"):
self.wallet_account_by_name(account_name).click()
self.receive_transaction_button.click()
address = self.address_text.text
self.back_button.click()
return address

def wallet_account_by_name(self, account_name):
return AccountElementButton(self.driver, account_name)

def asset_by_name(self, asset_name):
return AssetTextElement(self.driver, asset_name)

Expand Down

0 comments on commit 290afa2

Please sign in to comment.