Sign-in flow docs and tests

This commit is contained in:
Roman Volosovskyi 2019-01-13 20:30:34 +02:00
parent 471d26c6d1
commit 664cbf6bbe
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
9 changed files with 547 additions and 14 deletions

68
doc/sign_in/readme.md Normal file
View File

@ -0,0 +1,68 @@
# Sign in flow
## tl;dr
In general, at first we try to encrypt realm database using password
and then proceed with the rest of operations. We do not wait for
`Statusgo.Login` callback in order to show `:home` screen with chats
as this call may add more than 1s to the process.
![img](sign_in_diagram.jpg)
## In details
#### Main flow:
1. User enters password
2. Presses "Sign In"
3. Attempt to open account's db
4.
_a._ If DB file doesn't exist go to [**Empty DB flow**](#empty-db-flow)
_b._ Otherwise continue
5.
_a._ If db can't be encrypted go to [**Verify password flow**](#verify-password-flow)
_b._ Otherwise continue
6.
_a._ If db can't be migrate DB schema **show migrations failure popup with
option to erase DB**
_b._ Otherwise continue
7. Proceed with [**UI flow**](#ui-flow) and [**Statusgo.Login flow**]
(#statusgologin-flow)
#### Empty DB flow:
1. Verify password
2.
_a._ If password is wrong **show "Wrong password" label**
_b._ Otherwise continue
3. Create account's DB (by opening it with correct encryption key)
4. Proceed with [**UI flow**](#ui-flow) and [**Statusgo.Login flow**]
(#statusgologin-flow)
#### Verify password flow:
1. Verify password
2.
_a._ If password is correct **show encryption failure popup with option to
erase DB**
_b._ Otherwise **show "Wrong password" label**
#### Statusgo.Login flow:
1. Start node
2. "node.ready" event received
3. Statusgo.Login is called
4. Statusgo.Login callback
5.
_a._ If password is incorrect **show error popup (passwords used for db
encryption and for account do not match)**
_b._ Otherwise continue
6. Done
#### UI flow:
1. Load necessary data for last 10 chats
2. Show `:home` screen
2. Load the rest of chats
3. Show them too
4. Done

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

View File

@ -0,0 +1 @@
<mxfile modified="2019-01-14T06:39:33.710Z" host="www.draw.io" agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/9.3.1 Chrome/66.0.3359.181 Electron/3.0.6 Safari/537.36" etag="ZKyT9Zd5PY9VIiVbNCFQ" version="10.0.35" type="device"><diagram id="QTDXuohdJGh2zwvYWD-a" name="Page-1">7V1dd6M2Gv41PtteTA4gwHA5idNu2+lMutnNdPZmjwwC02LkCjyJ++tXMsgGIduaGAHO8VxkbAEC3s/n/ZA8AXfLlx8JXC1+xSFKJ5YRvkzAbGJZvmPQv2xgUw5MTb8ciEkSlkPmfuAx+RtVg9V18ToJUd44scA4LZJVczDAWYaCojEGCcHPzdMinDbvuoIxag08BjBtj35OwmJRjnr8tdj4P1ESL/idTaM6soT85GogX8AQP9eGwP0E3BGMi/LT8uUOpYx2nC7ldT8cOLp7MIKyQuWC+ebp68/LX/3ZE948PcysF+Ljd5ZXPVyx4W+MQkqA6ismxQLHOIPp/X70luB1FiI2rUG/LYplSj+a9CN6SYrf2fCNU337wo9kBdnUDrGvX6oJ/kBFsak4D9cFpkP7+37AeFXN0X7higY5XpMAHXlLLjiQxKg4Ro3yPEaB2g0qcv6I8BLRx6YnEJTCIvnaFBFYSVq8O2/PDPqh4sc38Kaa9ytM19WdHgjK8wnjs/vXmsnN7WMSZ3Tgp2w/1GLonl2Mis+LpECPK7gl2DPV2SYLoyRN73CKyfZaEELkRQEdzwuC/0S1I27goXl0jC1fESnQy1FCVkeB6ZSXbLgWTW+qkee90plckxY1hQOGJupbLep/WiFGaxgElKDFP/KtIMB0Sf+fvQmqe9bgVLdbVGekNSh9EFPMlyQv6C1/aFN7gZfzdX6a0p3QzWjQjTo1Gd2AhG5eB3QDP01/u/3fu/XP//plMbv9+PnJ/c+Xd06XZly/QXYUDbIPRmWRnZZ03kFmElAWkM2qKA3B0NJpNaUTTM22bJoS2ZwCXZZ02inG2CGJBo7YwgpVwRXNrYO80JaZW8+aA9c9S9RdRVHnLOlO1LeXvicEbmonrHCSURO6n/mBDdTEZ9p0Cq7tCAJQzrgXh92jnWH1py3FGsKeCWIReQEKp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ct2563QU+lriQktJAOT1ml42rqFvLxGQWFqzPGfotibTkG2pdy2dd967LpTOLdvvsXQu3aqi0wWqNX859WwRPw7kLHe7KV2at9w9+NVdUren8muTMofp6MoYmtIt3a8OU3sLODBU1328wmHSr/uf9y17Wfa/kQzu/w8=</diagram></mxfile>

View File

@ -104,6 +104,17 @@
{:db (assoc db :chats/loading? false)}
(chat-loading/initialize-chats {:from 10}))))
(defn account-change-success
[{:keys [db] :as cofx} [_ address]]
(let [{:node/keys [status on-ready]} db]
(fx/merge
cofx
(if (= status :started)
(accounts.login/login)
(node/initialize (get-in db [:accounts/login :address])))
(init/initialize-account address)
(chat-loading/initialize-chats {:to 10}))))
(handlers/register-handler-fx
:init.callback/account-change-success
[(re-frame/inject-cofx :web3/get-web3)
@ -113,15 +124,7 @@
(re-frame/inject-cofx :data-store/all-dapp-permissions)
(re-frame/inject-cofx :get-default-dapps)
(re-frame/inject-cofx :data-store/all-chats)]
(fn [{:keys [db] :as cofx} [_ address]]
(let [{:node/keys [status on-ready]} db]
(fx/merge
cofx
(if (= status :started)
(accounts.login/login)
(node/initialize (get-in db [:accounts/login :address])))
(init/initialize-account address)
(chat-loading/initialize-chats {:to 10})))))
account-change-success)
(handlers/register-handler-fx
:init.callback/keychain-reset
@ -260,7 +263,6 @@
(handlers/register-handler-fx
:accounts.login.callback/login-success
[(re-frame/inject-cofx :web3/get-web3)
(re-frame/inject-cofx :data-store/all-chats)
(re-frame/inject-cofx :data-store/get-all-mailservers)
(re-frame/inject-cofx :data-store/transport)
(re-frame/inject-cofx :data-store/mailserver-topics)]

View File

@ -32,9 +32,10 @@
(fx/defn check-sync-state
[{{:keys [web3] :as db} :db :as cofx}]
(if (:account/account db)
{:web3/get-syncing web3
{:web3/get-syncing web3
:web3/get-block-number web3
:dispatch-later [{:ms 10000 :dispatch [:protocol/state-sync-timed-out]}]}
:utils/dispatch-later [{:ms 10000
:dispatch [:protocol/state-sync-timed-out]}]}
(semaphores/free cofx :check-sync-state?)))
(fx/defn start-check-sync-state

View File

@ -50,3 +50,6 @@
(def keychain #js {:setGenericPassword (constantly (.resolve js/Promise true))})
(def secure-random #(.resolve js/Promise (clj->js (range 0 %))))
(def react-navigation #js {:NavigationActions #js {}})
(def desktop-menu #js {})
(def desktop-config #js {})

View File

@ -59,7 +59,8 @@
[status-im.test.hardwallet.core]
[status-im.test.contact-recovery.core]
[status-im.test.ui.screens.currency-settings.models]
[status-im.test.ui.screens.wallet.db]))
[status-im.test.ui.screens.wallet.db]
[status-im.test.sign-in.flow]))
(enable-console-print!)
@ -129,4 +130,5 @@
'status-im.test.browser.core
'status-im.test.contact-recovery.core
'status-im.test.extensions.ethereum
'status-im.test.browser.permissions)
'status-im.test.browser.permissions
'status-im.test.sign-in.flow)

View File

@ -0,0 +1,221 @@
(ns status-im.test.sign-in.data)
(def all-contacts
[{:description nil
:last-updated 1547185503000
:tags #{}
:hide-contact? false
:address "2f88d65f3cb52605a54a833ae118fb1363acccd2"
:name "Darkviolet Lightgreen Halcyon"
:fcm-token "cwigXoAk9R4:APA91bFZOy8vsCj9I9t6PYZXropyYEqAhKaVD2GxrURwvxe_Ay3zLrtJxeirp69se_5EOjS5i4T9xQnoPWrFTLfU9U7AUBdjxZtq5cnlP005bOY05p-psxGsQThMKQMeP5DJC9uxN0Ei"
:dapp-url nil
:dapp-hash nil
:photo-path "data:image/png;base64iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAMAAAC7IEhfAAADAFBMVEX///+M2KwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY5UBARL8TK8AAAAASUVORK5CYII="
:debug? false
:status nil
:bot-url nil
:pending? false
:last-online 0
:dapp? false
:public-key "0x04d6e56a475cd35f512d6ce0bf76c2c2af435c85ff48c2b9bdefd129f620e051a436f50961eae5717b2a750e59c3f5b60647d927da46d0b8b11621640b5678fc24"}
{:description nil
:last-updated 1547271764000
:tags #{}
:hide-contact? false
:address "b267ff8336ac10b3a1986c04a70ff91fb03d0b78"
:name "rv"
:fcm-token "dpVPtMBLuv8:APA91bEU4YuSz9yrc-vsiSl-IjdLSR5UpHm7yffaFlWQs_fvsTiK18ZcdYUbzA8iUoNuMVRNF_ngU7JdQInwNpXdGtNv_qcAFt0jhXHqf7dWY-kGJUBw9Ma8G_2fa40JLJchGVrzUIen"
:dapp-url nil
:dapp-hash nil
:photo-path "data:image/png;base64iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAMAAAC7IEhfAAADAFBMVEX////VjNgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA6IYA4bRtf+EAAAAASUVORK5CYII="
:debug? false
:status nil
:bot-url nil
:pending? false
:last-online 0
:dapp? false
:public-key "0x043ae31038ff45a31b096a91d3f8290e079366fbbae76a00fbbd349cd0e5b8d7598965d206772ec4504f68908649a08383cdc51a52cdae5e9ccc744ace4d37020f"}])
(def chats
[{:updated-at nil
:tags #{}
:color "#51d0f0"
:contacts #{}
:last-clock-value 154990121501242
:admins #{}
:members-joined #{}
:name "status"
:removed-from-at nil
:membership-updates ()
:unviewed-messages-count 0
:last-message-content-type "text/plain"
:is-active true
:last-message-content {:chat-id "status" :text "darn typos...! "}
:debug? false
:added-to-at nil
:group-chat true
:public? true
:removed-at nil
:message-overhead 0
:chat-id "status"
:timestamp 1547361080397
:deleted-at-clock-value nil}
{:updated-at nil
:tags #{}
:color "#d37ef4"
:contacts #{"0x043ae31038ff45a31b096a91d3f8290e079366fbbae76a00fbbd349cd0e5b8d7598965d206772ec4504f68908649a08383cdc51a52cdae5e9ccc744ace4d37020f"}
:last-clock-value 154727176928001
:admins #{}
:members-joined #{}
:name "rv"
:removed-from-at nil
:membership-updates ()
:unviewed-messages-count 0
:last-message-content-type "text/plain"
:is-active true
:last-message-content {:chat-id "0x04173f7cdea0076a7998abb674cc79fe61337c42db77043c01d5b0f3e3ac1e5a45bca0c93bb9f3c3d38b7cc9a7337cd64f9f9b2114fe4bbdfe1ae2633ba14d8c9c"
:text "Hey"}
:debug? false
:added-to-at nil
:group-chat false
:public? false
:removed-at nil
:message-overhead 0
:chat-id "0x043ae31038ff45a31b096a91d3f8290e079366fbbae76a00fbbd349cd0e5b8d7598965d206772ec4504f68908649a08383cdc51a52cdae5e9ccc744ace4d37020f"
:timestamp 1547271770816
:deleted-at-clock-value nil}
{:updated-at nil
:tags #{}
:color "#7cda00"
:contacts #{"0x04d6e56a475cd35f512d6ce0bf76c2c2af435c85ff48c2b9bdefd129f620e051a436f50961eae5717b2a750e59c3f5b60647d927da46d0b8b11621640b5678fc24"}
:last-clock-value 154718689430301
:admins #{}
:members-joined #{}
:name "Darkviolet Lightgreen Halcyon"
:removed-from-at nil
:membership-updates ()
:unviewed-messages-count 0
:last-message-content-type "text/plain"
:is-active true
:last-message-content {:chat-id "0x04173f7cdea0076a7998abb674cc79fe61337c42db77043c01d5b0f3e3ac1e5a45bca0c93bb9f3c3d38b7cc9a7337cd64f9f9b2114fe4bbdfe1ae2633ba14d8c9c"
:text "Djndjd"}
:debug? false
:added-to-at nil
:group-chat false
:public? false
:removed-at nil
:message-overhead 0
:chat-id "0x04d6e56a475cd35f512d6ce0bf76c2c2af435c85ff48c2b9bdefd129f620e051a436f50961eae5717b2a750e59c3f5b60647d927da46d0b8b11621640b5678fc24"
:timestamp 1547186895328
:deleted-at-clock-value nil}])
(def account
{:desktop-alpha-release-warning-shown? false
:last-updated 0
:address "7540c34d6c4082391f12468580a9a4e0724c6755"
:mnemonic "tumble gorilla neglect dumb budget involve tennis ocean diary eagle lady ring"
:bootnodes {}
:signing-phrase "bull exam weed"
:signed-up? true
:name "name"
:last-request nil
:desktop-notifications? false
:settings {:web3-opt-in? true
:wallet {:visible-tokens {:testnet #{:STT
:HND}
:mainnet #{:SNT}
:rinkeby #{:MOKSHA
:KDO}
:xdai #{}
:poa #{}}}}
:dev-mode? false
:networks {"testnet" {:id "testnet"
:name "Ropsten"
:config {:NetworkId 3
:DataDir "/ethereum/testnet"
:LightEthConfig {:Enabled true}}
:rpc-url nil}
"testnet_rpc" {:id "testnet_rpc"
:name "Ropsten with upstream RPC"
:config {:NetworkId 3
:DataDir "/ethereum/testnet_rpc"
:UpstreamConfig {:Enabled true
:URL "https://ropsten.infura.io/z6GCTmjdP3FETEJmMBI4"}}
:rpc-url nil}
"rinkeby_rpc" {:id "rinkeby_rpc"
:name "Rinkeby with upstream RPC"
:config {:NetworkId 4
:DataDir "/ethereum/rinkeby_rpc"
:UpstreamConfig {:Enabled true
:URL "https://rinkeby.infura.io/z6GCTmjdP3FETEJmMBI4"}}
:rpc-url nil}
"mainnet_rpc" {:id "mainnet_rpc"
:name "Mainnet with upstream RPC"
:config {:NetworkId 1
:DataDir "/ethereum/mainnet_rpc"
:UpstreamConfig {:Enabled true
:URL "https://mainnet.infura.io/z6GCTmjdP3FETEJmMBI4"}}
:rpc-url nil}
"xdai_rpc" {:id "xdai_rpc"
:name "xDai Chain"
:config {:NetworkId 100
:DataDir "/ethereum/xdai_rpc"
:UpstreamConfig {:Enabled true
:URL "https://dai.poa.network"}}
:rpc-url nil}
"poa_rpc" {:id "poa_rpc"
:name "POA Network"
:config {:NetworkId 99
:DataDir "/ethereum/poa_rpc"
:UpstreamConfig {:Enabled true
:URL "https://poa.infura.io"}}
:rpc-url nil}}
:photo-path "data:image/png;base64iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAMAAAC7IEhfAAADAFBMVEX////YsYwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAloYA4a9rBHIAAAAASUVORK5CYII="
:debug? false
:status "success is simply the wisdom born out of so called failures"
:extensions {}
:mainnet-warning-shown? false
:last-sign-in 1547271706793
:seed-backed-up? false
:network "mainnet_rpc"
:wallet-set-up-passed? false
:public-key "0x04173f7cdea0076a7998abb674cc79fe61337c42db77043c01d5b0f3e3ac1e5a45bca0c93bb9f3c3d38b7cc9a7337cd64f9f9b2114fe4bbdfe1ae2633ba14d8c9c"
:keycard-instance-uid nil
:installation-id "618ec020-13c8-5505-8aa6-9c5444317e7f"})
(def accounts
{"address" account})
(defn get-chats [_ _] chats)
(def transport
{"0x04d6e56a475cd35f512d6ce0bf76c2c2af435c85ff48c2b9bdefd129f620e051a436f50961eae5717b2a750e59c3f5b60647d927da46d0b8b11621640b5678fc24"
{:sym-key nil
:resend? nil
:topic nil
:pending-ack []
:seen []
:ack []
:sym-key-id nil
:pending-send []}
"0x043ae31038ff45a31b096a91d3f8290e079366fbbae76a00fbbd349cd0e5b8d7598965d206772ec4504f68908649a08383cdc51a52cdae5e9ccc744ace4d37020f"
{:sym-key nil
:resend? nil
:topic nil
:pending-ack []
:seen []
:ack []
:sym-key-id nil
:pending-send []}
"status"
{:sym-key "0x36224048e42c49e5c59c57bba5024fbb8822d6b4ee6ac5fbefd8b77f5323ecc4"
:resend? nil
:topic "0xcd423760"
:pending-ack []
:seen []
:ack []
:sym-key-id "2091c39cac37211987f63391b93d0bd021b9df247da50728bfd766946993849d"
:pending-send []}})
(def topics {"0xf8946aac" {:chat-ids #{:discovery-topic}
:last-request 1547319670}})

View File

@ -0,0 +1,235 @@
(ns status-im.test.sign-in.flow
"The main purpose of these tests is to signal that some steps of the sign in
flow has been changed. Such changes should be reflected in both these tests
and documents which describe the whole \"sign in\" flow."
(:require [cljs.test :refer-macros [deftest is are testing]]
[status-im.accounts.login.core :as login.core]
[status-im.events :as events]
[status-im.ui.screens.browser.default-dapps :as default-dapps]
[status-im.test.sign-in.data :as data]
[status-im.signals.core :as signals]))
(deftest on-password-input-submitted
(testing
"handling :accounts.login.ui/password-input-submitted event"
(let [cofx {:db {:accounts/login {:address "address"
:password "password"}}}
create-database? false
efx (login.core/user-login cofx create-database?)]
(testing "Web data cleared."
(is (contains? efx :accounts.login/clear-web-data)))
(testing "Change account."
(is (= (:data-store/change-account efx)
["address" "password" false])))
(testing "set `node/on-ready` handler"
(is (= (get-in efx [:db :node/on-ready]) :login)))
(testing "start activity indicator"
(is (= (get-in efx [:db :accounts/login :processing]) true))))))
(deftest on-successful-account-change
(testing
"Account changed successfully: :init.callback/account-change-success
event is handled."
(let [db {:accounts/login {:address "address"
:password "password"}
:node/on-ready :login
:accounts/accounts data/accounts}
cofx {:db db
:web3 :web3
:all-contacts data/all-contacts
:all-installations []
:all-stored-browsers []
:all-dapp-permissions []
:default-dapps default-dapps/all
:get-all-stored-chats data/get-chats}
efx (events/account-change-success cofx [nil "address"])
new-db (:db efx)]
(testing "Starting node."
(is (contains? efx :node/start)))
(testing "Get fcm token."
(is (contains? efx :notifications/get-fcm-token)))
(testing "Request notifications permissions."
(is (contains? efx :notifications/request-notifications-permissions)))
(testing "Navigate to :home."
(is (= :home (efx :status-im.ui.screens.navigation/navigate-to))))
(testing "Account selected."
(is (contains? new-db :account/account)))
(testing "Chats initialized."
(is (= 3 (count (:chats new-db)))))
(testing "Contacts initialized."
(is (= 2 (count (:contacts/contacts new-db))))))))
(deftest decryption-failure-on-account-change
(testing ":init.callback/account-change-error event received."
(let [cofx {:db {}}
error {:error :decryption-failed}
efx (login.core/handle-change-account-error cofx error)
new-db (:db efx)]
(testing "Init account's password verification"
(is (= :verify-account (new-db :node/on-ready))))
(testing "Init account's password verification"
(is (= :decryption-failed (get-in new-db [:realm-error :error]))))
(testing "Start node."
(is (contains? efx :node/start))))))
(deftest database-does-not-exist-on-account-change
(testing ":init.callback/account-change-error event received."
(let [cofx {:db {}}
error {:error :database-does-not-exist}
efx (login.core/handle-change-account-error cofx error)
new-db (:db efx)]
(testing "Init account's password verification"
(is (= :verify-account (new-db :node/on-ready))))
(testing "Init account's password verification"
(is (= :database-does-not-exist (get-in new-db [:realm-error :error]))))
(testing "Start node."
(is (contains? efx :node/start))))))
(deftest migrations-failed-on-account-change
(testing ":init.callback/account-change-error event received."
(let [cofx {:db {}}
error {:error :migrations-failed}
efx (login.core/handle-change-account-error cofx error)]
(testing "Show migrations dialog."
(is (contains? efx :ui/show-confirmation))))))
(deftest unknown-realm-error-on-account-change
(testing ":init.callback/account-change-error event received."
(let [cofx {:db {}}
error {:error :unknown-error}
efx (login.core/handle-change-account-error cofx error)]
(testing "Show unknown error dialog."
(is (contains? efx :ui/show-confirmation))))))
(deftest on-node-started
(testing "node.ready signal received"
(let [cofx {:db {:accounts/login {:address "address"
:password "password"}
:node/on-ready :login
:accounts/accounts data/accounts
:account/account data/accounts}}
efx (signals/status-node-started cofx)]
(testing "Init Login call."
(is (= ["address" "password"] (:accounts.login/login efx))))
(testing "Change node's status to started."
(is (= :started (get-in efx [:db :node/status])))))))
(deftest on-node-started-for-verification
(testing "node.ready signal received"
(let [cofx {:db {:accounts/login {:address "address"
:password "password"}
:node/on-ready :verify-account
:accounts/accounts data/accounts
:account/account data/accounts
:realm-error {:error :database-does-not-exist}}}
efx (signals/status-node-started cofx)]
(testing "Init VerifyAccountPassword call."
(is (= ["address" "password" {:error :database-does-not-exist}]
(:accounts.login/verify efx))))
(testing "Change node's status to started."
(is (= :started (get-in efx [:db :node/status])))))))
(deftest on-verify-account-success-after-decryption-failure
(testing ":accounts.login.callback/verify-success event received."
(let [cofx {:db {}}
verify-result "{\"error\":\"\"}"
realm-error {:error :decryption-failed}
efx (login.core/verify-callback cofx verify-result realm-error)]
(testing "Show dialog."
(is (contains? efx :ui/show-confirmation)))
(testing "Stop node."
(is (contains? efx :node/stop))))))
(deftest on-verify-account-success-after-database-does-not-exist
(testing ":accounts.login.callback/verify-success event received."
(let [cofx {:db {:accounts/login {:address "address"
:password "password"}}}
verify-result "{\"error\":\"\"}"
realm-error {:error :database-does-not-exist}
efx (login.core/verify-callback
cofx verify-result realm-error)]
(testing "Change account."
(is (= ["address" "password" true]
(:data-store/change-account efx))))
(testing "Stop node."
(is (contains? efx :node/stop))))))
(deftest on-verify-account-failed
(testing ":accounts.login.callback/verify-success event received."
(let [cofx {:db {:accounts/login {:address "address"
:password "password"}}}
verify-result "{\"error\":\"some error\"}"
realm-error {:error :database-does-not-exist}
efx (login.core/verify-callback
cofx verify-result realm-error)
new-db (:db efx)]
(testing "Show error in sign in form."
(is (= "some error" (get-in new-db [:accounts/login :error]))))
(testing "Hide activity indicator."
(is (= false (get-in new-db [:accounts/login :processing]))))
(testing "Stop node."
(is (contains? efx :node/stop))))))
(deftest login-success
(testing ":accounts.login.callback/login-success event received."
(let [db {:accounts/login {:address "address"
:password "password"}
:account/account data/account
:semaphores #{}}
cofx {:db db
:data-store/mailservers []
:data-store/transport data/transport
:data-store/mailserver-topics data/topics}
login-result "{\"error\":\"\"}"
efx (login.core/user-login-callback cofx login-result)
new-db (:db efx)]
(testing ":accounts/login cleared."
(is (not (contains? new-db :accounts/login))))
(testing "Check messaging related effects."
(is (= 1 (count (get-in efx [:shh/restore-sym-keys-batch :transport]))))
(is (contains? efx :shh/generate-sym-key-from-password))
(is (contains? efx :shh/add-discovery-filters))
(is (contains? efx :mailserver/add-peer))
(is (contains? efx :mailserver/update-mailservers))
(is (contains? efx :protocol/assert-correct-network))
(is (= #{{:ms 10000
:dispatch [:mailserver/check-connection-timeout]}
{:ms 10000
:dispatch [:protocol/state-sync-timed-out]}}
(set (:utils/dispatch-later efx)))))
(testing "Check the rest of effects."
(is (contains? efx :web3/set-default-account))
(is (contains? efx :web3/get-block-number))
(is (contains? efx :web3/fetch-node-version))
(is (contains? efx :get-balance))
(is (contains? efx :web3/get-syncing))
(is (contains? efx :get-tokens-balance))
(is (contains? efx :get-prices))
(is (contains? efx :status-im.models.transactions/start-sync-transactions))))))
(deftest login-failed
(testing
":accounts.login.callback/login-success event received with error."
(let [db {:accounts/login {:address "address"
:password "password"}
:account/account data/account
:semaphores #{}}
cofx {:db db
:data-store/mailservers []
:data-store/transport data/transport
:data-store/mailserver-topics data/topics}
login-result "{\"error\":\"Something went wrong!\"}"
efx (login.core/user-login-callback cofx login-result)
new-db (:db efx)]
(testing "Prevent saving of the password."
(is (= false (get-in new-db [:accounts/login :save-password?]))))
(testing "Show error in sign in form."
(is (contains? (:accounts/login new-db) :error)))
(testing "Stop activity indicator."
(is (= false (get-in new-db [:accounts/login :processing]))))
(testing "Show error in sign in form."
(is (contains? (:accounts/login new-db) :error)))
(testing "Show error popup."
(is (contains? efx :utils/show-popup)))
(testing "Logout."
(is (= [:accounts.logout.ui/logout-confirmed] (:dispatch efx)))))))