wallet update balance and fix failures
Signed-off-by: Churikova Tetiana <churikova.tm@gmail.com>
This commit is contained in:
parent
34a4b9a451
commit
9311fee2ae
|
@ -77,10 +77,10 @@ class NetworkApi(object):
|
|||
(amount, address))
|
||||
return transaction
|
||||
|
||||
def wait_for_confirmation_of_transaction(self, address, amount):
|
||||
def wait_for_confirmation_of_transaction(self, address, amount, token=False):
|
||||
start_time = time.time()
|
||||
while round(time.time() - start_time, ndigits=2) < 900: # should be < idleTimeout capability
|
||||
transaction = self.find_transaction_by_unique_amount(address, amount)
|
||||
transaction = self.find_transaction_by_unique_amount(address, amount, token)
|
||||
if int(transaction['confirmations']) >= 12:
|
||||
return
|
||||
time.sleep(10)
|
||||
|
|
|
@ -32,13 +32,13 @@ unique_password = 'unique' + get_current_time()
|
|||
|
||||
bootnode_address = "enode://a8a97f126f5e3a340cb4db28a1187c325290ec08b2c9a6b1f19845ac86c46f9fac2ba13328822590" \
|
||||
"fd3de3acb09cc38b5a05272e583a2365ad1fa67f66c55b34@167.99.210.203:30404"
|
||||
mailserver_address = "enode://531e252ec966b7e83f5538c19bf1cde7381cc7949026a6e499b6e998e695751aadf26d4c98d5a4eab" \
|
||||
"fb7cefd31c3c88d600a775f14ed5781520a88ecd25da3c6:status-offline-inbox@35.225.227.79:30504"
|
||||
mailserver_address = "enode://e4fc10c1f65c8aed83ac26bc1bfb21a45cc1a8550a58077c8d2de2a0e0cd18e40fd40f7e6f7d02dc" \
|
||||
"6cd06982b014ce88d6e468725ffe2c138e958788d0002a7f:status-offline-inbox@35.239.193.41:443"
|
||||
mailserver_central_2 = 'mail-02.gc-us-central1-a.eth.beta'
|
||||
mailserver_central_3 = 'mail-03.gc-us-central1-a.eth.beta'
|
||||
mailserver_staging_central_1 = 'mail-01.gc-us-central1-a.eth.staging'
|
||||
mailserver_staging_ams_1 = 'mail-01.do-ams3.eth.staging'
|
||||
|
||||
mailserver_staging_hk = 'mail-01.ac-cn-hongkong-c.eth.staging'
|
||||
mailserver_ams_01 = 'mail-01.do-ams3.eth.beta'
|
||||
camera_access_error_text = "To grant the required camera permission, please go to your system settings " \
|
||||
"and make sure that Status > Camera is selected."
|
||||
|
|
|
@ -3,7 +3,7 @@ import re
|
|||
|
||||
from tests import marks, bootnode_address, mailserver_address, camera_access_error_text, \
|
||||
photos_access_error_text, test_dapp_url, test_dapp_name, mailserver_staging_ams_1, mailserver_staging_central_1, \
|
||||
mailserver_ams_01
|
||||
mailserver_staging_hk
|
||||
from tests.base_test_case import SingleDeviceTestCase, MultipleDeviceTestCase
|
||||
from tests.users import transaction_senders, basic_user, ens_user
|
||||
from views.dapps_view import DappsView
|
||||
|
@ -606,7 +606,7 @@ class TestProfileMultipleDevice(MultipleDeviceTestCase):
|
|||
profile_1.sync_settings_button.click()
|
||||
profile_1.mail_server_button.click()
|
||||
# TODO: temporary pin mailserver to avoid issue 9269 - should be disabled after fix
|
||||
mailserver = mailserver_ams_01 if profile_1.element_by_text(mailserver_staging_ams_1).is_element_present() else mailserver_staging_ams_1
|
||||
mailserver = mailserver_staging_hk if profile_1.element_by_text(mailserver_staging_ams_1).is_element_present() else mailserver_staging_ams_1
|
||||
profile_1.mail_server_auto_selection_button.click()
|
||||
profile_1.element_by_text(mailserver).click()
|
||||
profile_1.confirm_button.click()
|
||||
|
|
|
@ -90,7 +90,7 @@ class TestCommandsMultipleDevices(MultipleDeviceTestCase):
|
|||
wallet_1.set_up_wallet()
|
||||
wallet_1.home_button.click()
|
||||
wallet_2.set_up_wallet()
|
||||
init_balance = wallet_2.get_eth_value()
|
||||
init_balance = wallet_2.get_asset_amount_by_name('ETHro')
|
||||
wallet_2.home_button.click()
|
||||
|
||||
chat_1 = home_1.add_contact(recipient['public_key'])
|
||||
|
@ -123,7 +123,7 @@ class TestCommandsMultipleDevices(MultipleDeviceTestCase):
|
|||
chat_2.get_back_to_home_view()
|
||||
home_2.wallet_button.click()
|
||||
try:
|
||||
wallet_2.wait_balance_changed_on_wallet_screen(expected_balance=init_balance + float(amount))
|
||||
wallet_2.wait_balance_is_equal_expected_amount('ETHro', expected_balance=init_balance + float(amount))
|
||||
self.network_api.find_transaction_by_unique_amount(recipient['address'], amount)
|
||||
except Failed as e:
|
||||
self.errors.append(e.msg)
|
||||
|
@ -144,7 +144,7 @@ class TestCommandsMultipleDevices(MultipleDeviceTestCase):
|
|||
wallet_1.set_up_wallet()
|
||||
wallet_1.home_button.click()
|
||||
wallet_2.set_up_wallet()
|
||||
init_balance = wallet_2.get_eth_value()
|
||||
init_balance = wallet_2.get_asset_amount_by_name('ETHro')
|
||||
wallet_2.home_button.click()
|
||||
|
||||
chat_2 = home_2.add_contact(sender['public_key'])
|
||||
|
@ -162,7 +162,7 @@ class TestCommandsMultipleDevices(MultipleDeviceTestCase):
|
|||
chat_2.get_back_to_home_view()
|
||||
home_2.wallet_button.click()
|
||||
try:
|
||||
wallet_2.wait_balance_changed_on_wallet_screen(expected_balance=init_balance + float(amount))
|
||||
wallet_2.wait_balance_is_equal_expected_amount('ETHro', expected_balance=init_balance + float(amount))
|
||||
self.network_api.find_transaction_by_unique_amount(recipient['address'], amount)
|
||||
except Failed as e:
|
||||
self.errors.append(e.msg)
|
||||
|
@ -477,8 +477,8 @@ class TestCommandsSingleDevices(SingleDeviceTestCase):
|
|||
wallet_view = sign_in_view.wallet_button.click()
|
||||
wallet_view.set_up_wallet()
|
||||
wallet_view.accounts_status_account.click()
|
||||
eth_value = wallet_view.get_eth_value()
|
||||
stt_value = wallet_view.get_stt_value()
|
||||
eth_value = wallet_view.get_asset_amount_by_name('ETHro')
|
||||
stt_value = wallet_view.get_asset_amount_by_name('STT')
|
||||
if eth_value == 0 or stt_value == 0:
|
||||
self.driver.fail('No funds!')
|
||||
home_view = wallet_view.home_button.click()
|
||||
|
|
|
@ -157,6 +157,8 @@ class TestTransactionDApp(SingleDeviceTestCase):
|
|||
|
||||
@marks.testrail_id(5372)
|
||||
@marks.high
|
||||
@marks.skip
|
||||
# skipped because it is part of other tests
|
||||
def test_request_eth_in_status_test_dapp(self):
|
||||
sign_in_view = SignInView(self.driver)
|
||||
home_view = sign_in_view.create_user()
|
||||
|
@ -169,7 +171,7 @@ class TestTransactionDApp(SingleDeviceTestCase):
|
|||
status_test_dapp.cross_icon.click()
|
||||
wallet_view = sign_in_view.wallet_button.click()
|
||||
wallet_view.set_up_wallet()
|
||||
wallet_view.wait_balance_changed_on_wallet_screen()
|
||||
wallet_view.wait_balance_is_equal_expected_amount()
|
||||
|
||||
@marks.testrail_id(5355)
|
||||
@marks.medium
|
||||
|
|
|
@ -120,6 +120,40 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase):
|
|||
if send_transaction.element_by_text_part('Transaction sent').is_element_displayed():
|
||||
self.driver.fail('Transaction was sent with a wrong password')
|
||||
|
||||
@marks.testrail_id(6237)
|
||||
@marks.high
|
||||
def test_fetching_balance_after_offline(self):
|
||||
sender = wallet_users['A']
|
||||
sign_in_view = SignInView(self.driver)
|
||||
|
||||
sign_in_view.just_fyi('Restore account with funds offline')
|
||||
sign_in_view.toggle_airplane_mode()
|
||||
sign_in_view.access_key_button.click()
|
||||
sign_in_view.recover_access(sender['passphrase'])
|
||||
home_view = sign_in_view.get_home_view()
|
||||
wallet_view = home_view.wallet_button.click()
|
||||
wallet_view.set_up_wallet()
|
||||
|
||||
sign_in_view.just_fyi('Go back to online and check that balance is updated')
|
||||
sign_in_view.toggle_airplane_mode()
|
||||
wallet_view.wait_balance_is_changed('ETHro')
|
||||
wallet_view.wait_balance_is_changed('STT')
|
||||
|
||||
sign_in_view.just_fyi('Send some tokens to other account')
|
||||
recipient = "0x" + basic_user['address']
|
||||
sending_amount = wallet_view.get_unique_amount()
|
||||
asset = 'STT'
|
||||
wallet_view.accounts_status_account.click_until_presence_of_element(wallet_view.send_transaction_button)
|
||||
wallet_view.send_transaction(asset_name=asset, amount=sending_amount, recipient=recipient,
|
||||
sign_transaction=True)
|
||||
sign_in_view.toggle_airplane_mode()
|
||||
self.network_api.wait_for_confirmation_of_transaction(basic_user['address'], sending_amount, token=True)
|
||||
|
||||
sign_in_view.just_fyi('Change that balance is updated')
|
||||
initial_amount_STT = wallet_view.get_asset_amount_by_name('STT')
|
||||
sign_in_view.toggle_airplane_mode()
|
||||
wallet_view.wait_balance_is_changed('STT', initial_amount_STT)
|
||||
|
||||
@marks.testrail_id(6236)
|
||||
@marks.medium
|
||||
def test_transaction_appears_in_history(self):
|
||||
|
@ -127,11 +161,15 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase):
|
|||
home_view = sign_in_view.create_user()
|
||||
wallet_view = home_view.wallet_button.click()
|
||||
wallet_view.set_up_wallet()
|
||||
|
||||
address = wallet_view.get_wallet_address()[2:]
|
||||
self.network_api.get_donate(address)
|
||||
wallet_view.wait_balance_is_equal_expected_amount()
|
||||
recipient = "0x"+basic_user['address']
|
||||
sending_amount = "0.08"
|
||||
wallet_view.send_transaction(asset_name='ETHro', amount=sending_amount, recipient=recipient, sign_transaction=True)
|
||||
asset = 'ETHro'
|
||||
wallet_view.send_transaction(asset_name=asset, amount=sending_amount, recipient=recipient, sign_transaction=True)
|
||||
wallet_view.wait_balance_is_changed(asset, wallet_view.get_asset_amount_by_name(asset))
|
||||
transactions_view = wallet_view.transaction_history_button.click()
|
||||
transactions_view.transactions_table.find_transaction(amount=sending_amount)
|
||||
transactions_view.transactions_table.find_transaction(amount="0.1")
|
||||
|
@ -256,7 +294,7 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase):
|
|||
wallet_view = sign_in_view.wallet_button.click()
|
||||
wallet_view.set_up_wallet()
|
||||
wallet_view.accounts_status_account.click()
|
||||
bigger_amount = wallet_view.get_eth_value() + 1
|
||||
bigger_amount = wallet_view.get_asset_amount_by_name('ETHro') + 1
|
||||
send_transaction = wallet_view.send_transaction_button.click()
|
||||
amount_edit_box = send_transaction.amount_edit_box
|
||||
amount_edit_box.click()
|
||||
|
@ -304,8 +342,8 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase):
|
|||
sign_in_view.recover_access(sender['passphrase'])
|
||||
wallet_view = sign_in_view.wallet_button.click()
|
||||
wallet_view.set_up_wallet()
|
||||
eth_value = wallet_view.get_eth_value()
|
||||
stt_value = wallet_view.get_stt_value()
|
||||
eth_value = wallet_view.get_asset_amount_by_name('ETHro')
|
||||
stt_value = wallet_view.get_asset_amount_by_name('STT')
|
||||
if eth_value == 0 or stt_value == 0:
|
||||
self.driver.fail('No funds!')
|
||||
wallet_view.accounts_status_account.click()
|
||||
|
|
|
@ -104,9 +104,13 @@ class ChatElement(BaseButton):
|
|||
class UnreadMessagesCountText(BaseText):
|
||||
def __init__(self, driver, parent_locator: str):
|
||||
super(UnreadMessagesCountText, self).__init__(driver)
|
||||
locator_str = "//*[@content-desc='unread-messages-count-text']"
|
||||
# TODO: commented until accessibility-id will be added back
|
||||
# locator_str = "//*[@content-desc='unread-messages-count-text']"
|
||||
# self.locator = self.Locator.xpath_selector(parent_locator + locator_str)
|
||||
locator_str = "/android.view.ViewGroup[3]//android.widget.TextView"
|
||||
self.locator = self.Locator.xpath_selector(parent_locator + locator_str)
|
||||
|
||||
|
||||
return UnreadMessagesCountText(self.driver, self.locator.value)
|
||||
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ class TransactionHistoryButton(BaseButton):
|
|||
|
||||
def __init__(self, driver):
|
||||
super(TransactionHistoryButton, self).__init__(driver)
|
||||
self.locator = self.Locator.xpath_selector("//*[@text='History']")
|
||||
self.locator = self.Locator.text_selector("History")
|
||||
|
||||
def navigate(self):
|
||||
from views.transactions_view import TransactionsView
|
||||
|
@ -33,19 +33,13 @@ class TransactionHistoryButton(BaseButton):
|
|||
class ChooseFromContactsButton(BaseButton):
|
||||
def __init__(self, driver):
|
||||
super(ChooseFromContactsButton, self).__init__(driver)
|
||||
self.locator = self.Locator.xpath_selector("//*[@text='Choose From Contacts']")
|
||||
self.locator = self.Locator.text_selector("Choose From Contacts")
|
||||
|
||||
|
||||
class EthAssetText(BaseText):
|
||||
def __init__(self, driver):
|
||||
super(EthAssetText, self).__init__(driver)
|
||||
self.locator = self.Locator.xpath_selector("//*[@text='ETHro']/preceding-sibling::*[1]")
|
||||
|
||||
|
||||
class STTAssetText(BaseText):
|
||||
def __init__(self, driver):
|
||||
super(STTAssetText, self).__init__(driver)
|
||||
self.locator = self.Locator.xpath_selector("//*[@text='STT']/preceding-sibling::*[1]")
|
||||
class AssetText(BaseText):
|
||||
def __init__(self, driver, asset):
|
||||
super(AssetText, self).__init__(driver)
|
||||
self.locator = self.Locator.xpath_selector("//*[@text='%s']/preceding-sibling::*[1]" % asset)
|
||||
|
||||
|
||||
class UsdTotalValueText(BaseText):
|
||||
|
@ -340,8 +334,6 @@ class WalletView(BaseView):
|
|||
|
||||
self.send_transaction_button = SendTransactionButton(self.driver)
|
||||
self.transaction_history_button = TransactionHistoryButton(self.driver)
|
||||
self.eth_asset_value = EthAssetText(self.driver)
|
||||
self.stt_asset_value = STTAssetText(self.driver)
|
||||
self.usd_total_value = UsdTotalValueText(self.driver)
|
||||
|
||||
self.send_transaction_request = SendTransactionRequestButton(self.driver)
|
||||
|
@ -391,17 +383,16 @@ class WalletView(BaseView):
|
|||
import re
|
||||
return float(re.sub('[~,]', '', self.usd_total_value.text))
|
||||
|
||||
def get_eth_value(self):
|
||||
self.eth_asset_value.scroll_to_element()
|
||||
return float(self.eth_asset_value.text)
|
||||
|
||||
def get_stt_value(self):
|
||||
self.stt_asset_value.scroll_to_element()
|
||||
return float(self.stt_asset_value.text)
|
||||
|
||||
def get_asset_amount_by_name(self, asset: str):
|
||||
asset_value = AssetText(self.driver, asset)
|
||||
asset_value.scroll_to_element()
|
||||
return float(asset_value.text)
|
||||
|
||||
def verify_currency_balance(self, expected_rate: int, errors: list):
|
||||
usd = self.get_usd_total_value()
|
||||
eth = self.get_eth_value()
|
||||
eth = self.get_asset_amount_by_name('ETHro')
|
||||
expected_usd = round(eth * expected_rate, 2)
|
||||
percentage_diff = abs((usd - expected_usd) / ((usd + expected_usd) / 2)) * 100
|
||||
if percentage_diff > 2:
|
||||
|
@ -409,20 +400,41 @@ class WalletView(BaseView):
|
|||
else:
|
||||
self.driver.info('Current USD balance %s is ok' % usd)
|
||||
|
||||
def wait_balance_changed_on_wallet_screen(self, expected_balance=0.1, wait_time=300):
|
||||
|
||||
def wait_balance_is_equal_expected_amount(self, asset ='ETHro', expected_balance=0.1, wait_time=300):
|
||||
counter = 0
|
||||
while True:
|
||||
if counter >= wait_time:
|
||||
self.driver.fail('Balance is not changed during %s seconds!' % wait_time)
|
||||
elif self.get_eth_value() != expected_balance:
|
||||
elif self.get_asset_amount_by_name(asset) != expected_balance:
|
||||
counter += 10
|
||||
time.sleep(10)
|
||||
self.swipe_down()
|
||||
self.driver.info('Waiting %s seconds for ETH update' % counter)
|
||||
self.driver.info('Waiting %s seconds for %s balance update' % (counter,asset))
|
||||
else:
|
||||
self.driver.info('Transaction received, balance updated!')
|
||||
return
|
||||
|
||||
def wait_balance_is_changed(self, asset ='ETHro', initial_balance=0, wait_time=300):
|
||||
counter = 0
|
||||
while True:
|
||||
if counter >= wait_time:
|
||||
self.driver.fail('Balance is not changed during %s seconds!' % wait_time)
|
||||
elif self.asset_by_name(asset).is_element_present() and self.get_asset_amount_by_name(asset) == initial_balance:
|
||||
counter += 10
|
||||
time.sleep(10)
|
||||
self.swipe_down()
|
||||
self.driver.info('Waiting %s seconds for %s to update' % (counter,asset))
|
||||
elif not self.asset_by_name(asset).is_element_present(10):
|
||||
counter += 10
|
||||
time.sleep(10)
|
||||
self.swipe_down()
|
||||
self.driver.info('Waiting %s seconds for %s to display asset' % (counter, asset))
|
||||
else:
|
||||
self.driver.info('Balance is updated!')
|
||||
return
|
||||
|
||||
|
||||
def get_sign_in_phrase(self):
|
||||
return ' '.join([element.text for element in self.sign_in_phrase.find_elements()])
|
||||
|
||||
|
|
Loading…
Reference in New Issue