From b05787b0b2883a6ebc87e276bb49965cb055a1a6 Mon Sep 17 00:00:00 2001 From: Erik Seppanen Date: Tue, 6 Sep 2022 16:22:47 -0400 Subject: [PATCH] [13857] Extend integration tests to recover multiaccount from seed phrase --- src/mocks/js_dependencies.cljs | 2 ++ src/status_im/integration_test.cljs | 33 +++++++++++++++++++++++++++++ src/status_im/utils/test.cljs | 13 +++++++++--- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/src/mocks/js_dependencies.cljs b/src/mocks/js_dependencies.cljs index 6942584ba5..3be9492531 100644 --- a/src/mocks/js_dependencies.cljs +++ b/src/mocks/js_dependencies.cljs @@ -26,6 +26,7 @@ :View {} :RefreshControl {} :AppState {} + :Alert {:alert (fn [])} :FlatList {} :SectionList {} :Text {} @@ -136,6 +137,7 @@ :setDefaultOptions identity :setRoot identity :dismissOverlay #(js/Promise.resolve) + :showOverlay identity :setLazyComponentRegistrator identity :pop identity :push identity diff --git a/src/status_im/integration_test.cljs b/src/status_im/integration_test.cljs index 1b2679da29..5f2afa2c49 100644 --- a/src/status_im/integration_test.cljs +++ b/src/status_im/integration_test.cljs @@ -4,6 +4,7 @@ [clojure.string :as string] [re-frame.core :as rf] status-im.events + [status-im.utils.security :as security] [status-im.multiaccounts.logout.core :as logout] [status-im.transport.core :as transport] status-im.subs ;;so integration tests can run independently @@ -174,5 +175,37 @@ (rf-test/wait-for [::logout/logout-method] ; we need to logout to make sure the node is not in an inconsistent state between tests (assert-logout))))))))) +(def multiaccount-name "Narrow Frail Lemming") +(def multiaccount-mnemonic "tattoo ramp health green tongue universe style vapor become tape lava reason") +(def multiaccount-key-uid "0x694b8229524820a3a00a6e211141561d61b251ad99d6b65daf82a73c9a57697b") + +(deftest recover-multiaccount-test + (log/info "========= recover-multiaccount-test ==================") + (rf-test/run-test-async + (initialize-app!) + (rf-test/wait-for + [:status-im.init.core/initialize-view] + (rf/dispatch-sync [:init-root :onboarding]) + (rf/dispatch-sync [:multiaccounts.recover.ui/recover-multiaccount-button-pressed]) + (rf/dispatch-sync [:status-im.multiaccounts.recover.core/enter-phrase-pressed]) + (rf/dispatch-sync [:multiaccounts.recover/enter-phrase-input-changed + (security/mask-data multiaccount-mnemonic)]) + (rf/dispatch [:multiaccounts.recover/enter-phrase-next-pressed]) + (rf-test/wait-for + [:status-im.multiaccounts.recover.core/import-multiaccount-success] + (rf/dispatch-sync [:multiaccounts.recover/re-encrypt-pressed]) + (rf/dispatch [:multiaccounts.recover/enter-password-next-pressed password]) + (rf-test/wait-for + [:status-im.multiaccounts.recover.core/store-multiaccount-success] + (let [multiaccount @(rf/subscribe [:multiaccount])] ; assert multiaccount is recovered + (is (= multiaccount-key-uid (:key-uid multiaccount))) + (is (= multiaccount-name (:name multiaccount)))) + (rf-test/wait-for ; wait for login + [::transport/messenger-started] + (assert-messenger-started) + (logout!) + (rf-test/wait-for [::logout/logout-method] ; we need to logout to make sure the node is not in an inconsistent state between tests + (assert-logout)))))))) + (comment (run-tests)) diff --git a/src/status_im/utils/test.cljs b/src/status_im/utils/test.cljs index 4a0a1b0e74..fb8ff1ad33 100644 --- a/src/status_im/utils/test.cljs +++ b/src/status_im/utils/test.cljs @@ -48,7 +48,6 @@ settings config accounts-data)) - :logout (fn [] (.logout native-status)) :generateAliasAndIdenticonAsync (fn [seed callback] @@ -60,6 +59,11 @@ (.multiAccountGenerateAndDeriveAddresses native-status json))) + :multiAccountImportMnemonic (fn [json callback] + (callback + (.multiAccountImportMnemonic + native-status + json))) :multiAccountLoadAccount (fn [json callback] (callback (.multiAccountLoadAccount @@ -75,8 +79,11 @@ (.initKeystore native-status (str test-dir "/keystore/" key-uid)))) - :identicon (fn [pk] (.identicon native-status pk)) - + :validateMnemonic (fn [json callback] + (callback + (.validateMnemonic + native-status + json))) :startLocalNotifications identity}))