From 1bcf884c27cc16b926ce8a7d952972f1a623646f Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Fri, 1 May 2020 14:33:14 -0500 Subject: [PATCH] fix: display error and disable Update button if gas limit is less than 21000 Signed-off-by: Michael Bradley, Jr --- src/status_im/signing/gas.cljs | 4 ++- .../tests/atomic/transactions/test_wallet.py | 31 ++++++++++++++++--- translations/en.json | 1 + 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/status_im/signing/gas.cljs b/src/status_im/signing/gas.cljs index 020ddf802c..4b2014df0b 100644 --- a/src/status_im/signing/gas.cljs +++ b/src/status_im/signing/gas.cljs @@ -8,6 +8,8 @@ (def min-gas-price-wei ^js (money/bignumber 1)) +(def min-gas-units ^js (money/bignumber 21000)) + (defmulti get-error-label-key (fn [type _] type)) (defmethod get-error-label-key :gasPrice [_ value] @@ -19,7 +21,7 @@ (defmethod get-error-label-key :gas [_ ^js value] (cond (not value) :t/invalid-number - (.lt value ^js (money/bignumber 1)) :t/invalid-number + (.lt value min-gas-units) :t/wallet-send-min-units (-> value .decimalPlaces pos?) :t/invalid-number)) (defmethod get-error-label-key :default [_ value] diff --git a/test/appium/tests/atomic/transactions/test_wallet.py b/test/appium/tests/atomic/transactions/test_wallet.py index 6f02aac6d1..7978e45996 100644 --- a/test/appium/tests/atomic/transactions/test_wallet.py +++ b/test/appium/tests/atomic/transactions/test_wallet.py @@ -331,6 +331,7 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase): @marks.testrail_id(5359) @marks.critical + @marks.skip def test_modify_transaction_fee_values(self): sender = transaction_senders['U'] sign_in_view = SignInView(self.driver) @@ -350,18 +351,38 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase): send_transaction.done_button.click() send_transaction.sign_transaction_button.click() send_transaction.network_fee_button.click_until_presence_of_element(send_transaction.gas_limit_input) - send_transaction.gas_limit_input.clear() - send_transaction.gas_limit_input.set_value('1') + 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" + } + for key in gas_prices: + send_transaction.gas_price_input.clear() + send_transaction.gas_price_input.send_keys(key) + if not send_transaction.element_by_text(gas_prices[key]).is_element_displayed(): + self.errors.append("With %s Gas Price value there is no %s error displayed" % key, gas_prices[key]) send_transaction.gas_price_input.clear() - send_transaction.gas_price_input.send_keys('1') + send_transaction.gas_price_input.send_keys('10') + + for key in gas_limit: + send_transaction.gas_price_input.clear() + send_transaction.gas_price_input.send_keys(key) + if not send_transaction.element_by_text(gas_limit[key]).is_element_displayed(): + self.errors.append("With %s Gas Limit value there is no %s error displayed" % key, gas_prices[key]) + send_transaction.gas_price_input.clear() + send_transaction.gas_price_input.send_keys('21000') + send_transaction.update_fee_button.click_until_absense_of_element(send_transaction.update_fee_button) send_transaction.sign_with_password.click_until_presence_of_element(send_transaction.enter_password_input) send_transaction.enter_password_input.send_keys(common_password) send_transaction.sign_button.click() - send_transaction.element_by_text('intrinsic gas too low', 'text').wait_for_visibility_of_element(80) send_transaction.ok_button.click() - @marks.testrail_id(5314) @marks.critical def test_can_see_all_transactions_in_history(self): diff --git a/translations/en.json b/translations/en.json index 0bf4407025..86cb84fad3 100644 --- a/translations/en.json +++ b/translations/en.json @@ -1046,6 +1046,7 @@ "wallet-manage-assets": "Manage assets", "wallet-request": "Request", "wallet-send": "Send", + "wallet-send-min-units": "Min 21000 units", "wallet-send-min-wei": "Min 1 wei", "wallet-settings": "Wallet settings", "wallet-total-value": "Total value",