e2e: fee + fixes

Signed-off-by: Churikova Tetiana <churikova.tm@gmail.com>
Signed-off-by: Serhy <sergii@status.im>
This commit is contained in:
Churikova Tetiana 2021-09-08 16:44:20 +02:00 committed by Serhy
parent 0a5abee780
commit c036469409
No known key found for this signature in database
GPG Key ID: 5D7C4B9E2B6F500B
11 changed files with 171 additions and 83 deletions

View File

@ -176,4 +176,16 @@ class NetworkApi(object):
# get actual number of decimals on account balance
decimals = abs(Decimal(fetched_balance).as_tuple().exponent)
rounded_balance = round(float(actual_balance), decimals)
return rounded_balance
return rounded_balance
def get_custom_fee_tx_params(self, hash: str):
price_limit = int(w3.get_tx_param_by_hash(hash, 'maxFeePerGas'),16)/1000000000
tip_limit = int(w3.get_tx_param_by_hash(hash, 'maxPriorityFeePerGas'),16)/1000000000
gas_limit = w3.get_tx_param_by_hash(hash, 'gas')
return {
'fee_cap' : str(price_limit),
'tip_cap': str(tip_limit),
'gas_limit' : str(gas_limit)
}

View File

@ -76,6 +76,10 @@ def balance_of_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)
def to_checksumed_address(address):
return to_checksum_address(address)

View File

@ -556,7 +556,7 @@ class TestCreateAccount(SingleDeviceTestCase):
profile.keycard_button.scroll_and_click()
profile.change_pin_button.click()
keycard.enter_default_pin()
if not home.element_by_translation_id("keycard-is-frozen-title").is_element_displayed():
if not home.element_by_translation_id("keycard-is-frozen-title").is_element_displayed(30):
self.driver.fail("No reset card flow is shown for frozen card")
home.element_by_translation_id("keycard-is-frozen-factory-reset").click()
sign_in.seedphrase_input.set_value(transaction_senders['A']['passphrase'])

View File

@ -822,10 +822,10 @@ class TestMessagesOneToOneChatMultiple(MultipleDeviceTestCase):
message_to_send = symbol + message + symbol if 'quote' not in message else symbol + message
chat_2.chat_message_input.send_keys(message_to_send)
chat_2.send_message_button.click()
if not chat_2.chat_element_by_text(message).is_element_displayed():
if not chat_2.chat_element_by_text(message).is_element_displayed(30):
self.errors.append('%s is not displayed with markdown in public chat for the sender \n' % message)
if not chat_1.chat_element_by_text(message).is_element_displayed():
if not chat_1.chat_element_by_text(message).is_element_displayed(30):
self.errors.append('%s is not displayed with markdown in public chat for the recipient \n' % message)
self.errors.verify_no_errors()

View File

@ -123,7 +123,7 @@ class TestDApps(SingleDeviceTestCase):
profile_view.dapp_tab_button.click(desired_element_text='Accounts')
status_test_dapp.assets_button.click()
send_transaction_view = status_test_dapp.request_stt_button.click()
send_transaction_view.ok_got_it_button.click()
send_transaction_view.ok_got_it_button.wait_and_click()
address = send_transaction_view.get_formatted_recipient_address(address)
if not send_transaction_view.element_by_text(address).is_element_displayed():
self.errors.append("Wallet address %s in not shown in 'From' on Send Transaction screen" % address)

View File

@ -20,7 +20,7 @@ class TestTransactionDApp(SingleDeviceTestCase):
status_test_dapp.wait_for_d_aap_to_load()
status_test_dapp.assets_button.click()
send_transaction = status_test_dapp.request_stt_button.click()
if not send_transaction.onboarding_message.is_element_displayed():
if not send_transaction.onboarding_message.is_element_displayed(30):
self.driver.fail('It seems onboarding screen is not shown.')
home.ok_got_it_button.click()
home.cancel_button.click()

View File

@ -415,10 +415,7 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase):
self.errors.append('Expected error %s is not shown' % url_data[key]['error'])
wallet_view.ok_button.click()
if url_data[key].get('data'):
if 'gas' in key:
actual_data = send_transaction_view.get_values_from_send_transaction_bottom_sheet(gas=True)
else:
actual_data = send_transaction_view.get_values_from_send_transaction_bottom_sheet()
actual_data = send_transaction_view.get_values_from_send_transaction_bottom_sheet()
difference_in_data = url_data[key]['data'].items() - actual_data.items()
if difference_in_data:
self.errors.append(
@ -570,11 +567,9 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase):
@marks.testrail_id(5437)
@marks.medium
@marks.skip
#TODO: rewrite with EIP1559 and #12476
def test_validation_amount_errors(self):
sender = wallet_users['C']
sign_in_view = SignInView(self.driver)
sign_in = SignInView(self.driver)
errors = {'send_transaction_screen': {
'too_precise': 'Amount is too precise. Max number of decimals is 7.',
@ -584,27 +579,18 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase):
'Amount': 'Insufficient funds',
'Network fee': 'Not enough ETH for gas'
},
'gas_prices': {
'1.0000000009': 'Invalid number',
'0.0000000009': 'Min 1 wei',
'-1': 'Min 1 wei'
},
'gas_limit': {
'20999': 'Min 21000 units',
'21000.1': 'Invalid number',
'-21000': 'Min 21000 units'
}
}
warning = 'Warning %s is not shown on %s'
sign_in_view.recover_access(sender['passphrase'])
wallet_view = sign_in_view.wallet_button.click()
wallet_view.accounts_status_account.click()
sign_in.recover_access(sender['passphrase'])
wallet = sign_in.wallet_button.click()
wallet.wait_balance_is_changed('ADI')
wallet.accounts_status_account.click()
screen = 'send transaction screen from wallet'
sign_in_view.just_fyi('Checking %s on %s' % (errors['send_transaction_screen']['too_precise'], screen))
initial_amount_ADI = wallet_view.get_asset_amount_by_name('ADI')
send_transaction = wallet_view.send_transaction_button.click()
sign_in.just_fyi('Checking %s on %s' % (errors['send_transaction_screen']['too_precise'], screen))
initial_amount_ADI = wallet.get_asset_amount_by_name('ADI')
send_transaction = wallet.send_transaction_button.click()
adi_button = send_transaction.asset_by_name('ADI')
send_transaction.select_asset_button.click_until_presence_of_element(send_transaction.eth_asset_in_select_asset_bottom_sheet_button)
adi_button.click()
@ -614,62 +600,39 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase):
if not send_transaction.element_by_text(errors['send_transaction_screen']['too_precise']).is_element_displayed():
self.errors.append(warning % (errors['send_transaction_screen']['too_precise'], screen))
sign_in_view.just_fyi('Checking %s on %s' % (errors['send_transaction_screen']['insufficient_funds'], screen))
sign_in.just_fyi('Checking %s on %s' % (errors['send_transaction_screen']['insufficient_funds'], screen))
send_transaction.amount_edit_box.clear()
send_transaction.amount_edit_box.set_value(str(initial_amount_ADI) + '1')
if not send_transaction.element_by_text(errors['send_transaction_screen']['insufficient_funds']).is_element_displayed():
self.errors.append(warning % (errors['send_transaction_screen']['insufficient_funds'], screen))
wallet_view.close_send_transaction_view_button.click()
wallet_view.close_button.click()
wallet.close_send_transaction_view_button.click()
wallet.close_button.click()
screen = 'sending screen from wallet'
sign_in_view.just_fyi('Checking %s on %s' % (errors['sending_screen']['Network fee'], screen))
sign_in.just_fyi('Checking %s on %s' % (errors['sending_screen']['Network fee'], screen))
account_name = 'new'
wallet_view.add_account(account_name)
wallet_view.get_account_by_name(account_name).click()
wallet_view.send_transaction_button.click()
wallet.add_account(account_name)
wallet.get_account_by_name(account_name).click()
wallet.send_transaction_button.click()
send_transaction.amount_edit_box.set_value('0')
send_transaction.set_recipient_address(ens_user_ropsten['ens'])
send_transaction.next_button.click()
wallet.ok_got_it_button.wait_and_click(30)
if not send_transaction.validation_error_element.is_element_displayed(10):
self.errors.append('Validation icon is not shown when testing %s on %s' % (errors['sending_screen']['Network fee'],screen))
send_transaction.get_validation_icon().click()
# TODO: disbled until redo of Network fee validation element
# if not send_transaction.element_by_text_part(errors['sending_screen']['Network fee']).is_element_displayed(10):
# self.errors.append(warning % (errors['sending_screen']['Network fee'],screen))
send_transaction.sign_with_password.click()
if send_transaction.enter_password_input.is_element_displayed():
self.errors.append('Sign button is active when not enough ETH for gas')
sign_in_view.just_fyi('check validation for Gas Limit and Gas Price')
send_transaction.network_fee_button.click_until_presence_of_element(send_transaction.gas_limit_input)
for key in errors['gas_prices']:
send_transaction.gas_price_input.clear()
send_transaction.gas_price_input.send_keys(key)
if not send_transaction.element_by_text(errors['gas_prices'][key]).is_element_displayed():
self.errors.append("With %s Gas Price value there is no %s error displayed" % (key, errors['gas_prices'][key]))
send_transaction.gas_price_input.clear()
send_transaction.gas_price_input.send_keys('0.1')
for key in errors['gas_limit']:
send_transaction.gas_limit_input.clear()
send_transaction.gas_limit_input.send_keys(key)
if not send_transaction.element_by_text(errors['gas_limit'][key]).is_element_displayed():
self.errors.append("With %s Gas Limit value there is no %s error displayed" % (key, errors['gas_limit'][key]))
send_transaction.gas_limit_input.clear()
send_transaction.gas_limit_input.send_keys('21000')
send_transaction.update_fee_button.click_until_absense_of_element(send_transaction.update_fee_button)
if send_transaction.validation_error_element.is_element_displayed():
self.errors.append('Warning about insufficient funds for gas is shown after updating transaction fee')
send_transaction.cancel_button.click()
screen = 'sending screen from DApp'
sign_in_view.just_fyi('Checking %s on %s' % (errors['sending_screen']['Network fee'], screen))
home_view = wallet_view.home_button.click()
dapp_view = sign_in_view.dapp_tab_button.click()
dapp_view.select_account_button.click()
dapp_view.select_account_by_name(account_name).wait_for_element(30)
dapp_view.select_account_by_name(account_name).click()
status_test_dapp = home_view.open_status_test_dapp()
sign_in.just_fyi('Checking %s on %s' % (errors['sending_screen']['Network fee'], screen))
home = wallet.home_button.click()
dapp = sign_in.dapp_tab_button.click()
dapp.select_account_button.click()
dapp.select_account_by_name(account_name).wait_for_element(30)
dapp.select_account_by_name(account_name).click()
status_test_dapp = home.open_status_test_dapp()
status_test_dapp.wait_for_d_aap_to_load()
status_test_dapp.transactions_button.click_until_presence_of_element(
status_test_dapp.send_two_tx_in_batch_button)
@ -678,6 +641,111 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase):
self.errors.append(warning % (errors['sending_screen']['Network fee'],screen))
self.errors.verify_no_errors()
@marks.testrail_id(695855)
@marks.transaction
@marks.medium
def test_custom_gas_settings(self):
sender = wallet_users['A']
sign_in = SignInView(self.driver)
sign_in.recover_access(sender['passphrase'])
wallet = sign_in.wallet_button.click()
wallet.wait_balance_is_changed()
wallet.accounts_status_account.click()
send_transaction = wallet.send_transaction_button.click()
amount = '0.000%s' % str(random.randint(100000, 999999)) + '1'
send_transaction.amount_edit_box.set_value(amount)
send_transaction.set_recipient_address(ens_user_ropsten['ens'])
send_transaction.next_button.click()
wallet.ok_got_it_button.wait_and_click(30)
send_transaction.network_fee_button.click()
send_transaction = wallet.get_send_transaction_view()
fee_fields = (send_transaction.gas_limit_input, send_transaction.per_gas_tip_limit_input, send_transaction.per_gas_price_limit_input)
[default_limit, default_tip, default_price] = [input.text for input in fee_fields]
wallet.just_fyi("Check basic validation")
values = {
send_transaction.gas_limit_input :
{
'default': default_limit,
'value' : '22000',
'20999' : 'wallet-send-min-units',
'@!': 'invalid-number',
},
send_transaction.per_gas_tip_limit_input:
{
'default': default_tip,
'value': '2.5',
'aaaa' : 'invalid-number',
},
send_transaction.per_gas_price_limit_input:
{
'default': default_price,
'value': '4,000000001',
'-2' : 'invalid-number',
}
}
for field in values:
for key in values[field]:
if key != 'default' and key != 'value':
field.clear()
field.send_keys(key)
if not send_transaction.element_by_translation_id(values[field][key]).is_element_displayed(10):
self.errors.append("%s is not shown for %s" % (values[field][key], field.accessibility_id))
field.clear()
field.set_value(values[field]['value'])
wallet.just_fyi("Set custom fee and check that it will be applied")
send_transaction.save_fee_button.scroll_and_click()
if send_transaction.get_network_fee_from_bottom_sheet() != '0.000088':
self.driver.fail("Custom fee is not applied, in fact it is %s " % send_transaction.get_network_fee_from_bottom_sheet())
send_transaction.sign_transaction()
self.network_api.wait_for_confirmation_of_transaction(sender['address'], amount, confirmations=3)
transaction = wallet.find_transaction_in_history(amount=amount, return_hash=True)
expected_params = {
'fee_cap' : '4.000000001',
'tip_cap': '2.5',
'gas_limit' : '22000'
}
actual_params = self.network_api.get_custom_fee_tx_params(transaction)
if actual_params != expected_params:
self.errors.append('Real params %s for tx do not match expected ' % str(actual_params))
wallet.just_fyi('Verify custom fee data on tx screen')
wallet.swipe_up()
for key in expected_params:
if not wallet.element_by_text_part(expected_params[key]).is_element_displayed():
self.errors.append("Custom tx param %s is not shown on tx history screen" % key)
wallet.just_fyi("Check below fee popup on mainnet")
profile = wallet.profile_button.click()
profile.switch_network()
sign_in.wallet_button.click()
wallet.accounts_status_account.click()
send_transaction = wallet.send_transaction_button.click()
send_transaction.amount_edit_box.set_value(0)
send_transaction.set_recipient_address(ens_user_ropsten['ens'])
send_transaction.next_button.click()
send_transaction.network_fee_button.click()
send_transaction = wallet.get_send_transaction_view()
send_transaction.per_gas_price_limit_input.clear()
send_transaction.per_gas_price_limit_input.click()
send_transaction.per_gas_price_limit_input.send_keys('1')
if not wallet.element_by_translation_id("below-base-fee").is_element_displayed(10):
self.errors.append("Fee is below error is not shown")
send_transaction.save_fee_button.scroll_and_click()
if not wallet.element_by_translation_id("change-tip").is_element_displayed():
self.errors.append("Popup about changing fee error is not shown")
wallet.element_by_translation_id("continue-anyway").click()
if not send_transaction.element_by_text_part('0.000021 ETH').is_element_displayed():
self.driver.fail("Custom fee is not applied!")
self.errors.verify_no_errors()
class TestTransactionWalletMultipleDevice(MultipleDeviceTestCase):

View File

@ -95,25 +95,25 @@ class TestGroupChatMultipleDevice(MultipleDeviceTestCase):
devices_chat[i].request_membership_for_group_chat(introduction_messages[i])
devices_chat[0].just_fyi('Admin: accept request for Member_1 and decline for Member_2')
devices_home[0].get_chat(chat_name).click()
devices_chat[0].group_membership_request_button.click()
devices_chat[0].group_membership_request_button.wait_and_click()
devices_chat[0].element_by_text(devices_username[1]).click()
if not devices_chat[0].element_by_text_part(introduction_messages[1]).is_element_displayed():
self.errors.append('Introduction message is not shown!')
devices_chat[0].accept_group_invitation_button.click()
devices_chat[0].accept_group_invitation_button.wait_and_click()
devices_chat[0].accept_membership_for_group_chat_via_chat_view(devices_username[2], accept=False)
devices_chat[0].click_system_back_button()
devices_chat[2].just_fyi('Member_2: retry request')
devices_chat[2].retry_group_invite_button.click()
devices_chat[2].retry_group_invite_button.wait_and_click()
devices_chat[2].request_membership_for_group_chat(introduction_messages[0])
devices_chat[2].just_fyi('Admin: decline request for Member_2')
devices_chat[0].group_membership_request_button.click()
devices_chat[0].group_membership_request_button.wait_and_click()
devices_chat[0].element_by_text(devices_username[2]).click()
if not devices_chat[0].element_by_text_part(introduction_messages[0]).is_element_displayed():
self.errors.append('Introduction message that was set after retrying attempt is not shown for admin!')
devices_chat[0].decline_group_invitation_button.click()
devices_chat[0].decline_group_invitation_button.wait_and_click()
devices_chat[0].click_system_back_button()
devices_chat[2].just_fyi('Member_2: remove chat')
devices_chat[2].remove_group_invite_button.click()
devices_chat[2].remove_group_invite_button.wait_and_click()
devices_chat[2].just_fyi('Double check after relogin')
if devices_chat[0].group_membership_request_button.is_element_displayed():
self.errors.append('Group membership request is still shown when there are no pending requests anymore')

View File

@ -190,7 +190,7 @@ class AirplaneModeButton(Button):
def click(self):
action = TouchAction(self.driver)
action.press(None, 50, 0).move_to(None, 50, 300).perform()
action.press(None, 200, 0).move_to(None, 200, 300).perform()
super(AirplaneModeButton, self).click()
self.driver.press_keycode(4)

View File

@ -79,11 +79,13 @@ class SendTransactionView(BaseView):
self.set_max_button = Button(self.driver, translation_id="set-max")
self.validation_error_element = Text(self.driver, xpath="//*[@content-desc='custom-gas-fee']/../android.view.ViewGroup//*[@content-desc='icon']")
# Network fee elements
self.network_fee_button = Button(self.driver, accessibility_id="custom-gas-fee")
self.gas_limit_input = EditBox(self.driver, accessibility_id="gas-amount-limit")
self.per_gas_tip_limit_input = EditBox(self.driver, accessibility_id="per-gas-tip-limit")
self.per_gas_price_limit_input = EditBox(self.driver, accessibility_id="per-gas-tip-limit")
self.per_gas_price_limit_input = EditBox(self.driver, accessibility_id="per-gas-price-limit")
self.max_fee_text = Text(self.driver, xpath='//*[@text="Maximum fee:"]/following-sibling::android.widget.TextView[1]')
self.save_fee_button = Button(self.driver, accessibility_id="save-fees")
self.sign_transaction_button = Button(self.driver, accessibility_id="send-transaction-bottom-sheet")
@ -158,21 +160,20 @@ class SendTransactionView(BaseView):
def get_validation_icon(self, field='Network fee'):
return ValidationErrorOnSendTransaction(self.driver, field)
def get_values_from_send_transaction_bottom_sheet(self, gas=False):
def get_values_from_send_transaction_bottom_sheet(self):
self.driver.info("**Getting values from send transaction bottom sheet**")
data = {
'amount': self.amount_edit_box.text,
'asset': self.asset_text.text,
'address': self.enter_recipient_address_text.text
}
if gas:
self.sign_transaction_button.click_until_presence_of_element(self.sign_with_password)
self.network_fee_button.click_until_presence_of_element(self.gas_limit_input)
data['gas_limit'] = self.gas_limit_input.text
data['gas_price'] = self.gas_price_input.text
self.cancel_button.click()
return data
def get_network_fee_from_bottom_sheet(self):
self.driver.info("**Getting network fee from send transaction bottom sheet**")
return Text(self.driver, xpath="//*[@content-desc='custom-gas-fee']/android.widget.TextView[1]").text[0:-9]
def add_to_favorites(self, name):
self.driver.info("**Adding '%s' to favorite recipients**" % name)
self.recipient_add_to_favorites.click()

View File

@ -202,6 +202,9 @@ class SignInView(BaseView):
if not second_user:
self.accept_tos_checkbox.click()
self.get_started_button.click_until_presence_of_element(self.access_key_button)
if not self.access_key_button.is_element_displayed():
self.accept_tos_checkbox.click()
self.get_started_button.click()
self.access_key_button.click()
self.enter_seed_phrase_button.click()
self.seedphrase_input.click()