From d2f3790ed209efbb7010e8a5aa17d659329d3e9d Mon Sep 17 00:00:00 2001 From: Jamie Caprani Date: Thu, 22 Feb 2024 14:49:16 +0000 Subject: [PATCH 1/5] chore(wallet): add integration test for send flows --- modules/react-native-status/nodejs/status.cpp | 62 ++++++++++++++++++ src/mocks/js_dependencies.cljs | 2 +- src/react_native/keychain.cljs | 2 +- src/test_helpers/integration.clj | 14 +++- src/test_helpers/integration.cljs | 54 ++++++++++++---- src/tests/contract_test/core_test.cljs | 4 +- src/tests/integration_test/constants.cljs | 8 +++ src/tests/integration_test/core_test.cljs | 4 +- src/tests/integration_test/profile_test.cljs | 4 +- src/tests/integration_test/wallet_test.cljs | 64 +++++++++++++++++++ .../utils/test.cljs => tests/test_utils.cljs} | 9 ++- 11 files changed, 206 insertions(+), 21 deletions(-) create mode 100644 src/tests/integration_test/wallet_test.cljs rename src/{legacy/status_im/utils/test.cljs => tests/test_utils.cljs} (94%) diff --git a/modules/react-native-status/nodejs/status.cpp b/modules/react-native-status/nodejs/status.cpp index 87f07516d2b..d246c056de6 100644 --- a/modules/react-native-status/nodejs/status.cpp +++ b/modules/react-native-status/nodejs/status.cpp @@ -670,6 +670,36 @@ void _ToChecksumAddress(const FunctionCallbackInfo& args) { } +void _LoginAccount(const FunctionCallbackInfo& args) { + Isolate* isolate = args.GetIsolate(); + Local context = isolate->GetCurrentContext(); + + if (args.Length() != 1) { + // Throw an Error that is passed back to JavaScript + isolate->ThrowException(Exception::TypeError( + String::NewFromUtf8Literal(isolate, "Wrong number of arguments for Login"))); + return; + } + + // Check the argument types + + if (!args[0]->IsString()) { + isolate->ThrowException(Exception::TypeError( + String::NewFromUtf8Literal(isolate, "Wrong argument type for 'passwords'"))); + return; + } + + String::Utf8Value arg0Obj(isolate, args[0]->ToString(context).ToLocalChecked()); + char *arg0 = *arg0Obj; + + // Call exported Go function, which returns a C string + char *c = LoginAccount(arg0); + + Local ret = String::NewFromUtf8(isolate, c).ToLocalChecked(); + args.GetReturnValue().Set(ret); + delete c; +} + void _Logout(const FunctionCallbackInfo& args) { Isolate* isolate = args.GetIsolate(); @@ -844,6 +874,36 @@ void _CreateAccountAndLogin(const FunctionCallbackInfo& args) { } +void _RestoreAccountAndLogin(const FunctionCallbackInfo& args) { + Isolate* isolate = args.GetIsolate(); + Local context = isolate->GetCurrentContext(); + + if (args.Length() != 1) { + // Throw an Error that is passed back to JavaScript + isolate->ThrowException(Exception::TypeError( + String::NewFromUtf8Literal(isolate, "Wrong number of arguments for RestoreAccountAndLogin"))); + return; + } + + // Check the argument types + + if (!args[0]->IsString()) { + isolate->ThrowException(Exception::TypeError( + String::NewFromUtf8Literal(isolate, "Wrong argument type for 'RestoreAccountAndLogin'"))); + return; + } + + String::Utf8Value arg0Obj(isolate, args[0]->ToString(context).ToLocalChecked()); + char *arg0 = *arg0Obj; + + // Call exported Go function, which returns a C string + char *c = RestoreAccountAndLogin(arg0); + + Local ret = String::NewFromUtf8(isolate, c).ToLocalChecked(); + args.GetReturnValue().Set(ret); + delete c; +} + void _ValidateMnemonic(const FunctionCallbackInfo& args) { Isolate* isolate = args.GetIsolate(); Local context = isolate->GetCurrentContext(); @@ -1911,11 +1971,13 @@ void init(Local exports) { NODE_SET_METHOD(exports, "isAddress", _IsAddress); NODE_SET_METHOD(exports, "sha3", _Sha3); NODE_SET_METHOD(exports, "toChecksumAddress", _ToChecksumAddress); + NODE_SET_METHOD(exports, "loginAccount", _LoginAccount); NODE_SET_METHOD(exports, "logout", _Logout); NODE_SET_METHOD(exports, "hashMessage", _HashMessage); NODE_SET_METHOD(exports, "resetChainData", _ResetChainData); NODE_SET_METHOD(exports, "saveAccountAndLogin", _SaveAccountAndLogin); NODE_SET_METHOD(exports, "createAccountAndLogin", _CreateAccountAndLogin); + NODE_SET_METHOD(exports, "restoreAccountAndLogin", _RestoreAccountAndLogin); NODE_SET_METHOD(exports, "validateMnemonic", _ValidateMnemonic); NODE_SET_METHOD(exports, "multiformatSerializePublicKey", _MultiformatSerializePublicKey); NODE_SET_METHOD(exports, "saveAccountAndLoginWithKeycard", _SaveAccountAndLoginWithKeycard); diff --git a/src/mocks/js_dependencies.cljs b/src/mocks/js_dependencies.cljs index ec5d44576ea..adb2ae350c1 100644 --- a/src/mocks/js_dependencies.cljs +++ b/src/mocks/js_dependencies.cljs @@ -2,7 +2,7 @@ (:require-macros [legacy.status-im.utils.slurp :refer [slurp]]) (:require [legacy.status-im.fleet.default-fleet :refer (default-fleets)]) - (:require [legacy.status-im.utils.test :as utils.test])) + (:require [tests.test-utils :as utils.test])) ;; to generate a js Proxy at js/__STATUS_MOBILE_JS_IDENTITY_PROXY__ that accept any (.xxx) call and ;; return itself diff --git a/src/react_native/keychain.cljs b/src/react_native/keychain.cljs index 0a3c7e1e401..4096176034d 100644 --- a/src/react_native/keychain.cljs +++ b/src/react_native/keychain.cljs @@ -80,5 +80,5 @@ (defn reset-credentials [server] - (-> (.resetInternetCredentials ^js react-native-keychain (string/lower-case server)) + (-> (.resetInternetCredentials ^js react-native-keychain (when server (string/lower-case server))) (.then #(when-not % (log/error (str "Error while clearing saved password.")))))) diff --git a/src/test_helpers/integration.clj b/src/test_helpers/integration.clj index 0018e6dae5f..5e519dd7d6f 100644 --- a/src/test_helpers/integration.clj +++ b/src/test_helpers/integration.clj @@ -5,7 +5,7 @@ (defmacro with-app-initialized [& body] `(do - (legacy.status-im.utils.test/init!) + (tests.test/init!) (if (test-helpers.integration/app-initialized) (do ~@body) (do @@ -22,3 +22,15 @@ (rf-test/wait-for [:messenger-started] (test-helpers.integration/assert-messenger-started) ~@body)))) + +(defmacro with-recovered-account + [& body] + `(if (test-helpers.integration/messenger-started) + (do ~@body) + (do + (test-helpers.integration/recover-multiaccount!) + (rf-test/wait-for + [:messenger-started] + (test-helpers.integration/enable-testnet!) + (test-helpers.integration/assert-messenger-started) + ~@body)))) diff --git a/src/test_helpers/integration.cljs b/src/test_helpers/integration.cljs index 36f0ef48810..42b07acc8b9 100644 --- a/src/test_helpers/integration.cljs +++ b/src/test_helpers/integration.cljs @@ -6,11 +6,24 @@ legacy.status-im.subs.root [native-module.core :as native-module] [re-frame.core :as rf] + status-im.contexts.onboarding.events status-im.events status-im.navigation.core status-im.subs.root [taoensso.timbre :as log] - [tests.integration-test.constants :as constants])) + [tests.integration-test.constants :as constants] + [utils.security.core :as security] + [utils.transforms :as transforms])) + +(defn validate-mnemonic + [mnemonic on-success on-error] + (native-module/validate-mnemonic + (security/safe-unmask-data mnemonic) + (fn [result] + (let [{:keys [error keyUID]} (transforms/json->clj result)] + (if (seq error) + (when on-error (on-error error)) + (on-success mnemonic keyUID)))))) (defn initialize-app! [] @@ -21,6 +34,35 @@ (rf/dispatch [:profile.create/create-and-login {:display-name constants/account-name :password constants/password :color "blue"}])) +(defn recover-and-login + [seed-phrase] + (rf/dispatch [:profile.recover/recover-and-login + {:display-name (:name constants/recovery-account) + :seed-phrase seed-phrase + :password constants/password + :color "blue"}])) + +(defn recover-multiaccount! + [] + (let [masked-seed-phrase (security/mask-data (:seed-phrase constants/recovery-account))] + (validate-mnemonic + masked-seed-phrase + (fn [mnemonic key-uid] + (rf/dispatch [:onboarding/seed-phrase-validated + (security/mask-data mnemonic) key-uid]) + (rf/dispatch [:pop-to-root :profiles]) + (rf/dispatch [:profile/profile-selected key-uid]) + (recover-and-login mnemonic)) + #()))) + +(defn enable-testnet! + [] + (rf/dispatch [:profile.settings/profile-update :test-networks-enabled? + true {}]) + ; can be removed soon + (rf/dispatch [:profile.settings/profile-update :is-sepolia-enabled? true {}]) + (rf/dispatch [:wallet/initialize])) + (defn app-initialized [] (let [app-state @(rf/subscribe [:app-state])] @@ -42,16 +84,6 @@ [] (is (= @(rf/subscribe [:communities/create]) constants/community))) -(defn create-new-account! - [] - (rf/dispatch-sync [:wallet-legacy.accounts/start-adding-new-account {:type :generate}]) - (rf/dispatch-sync [:set-in [:add-account :account :name] constants/account-name]) - (rf/dispatch [:wallet-legacy.accounts/add-new-account (native-module/sha3 constants/password)])) - -(defn assert-new-account-created - [] - (is (true? (some #(= (:name %) constants/account-name) - @(rf/subscribe [:profile/wallet-accounts]))))) (defn logout [] diff --git a/src/tests/contract_test/core_test.cljs b/src/tests/contract_test/core_test.cljs index 046f291b833..2776e1e5d1e 100644 --- a/src/tests/contract_test/core_test.cljs +++ b/src/tests/contract_test/core_test.cljs @@ -5,12 +5,12 @@ legacy.status-im.events [legacy.status-im.multiaccounts.logout.core :as logout] legacy.status-im.subs.root - [legacy.status-im.utils.test :as utils.test] [re-frame.core :as rf] status-im.events status-im.navigation.core status-im.subs.root - [test-helpers.integration :as h])) + [test-helpers.integration :as h] + [tests.test-utils :as utils.test])) (deftest initialize-app-test (h/log-headline :initialize-app-test) diff --git a/src/tests/integration_test/constants.cljs b/src/tests/integration_test/constants.cljs index 4f72fb39352..d2d2e2ae225 100644 --- a/src/tests/integration_test/constants.cljs +++ b/src/tests/integration_test/constants.cljs @@ -5,3 +5,11 @@ (def community {:membership 1 :name "foo" :description "bar"}) (def account-name "account-abc") + + +(def recovery-account + {:name "wallet-abc" + :seed-phrase "destroy end torch puzzle develop note wise island disease chaos kind bus" + :key-uid "0x6827f3d1e21ae723a24e0dcbac1853b5ed4d651c821a2326492ce8f2367ec905" + :public-key "0x48b8b9e2a8f71e1beae729d83bcd385ffc6af0d5" + }) diff --git a/src/tests/integration_test/core_test.cljs b/src/tests/integration_test/core_test.cljs index bc98c707032..b385e06d593 100644 --- a/src/tests/integration_test/core_test.cljs +++ b/src/tests/integration_test/core_test.cljs @@ -5,12 +5,12 @@ legacy.status-im.events [legacy.status-im.multiaccounts.logout.core :as logout] legacy.status-im.subs.root - [legacy.status-im.utils.test :as utils.test] [re-frame.core :as rf] status-im.events status-im.navigation.core status-im.subs.root - [test-helpers.integration :as h])) + [test-helpers.integration :as h] + [tests.test-utils :as utils.test])) (deftest initialize-app-test (h/log-headline :initialize-app-test) diff --git a/src/tests/integration_test/profile_test.cljs b/src/tests/integration_test/profile_test.cljs index 29c7bd0dbb5..e3a126bafaa 100644 --- a/src/tests/integration_test/profile_test.cljs +++ b/src/tests/integration_test/profile_test.cljs @@ -3,9 +3,9 @@ [cljs.test :refer [deftest is]] [day8.re-frame.test :as rf-test] [legacy.status-im.multiaccounts.logout.core :as logout] - [legacy.status-im.utils.test :as utils.test] [status-im.contexts.profile.utils :as profile.utils] [test-helpers.integration :as h] + [tests.test-utils :as test-utils] [utils.re-frame :as rf])) (deftest edit-profile-name-test @@ -28,7 +28,7 @@ (deftest edit-profile-picture-test (h/log-headline :edit-profile-picture-test) (let [mock-image "resources/images/mock2/monkey.png" - absolute-path (.resolve utils.test/path mock-image)] + absolute-path (.resolve test-utils/path mock-image)] (rf-test/run-test-async (h/with-app-initialized (h/with-account diff --git a/src/tests/integration_test/wallet_test.cljs b/src/tests/integration_test/wallet_test.cljs new file mode 100644 index 00000000000..b30aff3f090 --- /dev/null +++ b/src/tests/integration_test/wallet_test.cljs @@ -0,0 +1,64 @@ +(ns tests.integration-test.wallet-test + (:require + [cljs.test :refer [deftest is]] + [day8.re-frame.test :as rf-test] + legacy.status-im.events + legacy.status-im.subs.root + status-im.events + status-im.navigation.core + status-im.subs.root + [test-helpers.integration :as h] + [tests.integration-test.constants :as test-constants] + [utils.re-frame :as rf] + [utils.security.core :as security])) + +(defn get-default-account + [accounts] + (first (filter :wallet accounts))) + +(def send-amount "0.00001") + +(deftest wallet-send-test + (h/log-headline :wallet-send-test) + (rf-test/run-test-async + (h/with-app-initialized + (h/with-recovered-account + (rf-test/wait-for + [:wallet/get-wallet-token] + (let [accs (rf/sub [:wallet/accounts]) + default-account (get-default-account accs) + address (:address default-account)] + ;; navigate to account page + (rf/dispatch [:wallet/navigate-to-account (:address default-account)]) + (rf-test/wait-for [:wallet/navigate-to-account] + ;; set the receipient address (same address as sender to avoid token loss) + (rf/dispatch [:wallet/select-send-address + {:address address + :token true + :receipient address + :stack-id :wallet-select-address}]) + (let [filtered-tokens (rf/sub [:wallet/tokens-filtered "eth"])] + (rf/dispatch [:wallet/send-select-token + {:token (first filtered-tokens) + :stack-id :wallet-select-asset}]) + (rf-test/wait-for + [:wallet/clean-suggested-routes] + (rf/dispatch + [:wallet/get-suggested-routes send-amount])) + (rf-test/wait-for + [:wallet/suggested-routes-success] + (let [route (rf/sub [:wallet/wallet-send-route])] + (is (true? (some? route))) + (rf/dispatch [:wallet/send-select-amount + {:amount send-amount + :stack-id :wallet-send-input-amount}]) + (rf/dispatch + [:wallet/send-transaction + (security/safe-unmask-data (security/hash-masked-password + (security/mask-data test-constants/password)))]) + (rf-test/wait-for [:wallet/pending-transaction-status-changed-received] + (let [transaction-details (rf/sub [:wallet/send-transaction-progress])] + (is (= :confirmed (-> transaction-details vals first :status))) + (h/logout) + (rf-test/wait-for + [:legacy.status-im.multiaccounts.logout.core/logout-method]))))))))))))) diff --git a/src/legacy/status_im/utils/test.cljs b/src/tests/test_utils.cljs similarity index 94% rename from src/legacy/status_im/utils/test.cljs rename to src/tests/test_utils.cljs index 4bfb83d7b1c..9708b7581f2 100644 --- a/src/legacy/status_im/utils/test.cljs +++ b/src/tests/test_utils.cljs @@ -1,4 +1,4 @@ -(ns legacy.status-im.utils.test +(ns tests.test-utils (:require [legacy.status-im.utils.deprecated-types :as types] [re-frame.core :as re-frame])) @@ -70,6 +70,12 @@ (callback (.openAccounts native-status test-dir))) :createAccountAndLogin (fn [request] (.createAccountAndLogin native-status request)) + :restoreAccountAndLogin + (fn [request] + (prn native-status) + (.restoreAccountAndLogin native-status request)) + :loginAccount + (fn [request] (.loginAccount native-status request)) :logout (fn [] (.logout native-status)) :multiAccountImportMnemonic @@ -128,3 +134,4 @@ (fn [] (.fleets native-status)) :startLocalNotifications identity})) + From f31246bed503b1ba2a8cc6494281aab8ff9b7a6a Mon Sep 17 00:00:00 2001 From: Icaro Motta Date: Thu, 22 Feb 2024 08:56:06 -0300 Subject: [PATCH 2/5] Fix: only run unit tests in test-unit target --- Makefile | 2 +- src/test_helpers/integration.clj | 2 +- src/test_helpers/integration.cljs | 1 - src/tests/integration_test/constants.cljs | 1 - src/tests/integration_test/wallet_test.cljs | 5 +++-- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index faa86c44a77..6ae2ca02b94 100644 --- a/Makefile +++ b/Makefile @@ -359,7 +359,7 @@ test-watch-for-repl: ##@test Watch all Clojure tests and support REPL connection "until [ -f $$SHADOW_OUTPUT_TO ] ; do sleep 1 ; done ; node --require ./test-resources/override.js $$SHADOW_OUTPUT_TO --repl" test-unit: export SHADOW_OUTPUT_TO := target/unit_test/test.js -test-unit: export SHADOW_NS_REGEXP := ^(?!tests\.integration-test)(?!tests-im\.contract-test).*-test$$ +test-unit: export SHADOW_NS_REGEXP := ^(?!tests\.integration-test)(?!tests\.contract-test).*-test$$ test-unit: ##@test Run unit tests test-unit: _test-clojure diff --git a/src/test_helpers/integration.clj b/src/test_helpers/integration.clj index 5e519dd7d6f..a975aca8f5d 100644 --- a/src/test_helpers/integration.clj +++ b/src/test_helpers/integration.clj @@ -5,7 +5,7 @@ (defmacro with-app-initialized [& body] `(do - (tests.test/init!) + (tests.test-utils/init!) (if (test-helpers.integration/app-initialized) (do ~@body) (do diff --git a/src/test_helpers/integration.cljs b/src/test_helpers/integration.cljs index 42b07acc8b9..71c65e5c29f 100644 --- a/src/test_helpers/integration.cljs +++ b/src/test_helpers/integration.cljs @@ -84,7 +84,6 @@ [] (is (= @(rf/subscribe [:communities/create]) constants/community))) - (defn logout [] (rf/dispatch [:logout])) diff --git a/src/tests/integration_test/constants.cljs b/src/tests/integration_test/constants.cljs index d2d2e2ae225..fcdc1a3316a 100644 --- a/src/tests/integration_test/constants.cljs +++ b/src/tests/integration_test/constants.cljs @@ -6,7 +6,6 @@ (def account-name "account-abc") - (def recovery-account {:name "wallet-abc" :seed-phrase "destroy end torch puzzle develop note wise island disease chaos kind bus" diff --git a/src/tests/integration_test/wallet_test.cljs b/src/tests/integration_test/wallet_test.cljs index b30aff3f090..280f922aee6 100644 --- a/src/tests/integration_test/wallet_test.cljs +++ b/src/tests/integration_test/wallet_test.cljs @@ -16,7 +16,7 @@ [accounts] (first (filter :wallet accounts))) -(def send-amount "0.00001") +(def send-amount "0.0001") (deftest wallet-send-test (h/log-headline :wallet-send-test) @@ -38,13 +38,14 @@ :receipient address :stack-id :wallet-select-address}]) (let [filtered-tokens (rf/sub [:wallet/tokens-filtered "eth"])] + (rf/dispatch [:wallet/send-select-token {:token (first filtered-tokens) :stack-id :wallet-select-asset}]) (rf-test/wait-for [:wallet/clean-suggested-routes] (rf/dispatch - [:wallet/get-suggested-routes send-amount])) + [:wallet/get-suggested-routes {:amount send-amount}])) (rf-test/wait-for [:wallet/suggested-routes-success] (let [route (rf/sub [:wallet/wallet-send-route])] From 6bdf9126357bdb6dbbc183e03dd40f4a7575dfbf Mon Sep 17 00:00:00 2001 From: Jamie Caprani Date: Thu, 22 Feb 2024 17:13:06 +0000 Subject: [PATCH 3/5] infure --- src/status_im/config.cljs | 4 ++-- src/tests/integration_test/wallet_test.cljs | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/status_im/config.cljs b/src/status_im/config.cljs index bd59c5d0bc3..1ffe44ce6fc 100644 --- a/src/status_im/config.cljs +++ b/src/status_im/config.cljs @@ -9,7 +9,7 @@ (defn enabled? [v] (= "1" v)) -(goog-define INFURA_TOKEN "") +(goog-define INFURA_TOKEN "d7aaebc4a3584b5198682ced53801cd3") (goog-define POKT_TOKEN "3ef2018191814b7e1009b8d9") (goog-define OPENSEA_API_KEY "") (goog-define RARIBLE_MAINNET_API_KEY "") @@ -167,5 +167,5 @@ (def default-kdf-iterations 3200) -(def community-accounts-selection-enabled? true) +(def community-accounts-selection-enabled? (enabled? (get-config :ACCOUNT_SELECTION_ENABLED "0"))) (def fetch-messages-enabled? (enabled? (get-config :FETCH_MESSAGES_ENABLED "1"))) diff --git a/src/tests/integration_test/wallet_test.cljs b/src/tests/integration_test/wallet_test.cljs index 280f922aee6..75e3eabe9f0 100644 --- a/src/tests/integration_test/wallet_test.cljs +++ b/src/tests/integration_test/wallet_test.cljs @@ -3,6 +3,7 @@ [cljs.test :refer [deftest is]] [day8.re-frame.test :as rf-test] legacy.status-im.events + [legacy.status-im.multiaccounts.logout.core :as logout] legacy.status-im.subs.root status-im.events status-im.navigation.core @@ -62,4 +63,4 @@ (is (= :confirmed (-> transaction-details vals first :status))) (h/logout) (rf-test/wait-for - [:legacy.status-im.multiaccounts.logout.core/logout-method]))))))))))))) + [::logout/logout-method]))))))))))))) From 1a2748b993033324aea4f7ecae41000fa4751699 Mon Sep 17 00:00:00 2001 From: Andrea Maria Piana Date: Fri, 23 Feb 2024 15:17:14 +0000 Subject: [PATCH 4/5] indentation --- src/tests/integration_test/wallet_test.cljs | 80 ++++++++++----------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/src/tests/integration_test/wallet_test.cljs b/src/tests/integration_test/wallet_test.cljs index 75e3eabe9f0..60c1a81d2b4 100644 --- a/src/tests/integration_test/wallet_test.cljs +++ b/src/tests/integration_test/wallet_test.cljs @@ -23,44 +23,44 @@ (h/log-headline :wallet-send-test) (rf-test/run-test-async (h/with-app-initialized - (h/with-recovered-account - (rf-test/wait-for - [:wallet/get-wallet-token] - (let [accs (rf/sub [:wallet/accounts]) - default-account (get-default-account accs) - address (:address default-account)] - ;; navigate to account page - (rf/dispatch [:wallet/navigate-to-account (:address default-account)]) - (rf-test/wait-for [:wallet/navigate-to-account] - ;; set the receipient address (same address as sender to avoid token loss) - (rf/dispatch [:wallet/select-send-address - {:address address - :token true - :receipient address - :stack-id :wallet-select-address}]) - (let [filtered-tokens (rf/sub [:wallet/tokens-filtered "eth"])] + (h/with-recovered-account + (rf-test/wait-for + [:wallet/get-wallet-token] + (let [accs (rf/sub [:wallet/accounts]) + default-account (get-default-account accs) + address (:address default-account)] + ;; navigate to account page + (rf/dispatch [:wallet/navigate-to-account (:address default-account)]) + (rf-test/wait-for [:wallet/navigate-to-account] + ;; set the receipient address (same address as sender to avoid token loss) + (rf/dispatch [:wallet/select-send-address + {:address address + :token true + :receipient address + :stack-id :wallet-select-address}]) + (let [filtered-tokens (rf/sub [:wallet/tokens-filtered "eth"])] - (rf/dispatch [:wallet/send-select-token - {:token (first filtered-tokens) - :stack-id :wallet-select-asset}]) - (rf-test/wait-for - [:wallet/clean-suggested-routes] - (rf/dispatch - [:wallet/get-suggested-routes {:amount send-amount}])) - (rf-test/wait-for - [:wallet/suggested-routes-success] - (let [route (rf/sub [:wallet/wallet-send-route])] - (is (true? (some? route))) - (rf/dispatch [:wallet/send-select-amount - {:amount send-amount - :stack-id :wallet-send-input-amount}]) - (rf/dispatch - [:wallet/send-transaction - (security/safe-unmask-data (security/hash-masked-password - (security/mask-data test-constants/password)))]) - (rf-test/wait-for [:wallet/pending-transaction-status-changed-received] - (let [transaction-details (rf/sub [:wallet/send-transaction-progress])] - (is (= :confirmed (-> transaction-details vals first :status))) - (h/logout) - (rf-test/wait-for - [::logout/logout-method]))))))))))))) + (rf/dispatch [:wallet/send-select-token + {:token (first filtered-tokens) + :stack-id :wallet-select-asset}]) + (rf-test/wait-for + [:wallet/clean-suggested-routes] + (rf/dispatch + [:wallet/get-suggested-routes {:amount send-amount}]) + (rf-test/wait-for + [:wallet/suggested-routes-success] + (let [route (rf/sub [:wallet/wallet-send-route])] + (is (true? (some? route))) + (rf/dispatch [:wallet/send-select-amount + {:amount send-amount + :stack-id :wallet-send-input-amount}]) + (rf/dispatch + [:wallet/send-transaction + (security/safe-unmask-data (security/hash-masked-password + (security/mask-data test-constants/password)))]) + (rf-test/wait-for [:wallet/pending-transaction-status-changed-received] + (let [transaction-details (rf/sub [:wallet/send-transaction-progress])] + (is (= :confirmed (-> transaction-details vals first :status))) + (h/logout) + (rf-test/wait-for + [::logout/logout-method])))))))))))))) From fff082e67931848df9641d8fc5d5ee8f304a5bb8 Mon Sep 17 00:00:00 2001 From: Jamie Caprani Date: Mon, 26 Feb 2024 15:59:14 +0000 Subject: [PATCH 5/5] lint --- src/test_helpers/integration.cljs | 2 - src/tests/integration_test/wallet_test.cljs | 79 ++++++++++----------- 2 files changed, 38 insertions(+), 43 deletions(-) diff --git a/src/test_helpers/integration.cljs b/src/test_helpers/integration.cljs index 71c65e5c29f..81875788aa2 100644 --- a/src/test_helpers/integration.cljs +++ b/src/test_helpers/integration.cljs @@ -59,8 +59,6 @@ [] (rf/dispatch [:profile.settings/profile-update :test-networks-enabled? true {}]) - ; can be removed soon - (rf/dispatch [:profile.settings/profile-update :is-sepolia-enabled? true {}]) (rf/dispatch [:wallet/initialize])) (defn app-initialized diff --git a/src/tests/integration_test/wallet_test.cljs b/src/tests/integration_test/wallet_test.cljs index 60c1a81d2b4..1be33096263 100644 --- a/src/tests/integration_test/wallet_test.cljs +++ b/src/tests/integration_test/wallet_test.cljs @@ -23,44 +23,41 @@ (h/log-headline :wallet-send-test) (rf-test/run-test-async (h/with-app-initialized - (h/with-recovered-account - (rf-test/wait-for - [:wallet/get-wallet-token] - (let [accs (rf/sub [:wallet/accounts]) - default-account (get-default-account accs) - address (:address default-account)] - ;; navigate to account page - (rf/dispatch [:wallet/navigate-to-account (:address default-account)]) - (rf-test/wait-for [:wallet/navigate-to-account] - ;; set the receipient address (same address as sender to avoid token loss) - (rf/dispatch [:wallet/select-send-address - {:address address - :token true - :receipient address - :stack-id :wallet-select-address}]) - (let [filtered-tokens (rf/sub [:wallet/tokens-filtered "eth"])] - - (rf/dispatch [:wallet/send-select-token - {:token (first filtered-tokens) - :stack-id :wallet-select-asset}]) - (rf-test/wait-for - [:wallet/clean-suggested-routes] - (rf/dispatch - [:wallet/get-suggested-routes {:amount send-amount}]) - (rf-test/wait-for - [:wallet/suggested-routes-success] - (let [route (rf/sub [:wallet/wallet-send-route])] - (is (true? (some? route))) - (rf/dispatch [:wallet/send-select-amount - {:amount send-amount - :stack-id :wallet-send-input-amount}]) - (rf/dispatch - [:wallet/send-transaction - (security/safe-unmask-data (security/hash-masked-password - (security/mask-data test-constants/password)))]) - (rf-test/wait-for [:wallet/pending-transaction-status-changed-received] - (let [transaction-details (rf/sub [:wallet/send-transaction-progress])] - (is (= :confirmed (-> transaction-details vals first :status))) - (h/logout) - (rf-test/wait-for - [::logout/logout-method])))))))))))))) + (h/with-recovered-account + (rf-test/wait-for + [:wallet/get-wallet-token] + (let [accs (rf/sub [:wallet/accounts]) + default-account (get-default-account accs) + address (:address default-account)] + (rf/dispatch [:wallet/navigate-to-account (:address default-account)]) + (rf-test/wait-for [:wallet/navigate-to-account] + (rf/dispatch [:wallet/select-send-address + {:address address + :token true + :receipient address + :stack-id :wallet-select-address}]) + (let [filtered-tokens (rf/sub [:wallet/tokens-filtered "eth"])] + (rf/dispatch [:wallet/send-select-token + {:token (first filtered-tokens) + :stack-id :wallet-select-asset}]) + (rf-test/wait-for + [:wallet/clean-suggested-routes] + (rf/dispatch + [:wallet/get-suggested-routes {:amount send-amount}]) + (rf-test/wait-for + [:wallet/suggested-routes-success] + (let [route (rf/sub [:wallet/wallet-send-route])] + (is (true? (some? route))) + (rf/dispatch [:wallet/send-select-amount + {:amount send-amount + :stack-id :wallet-send-input-amount}]) + (rf/dispatch + [:wallet/send-transaction + (security/safe-unmask-data (security/hash-masked-password + (security/mask-data test-constants/password)))]) + (rf-test/wait-for [:wallet/pending-transaction-status-changed-received] + (let [transaction-details (rf/sub [:wallet/send-transaction-progress])] + (is (= :confirmed (-> transaction-details vals first :status))) + (h/logout) + (rf-test/wait-for + [::logout/logout-method]))))))))))))))