e2e: fixes for wallet, community urls and more
This commit is contained in:
parent
e0fe0d2dbd
commit
28da6f8bfc
|
@ -1,11 +1,13 @@
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
|
from datetime import datetime
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from json import JSONDecodeError
|
from json import JSONDecodeError
|
||||||
from os import environ
|
from os import environ
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
import pytz
|
||||||
import requests
|
import requests
|
||||||
from selenium.common import TimeoutException
|
from selenium.common import TimeoutException
|
||||||
|
|
||||||
|
@ -38,7 +40,7 @@ class NetworkApi:
|
||||||
return self.send_etherscan_request(params)
|
return self.send_etherscan_request(params)
|
||||||
|
|
||||||
def get_transactions(self, address: str) -> List[dict]:
|
def get_transactions(self, address: str) -> List[dict]:
|
||||||
params = {'module': 'account', 'action': 'txlist', 'address': address, 'sort': 'desc'}
|
params = {'module': 'account', 'action': 'txlist', 'address': address, 'page': 1, 'offset': 10, 'sort': 'desc'}
|
||||||
return self.send_etherscan_request(params)
|
return self.send_etherscan_request(params)
|
||||||
|
|
||||||
def is_transaction_successful(self, transaction_hash: str) -> int:
|
def is_transaction_successful(self, transaction_hash: str) -> int:
|
||||||
|
@ -106,22 +108,28 @@ class NetworkApi:
|
||||||
self.log("Failed iterate transactions(Etherscan unexpected error): " + str(e))
|
self.log("Failed iterate transactions(Etherscan unexpected error): " + str(e))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
def wait_for_confirmation_of_transaction(self, address, amount, confirmations=6, token=False):
|
def wait_for_confirmation_of_transaction(self, address, tx_time, confirmations=7, token=False):
|
||||||
|
expected_tx_timestamp = datetime.strptime(tx_time, "%Y-%m-%dT%H:%M:%S%z").replace(tzinfo=pytz.UTC)
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
if token:
|
if token:
|
||||||
token_info = "token transaction"
|
token_info = "token transaction"
|
||||||
else:
|
else:
|
||||||
token_info = "ETH transaction"
|
token_info = "ETH transaction"
|
||||||
self.log('Waiting %s %s for %s to have %s confirmations' % (amount, token_info, address, confirmations))
|
self.log('Waiting for %s of %s to have %s confirmations' % (token_info, address, confirmations))
|
||||||
while round(time.time() - start_time, ndigits=2) < 600: # should be < idleTimeout capability
|
while round(time.time() - start_time, ndigits=2) < 600: # should be < idleTimeout capability
|
||||||
transaction = self.find_transaction_by_unique_amount(address, amount, token)
|
if token:
|
||||||
|
transaction = self.get_token_transactions(address)[0]
|
||||||
|
else:
|
||||||
|
transaction = self.get_transactions(address)[0]
|
||||||
|
tx_timestamp = datetime.fromtimestamp(int(transaction['timeStamp'])).replace(tzinfo=pytz.UTC)
|
||||||
|
if tx_timestamp > expected_tx_timestamp:
|
||||||
|
if int(transaction['confirmations']) >= confirmations:
|
||||||
|
return
|
||||||
|
time.sleep(20)
|
||||||
self.log(
|
self.log(
|
||||||
'Expected amount of confirmations is %s, in fact %s' % (confirmations, transaction['confirmations']))
|
'Expected amount of confirmations is %s, in fact %s' % (confirmations, transaction['confirmations']))
|
||||||
if int(transaction['confirmations']) >= confirmations:
|
pytest.fail('The last transaction was not confirmed, address is %s, still has %s confirmations' % (
|
||||||
return
|
address, int(transaction['confirmations'])))
|
||||||
time.sleep(20)
|
|
||||||
pytest.fail('Transaction with amount %s was not confirmed, address is %s, still has %s confirmations' % (
|
|
||||||
amount, address, int(transaction['confirmations'])))
|
|
||||||
|
|
||||||
def verify_balance_is_updated(self, initial_balance, recipient_address, wait_time=360):
|
def verify_balance_is_updated(self, initial_balance, recipient_address, wait_time=360):
|
||||||
counter = 0
|
counter = 0
|
||||||
|
|
|
@ -48,11 +48,11 @@ class TestDeepLinksOneDevice(MultipleSharedDeviceTestCase):
|
||||||
self.profile_view.close_button.click()
|
self.profile_view.close_button.click()
|
||||||
|
|
||||||
community_urls = {
|
community_urls = {
|
||||||
"https://status.app/c/ixyACjgKDVNOVCBjb21tdW5pdHkSHHJlcXVpcmUgMTAgU05UIEdvZXJsaSB0byB1c2UYASIHI2VhYjcwMAM=#zQ3shUeGnhM33QW4g9JfYfeLFAH9ZwbDboNYn5exCR7S3ii1y":
|
"https://status.app/c/ixyACjgKDVNOVCBjb21tdW5pdHkSHHJlcXVpcmUgMTAgU05UIEdvZXJsaSB0byB1c2UYASIHI2VhYjcwMAM=#zQ3shhxbnaCooVQqaEkZRuRbez2SRws52Sas9HxkZNGimLRpi":
|
||||||
"SNT community",
|
"SNT community",
|
||||||
"https://status.app/c/G0UAAMTyNsn2QZDEG0EXftOl8pOEfwEBOOSA_YTfIk85xmADDgINGmxpUHAXzK36bN0fK42Xf4YD2yjPk1z2pbFwFw==#zQ3sheoNX5kiuM393TJ6xDnL57aQoiwFWEuJnazJ6W2eNuh9u":
|
"https://status.app/c/G0UAAMTyNsn2QZDEG0EXftOl8pOEfwEBOOSA_YTfIk85xmADDgINGmxpUHAXzK36bN0fK42Xf4YD2yjPk1z2pbFwFw==#zQ3shQGRffgENQzqDLAVCUbF8S2iPZHFfCGCPbApUfAoCNBMu":
|
||||||
"open community",
|
"open community",
|
||||||
"https://status.app/c/G00AAGS9TbI9mSR-ZNmFrhRjNuEeXAAbcAIUaLLJyjMOG3ACJQ12oIHD78QhzO9s_T5bUeU7rnATWJg3mGgTUemrAg==#zQ3shp9f5M3uyMpwTi3rFpFrP6WCWmNsW9pgK9cjXVTaf2vgj":
|
"https://status.app/c/G00AAGS9TbI9mSR-ZNmFrhRjNuEeXAAbcAIUaLLJyjMOG3ACJQ12oIHD78QhzO9s_T5bUeU7rnATWJg3mGgTUemrAg==#zQ3shf1JfZjB7yJ1EorFnnmeTs2PN5chpD98Li5kLN7wd2SpL":
|
||||||
"closed community"
|
"closed community"
|
||||||
}
|
}
|
||||||
for url, text in community_urls.items():
|
for url, text in community_urls.items():
|
||||||
|
@ -98,11 +98,11 @@ class TestDeepLinksOneDevice(MultipleSharedDeviceTestCase):
|
||||||
self.browser_view.click_system_back_button()
|
self.browser_view.click_system_back_button()
|
||||||
|
|
||||||
community_links = {
|
community_links = {
|
||||||
"status.app://c/ixyACjgKDVNOVCBjb21tdW5pdHkSHHJlcXVpcmUgMTAgU05UIEdvZXJsaSB0byB1c2UYASIHI2VhYjcwMAM=#zQ3shUeGnhM33QW4g9JfYfeLFAH9ZwbDboNYn5exCR7S3ii1y":
|
"status.app://c/ixyACjgKDVNOVCBjb21tdW5pdHkSHHJlcXVpcmUgMTAgU05UIEdvZXJsaSB0byB1c2UYASIHI2VhYjcwMAM=#zQ3shhxbnaCooVQqaEkZRuRbez2SRws52Sas9HxkZNGimLRpi":
|
||||||
"SNT community",
|
"SNT community",
|
||||||
"status.app://c/G0UAAMTyNsn2QZDEG0EXftOl8pOEfwEBOOSA_YTfIk85xmADDgINGmxpUHAXzK36bN0fK42Xf4YD2yjPk1z2pbFwFw==#zQ3sheoNX5kiuM393TJ6xDnL57aQoiwFWEuJnazJ6W2eNuh9u":
|
"status.app://c/G0UAAMTyNsn2QZDEG0EXftOl8pOEfwEBOOSA_YTfIk85xmADDgINGmxpUHAXzK36bN0fK42Xf4YD2yjPk1z2pbFwFw==#zQ3shQGRffgENQzqDLAVCUbF8S2iPZHFfCGCPbApUfAoCNBMu":
|
||||||
"open community",
|
"open community",
|
||||||
"status.app://c/G00AAGS9TbI9mSR-ZNmFrhRjNuEeXAAbcAIUaLLJyjMOG3ACJQ12oIHD78QhzO9s_T5bUeU7rnATWJg3mGgTUemrAg==#zQ3shp9f5M3uyMpwTi3rFpFrP6WCWmNsW9pgK9cjXVTaf2vgj":
|
"status.app://c/G00AAGS9TbI9mSR-ZNmFrhRjNuEeXAAbcAIUaLLJyjMOG3ACJQ12oIHD78QhzO9s_T5bUeU7rnATWJg3mGgTUemrAg==#zQ3shf1JfZjB7yJ1EorFnnmeTs2PN5chpD98Li5kLN7wd2SpL":
|
||||||
"closed community"
|
"closed community"
|
||||||
}
|
}
|
||||||
for link, text in community_links.items():
|
for link, text in community_links.items():
|
||||||
|
|
|
@ -135,11 +135,14 @@ class TestWalletMultipleDevice(MultipleSharedDeviceTestCase):
|
||||||
|
|
||||||
self.wallet_1.just_fyi("Sending funds from wallet")
|
self.wallet_1.just_fyi("Sending funds from wallet")
|
||||||
amount_to_send = 0.0001
|
amount_to_send = 0.0001
|
||||||
|
device_time_before_sending = self.wallet_1.driver.device_time
|
||||||
self.wallet_1.send_asset(address='arb1:' + self.receiver['wallet_address'],
|
self.wallet_1.send_asset(address='arb1:' + self.receiver['wallet_address'],
|
||||||
asset_name='Ether',
|
asset_name='Ether',
|
||||||
amount=amount_to_send)
|
amount=amount_to_send)
|
||||||
|
self.network_api.wait_for_confirmation_of_transaction(address=self.sender['wallet_address'],
|
||||||
|
tx_time=device_time_before_sending)
|
||||||
|
|
||||||
device_time = self.wallet_1.driver.device_time
|
device_time_after_sending = self.wallet_1.driver.device_time
|
||||||
|
|
||||||
self._check_balances_after_tx(amount_to_send, sender_balance, receiver_balance, eth_amount_sender,
|
self._check_balances_after_tx(amount_to_send, sender_balance, receiver_balance, eth_amount_sender,
|
||||||
eth_amount_receiver)
|
eth_amount_receiver)
|
||||||
|
@ -164,10 +167,13 @@ class TestWalletMultipleDevice(MultipleSharedDeviceTestCase):
|
||||||
|
|
||||||
self.wallet_1.just_fyi("Sending asset from drawer")
|
self.wallet_1.just_fyi("Sending asset from drawer")
|
||||||
amount_to_send = 0.0001
|
amount_to_send = 0.0001
|
||||||
|
device_time_before_sending = self.wallet_1.driver.device_time
|
||||||
self.wallet_1.send_asset_from_drawer(address='arb1:' + self.receiver['wallet_address'],
|
self.wallet_1.send_asset_from_drawer(address='arb1:' + self.receiver['wallet_address'],
|
||||||
asset_name='Ether',
|
asset_name='Ether',
|
||||||
amount=amount_to_send)
|
amount=amount_to_send)
|
||||||
device_time = self.wallet_1.driver.device_time
|
self.network_api.wait_for_confirmation_of_transaction(address=self.sender['wallet_address'],
|
||||||
|
tx_time=device_time_before_sending)
|
||||||
|
device_time_after_sending = self.wallet_1.driver.device_time
|
||||||
|
|
||||||
self._check_balances_after_tx(amount_to_send, sender_balance, receiver_balance, eth_amount_sender,
|
self._check_balances_after_tx(amount_to_send, sender_balance, receiver_balance, eth_amount_sender,
|
||||||
eth_amount_receiver)
|
eth_amount_receiver)
|
||||||
|
|
|
@ -290,8 +290,11 @@ class ProfileView(BaseView):
|
||||||
self.advertise_device_button = Button(self.driver, accessibility_id="advertise-device")
|
self.advertise_device_button = Button(self.driver, accessibility_id="advertise-device")
|
||||||
self.sync_all_button = Button(self.driver, translation_id="sync-all-devices")
|
self.sync_all_button = Button(self.driver, translation_id="sync-all-devices")
|
||||||
self.syncing_button = Button(self.driver, accessibility_id="icon, Syncing, label-component, icon")
|
self.syncing_button = Button(self.driver, accessibility_id="icon, Syncing, label-component, icon")
|
||||||
self.sync_plus_button = Button(self.driver,
|
self.paired_devices_button = Button(self.driver,
|
||||||
xpath="//*[@text='Syncing']/following-sibling::android.view.ViewGroup[1]")
|
accessibility_id="icon, Paired devices, 0 devices, label-component, icon")
|
||||||
|
self.sync_plus_button = Button(
|
||||||
|
self.driver,
|
||||||
|
xpath="//*[@text='Paired devices']/following-sibling::android.view.ViewGroup[@content-desc='icon']")
|
||||||
|
|
||||||
# Keycard
|
# Keycard
|
||||||
self.keycard_button = Button(self.driver, accessibility_id="keycard-button")
|
self.keycard_button = Button(self.driver, accessibility_id="keycard-button")
|
||||||
|
@ -539,6 +542,7 @@ class ProfileView(BaseView):
|
||||||
|
|
||||||
def get_sync_code(self):
|
def get_sync_code(self):
|
||||||
self.syncing_button.scroll_and_click()
|
self.syncing_button.scroll_and_click()
|
||||||
|
self.paired_devices_button.click()
|
||||||
self.sync_plus_button.click()
|
self.sync_plus_button.click()
|
||||||
for checkbox in Button(
|
for checkbox in Button(
|
||||||
self.driver,
|
self.driver,
|
||||||
|
|
|
@ -261,7 +261,7 @@ class SignInView(BaseView):
|
||||||
# self.identifiers_button.wait_and_click(30)
|
# self.identifiers_button.wait_and_click(30)
|
||||||
if enable_notifications:
|
if enable_notifications:
|
||||||
self.enable_notifications_button.click_until_presence_of_element(self.start_button)
|
self.enable_notifications_button.click_until_presence_of_element(self.start_button)
|
||||||
if self.allow_button.is_element_displayed():
|
if self.allow_button.is_element_displayed(10):
|
||||||
self.allow_button.click()
|
self.allow_button.click()
|
||||||
else:
|
else:
|
||||||
self.maybe_later_button.click_until_presence_of_element(self.start_button)
|
self.maybe_later_button.click_until_presence_of_element(self.start_button)
|
||||||
|
|
|
@ -160,7 +160,6 @@ class WalletView(BaseView):
|
||||||
self.add_account_button.click()
|
self.add_account_button.click()
|
||||||
self.add_account_to_watch.click()
|
self.add_account_to_watch.click()
|
||||||
self.address_to_watch_input.send_keys(address)
|
self.address_to_watch_input.send_keys(address)
|
||||||
self.account_has_activity_label.wait_for_visibility_of_element()
|
|
||||||
self.add_account_continue_button.click()
|
self.add_account_continue_button.click()
|
||||||
SignInView(self.driver).profile_title_input.send_keys(account_name)
|
SignInView(self.driver).profile_title_input.send_keys(account_name)
|
||||||
self.add_watched_address_button.click()
|
self.add_watched_address_button.click()
|
||||||
|
|
Loading…
Reference in New Issue