e2e: ENS purchase in dapp

This commit is contained in:
Churikova Tetiana 2022-06-22 16:09:04 +02:00
parent 78033eedc9
commit 9f9b896eb7
No known key found for this signature in database
GPG Key ID: 0D4EA7B33B47E6D8
4 changed files with 73 additions and 1 deletions

View File

@ -1,5 +1,8 @@
import pprint
from eth_utils import to_checksum_address, is_address
from web3.auto.infura.ropsten import w3
from ens import ENS
token_data = {"STT": [{
@ -7,6 +10,7 @@ token_data = {"STT": [{
"address": "0xc55cF4B03948D7EBc8b9E8BAD92643703811d162"}]}
ACCOUNT_PRIVATE_KEY = '0x5507f8c5c12707770c12fd0fae5d012b947d61f43b9203ae67916e703fd12ad7'
ACCOUNT_ADDRESS = '0xE2363E6e91d1a29d82C2c695fa8fa2e3Fa5d55eA'
class Account(object):
@ -73,9 +77,11 @@ def balance_of_address(address):
else:
return w3.eth.getBalance(to_checksum_address(address))
def transaction_status(hash):
return w3.eth.getTransaction(hash)
def get_tx_param_by_hash(hash: str, param: str):
return getattr(w3.eth.getTransaction(hash), param)
@ -97,6 +103,12 @@ def broadcast_signed_tx(signed_txn):
return w3.toHex(w3.sha3(signed_txn.rawTransaction))
def get_address_from_ens(ens_name, is_stateofus=True):
ns = ENS.fromWeb3(w3)
eth_address = ns.address('%s.stateofus.eth' % ens_name) if is_stateofus is True else ns.address(ens_name)
return eth_address if eth_address else None
account = Account(ACCOUNT_PRIVATE_KEY)
account_address = account.account_address

View File

@ -6,6 +6,7 @@ from tests.users import user_mainnet, chat_users, recovery_users, transaction_se
wallet_users, ens_user_ropsten, ens_user
from tests.base_test_case import SingleDeviceTestCase
from views.sign_in_view import SignInView
import support.api.web3_api as w3
@marks.medium
@ -1043,6 +1044,56 @@ class TestChatManagement(SingleDeviceTestCase):
profile.ok_button.click()
self.errors.verify_no_errors()
@marks.testrail_id(702167)
def test_ens_dapp_purchase(self):
sign_in = SignInView(self.driver)
self.home = sign_in.create_user()
self.ens_name = 'purchased%s' % self.home.get_random_chat_name()
self.wallet = self.home.wallet_button.click()
self.address = self.wallet.get_wallet_address()
self.chat_key = self.home.get_public_key_and_username()
w3.donate_testnet_eth(self.address, amount=0.1, inscrease_default_gas_price=10)
self.home.wallet_button.click()
self.wallet.wait_balance_is_changed()
w3.donate_testnet_token('STT', address=self.address, amount=10, inscrease_default_gas_price=10)
self.wallet.wait_balance_is_changed('STT', scan_tokens=True)
self.profile = self.home.profile_button.click()
self.profile.ens_usernames_button.wait_and_click()
self.dapp = self.home.get_dapp_view()
self.dapp.get_started_ens.click()
self.dapp.ens_name_input.set_value(self.ens_name)
self.dapp.check_ens_name.click_until_presence_of_element(self.dapp.register_ens_button)
self.dapp.agree_on_terms_ens.scroll_and_click()
if not self.dapp.element_by_text(self.chat_key).is_element_displayed():
self.error.append("No chat key for user is shown when register requested chat key")
self.dapp.register_ens_button.click()
self.send_tx = self.home.get_send_transaction_view()
self.send_tx.sign_transaction()
if not self.dapp.element_by_text('Nice! You own %s.stateofus.eth once the transaction is complete.' % self.ens_name).is_element_displayed(60):
self.error.append("ENS name %s is not purchasing" % self.ens_name)
self.dapp.ens_got_it.click()
if self.dapp.registration_in_progress.is_element_displayed(10):
self.dapp.registration_in_progress.wait_for_invisibility_of_element(300)
self.dapp.element_by_text(self.ens_name).click()
for text in ("10 SNT, deposit unlocked", self.chat_key, self.address.lower()):
if not self.dapp.element_by_text(text).is_element_displayed(10):
self.errors.append("%s is not displayed after ENS purchasing" % text)
if not w3.get_address_from_ens(self.ens_name) == self.address:
self.errors.append("ENS name %s is not resolved to correct address %s" % (self.ens_name, self.address))
self.wallet.just_fyi("Send leftovers")
self.wallet.wallet_button.click()
send_transaction = self.wallet.send_transaction_from_main_screen.click()
send_transaction.set_max_button.click()
send_transaction.confirm()
send_transaction.chose_recipient_button.click()
send_transaction.set_recipient_address(w3.ACCOUNT_ADDRESS)
send_transaction.sign_transaction_button.click()
send_transaction.sign_transaction()
self.errors.verify_no_errors()
@marks.testrail_id(6300)
@marks.skip
# TODO: waiting mode (rechecked 23.11.21, valid)

View File

@ -482,6 +482,10 @@ class BaseView(object):
from views.web_views.status_test_dapp import StatusTestDAppView
return StatusTestDAppView(self.driver)
def get_dapp_view(self):
from views.dapps_view import DappsView
return DappsView(self.driver)
def get_home_view(self):
from views.home_view import HomeView
return HomeView(self.driver)

View File

@ -1,5 +1,5 @@
from views.base_element import Button, EditBox, BaseElement
from views.base_view import BaseView
from views.base_view import BaseView, CheckBox, Text
from views.home_view import ChatElement
@ -42,8 +42,13 @@ class DappsView(BaseView):
self.web_page = BaseElement(self.driver, xpath="(//android.webkit.WebView)[1]")
# Ens dapp
self.get_started_ens = Button(self.driver, translation_id="get-started")
self.ens_name_input = EditBox(self.driver, xpath="//android.widget.EditText")
self.check_ens_name = Button(self.driver, xpath="(//android.widget.ImageView[@content-desc='icon'])[2]/../..")
self.agree_on_terms_ens = CheckBox(self.driver, accessibility_id=":checkbox-off")
self.register_ens_button = Button(self.driver, translation_id="ens-register")
self.ens_got_it = Button(self.driver, translation_id="ens-got-it")
self.registration_in_progress = Text(self.driver, translation_id="ens-registration-in-progress")
# Options on long press
self.delete_bookmark_button = Button(self.driver, accessibility_id="delete-bookmark")