Move contacts to status-go

Contacts are now in status-go, no migration of contacts is provided so
all contacts will be lost upon installing this build.

I have left the initialization of filters a bit sketchy (we wait that
load-filters is called twice), as the next step will be to avoid calling
load-filters altogether, as now that both contacts & chats are in
status-go, there's no reason to call it from status-react, and can be
called directly from status-go on loading.

Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
This commit is contained in:
Andrea Maria Piana 2019-08-03 15:01:17 +02:00
parent 68da6159ed
commit fe9d4e9cd8
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
13 changed files with 292 additions and 216 deletions

View File

@ -82,14 +82,15 @@
(navigation/navigate-back))))) (navigation/navigate-back)))))
(fx/defn unblock-contact (fx/defn unblock-contact
[{:keys [db now]} public-key] [{:keys [db now] :as cofx} public-key]
(let [contact (-> (get-in db [:contacts/contacts public-key]) (let [contact (-> (get-in db [:contacts/contacts public-key])
(assoc :last-updated now) (assoc :last-updated now)
(update :system-tags disj :contact/blocked))] (update :system-tags disj :contact/blocked))]
{:db (-> db (fx/merge cofx
(update :contacts/blocked disj public-key) {:db (-> db
(assoc-in [:contacts/contacts public-key] contact)) (update :contacts/blocked disj public-key)
:data-store/tx [(contacts-store/save-contact-tx contact)]})) (assoc-in [:contacts/contacts public-key] contact))}
(contacts-store/save-contact-tx contact))))
(fx/defn block-contact-confirmation (fx/defn block-contact-confirmation
[cofx public-key] [cofx public-key]

View File

@ -1,29 +1,38 @@
(ns status-im.contact.core (ns status-im.contact.core
(:require [status-im.multiaccounts.model :as multiaccounts.model] (:require
[status-im.transport.filters.core :as transport.filters] [re-frame.core :as re-frame]
[status-im.contact.db :as contact.db] [status-im.multiaccounts.model :as multiaccounts.model]
[status-im.contact.device-info :as device-info] [status-im.transport.filters.core :as transport.filters]
[status-im.ethereum.core :as ethereum] [status-im.contact.db :as contact.db]
[status-im.data-store.contacts :as contacts-store] [status-im.contact.device-info :as device-info]
[status-im.mailserver.core :as mailserver] [status-im.ethereum.core :as ethereum]
[status-im.transport.message.contact :as message.contact] [status-im.data-store.contacts :as contacts-store]
[status-im.transport.message.protocol :as protocol] [status-im.mailserver.core :as mailserver]
[status-im.tribute-to-talk.db :as tribute-to-talk] [status-im.transport.message.contact :as message.contact]
[status-im.tribute-to-talk.whitelist :as whitelist] [status-im.transport.message.protocol :as protocol]
[status-im.ui.screens.navigation :as navigation] [status-im.tribute-to-talk.db :as tribute-to-talk]
[status-im.utils.config :as config] [status-im.tribute-to-talk.whitelist :as whitelist]
[status-im.utils.fx :as fx])) [status-im.ui.screens.navigation :as navigation]
[status-im.utils.config :as config]
[status-im.utils.fx :as fx]))
(fx/defn load-contacts (fx/defn load-contacts
[{:keys [db all-contacts]}] {:events [::contacts-loaded]}
[{:keys [db] :as cofx} all-contacts]
(let [contacts-list (map #(vector (:public-key %) %) all-contacts) (let [contacts-list (map #(vector (:public-key %) %) all-contacts)
contacts (into {} contacts-list) contacts (into {} contacts-list)
tr-to-talk-enabled? (-> db tribute-to-talk/get-settings tribute-to-talk/enabled?)] tr-to-talk-enabled? (-> db tribute-to-talk/get-settings tribute-to-talk/enabled?)]
{:db (cond-> (-> db (fx/merge cofx
(update :contacts/contacts #(merge contacts %)) {:db (cond-> (-> db
(assoc :contacts/blocked (contact.db/get-blocked-contacts all-contacts))) (update :contacts/contacts #(merge contacts %))
tr-to-talk-enabled? (assoc :contacts/blocked (contact.db/get-blocked-contacts all-contacts)))
(assoc :contacts/whitelist (whitelist/get-contact-whitelist all-contacts)))})) tr-to-talk-enabled?
(assoc :contacts/whitelist (whitelist/get-contact-whitelist all-contacts)))}
;; TODO: This is currently called twice, once we load chats & when we load filters.
;; For now leaving as it is as the next step is not to have this being called from status-react
;; as both contacts & chats are in status-go, but we still need to signals the filters to
;; status-react for mailsevers/gaps, so will address separately
(transport.filters/load-filters))))
(defn build-contact (defn build-contact
[{{:keys [chats multiaccount] [{{:keys [chats multiaccount]
@ -47,9 +56,9 @@
{:keys [public-key] :as contact}] {:keys [public-key] :as contact}]
(fx/merge cofx (fx/merge cofx
{:db (-> db {:db (-> db
(update-in [:contacts/contacts public-key] merge contact)) (update-in [:contacts/contacts public-key] merge contact))}
:data-store/tx [(contacts-store/save-contact-tx contact)]} (transport.filters/load-contact contact)
(transport.filters/load-contact contact))) (contacts-store/save-contact-tx contact)))
(fx/defn send-contact-request (fx/defn send-contact-request
[{:keys [db] :as cofx} {:keys [public-key] :as contact}] [{:keys [db] :as cofx} {:keys [public-key] :as contact}]
@ -123,6 +132,9 @@
(def receive-contact-request-confirmation handle-contact-update) (def receive-contact-request-confirmation handle-contact-update)
(def receive-contact-update handle-contact-update) (def receive-contact-update handle-contact-update)
(fx/defn initialize-contacts [cofx]
(contacts-store/fetch-contacts-rpc #(re-frame/dispatch [::contacts-loaded %])))
(fx/defn open-contact-toggle-list (fx/defn open-contact-toggle-list
[{:keys [db :as cofx]}] [{:keys [db :as cofx]}]
(fx/merge cofx (fx/merge cofx

View File

@ -6,48 +6,64 @@
[taoensso.timbre :as log] [taoensso.timbre :as log]
[status-im.data-store.realm.core :as core])) [status-im.data-store.realm.core :as core]))
(defn- deserialize-contact [contact] (defn deserialize-device-info [contact]
(update contact :deviceInfo (fn [device-info]
(reduce (fn [acc info]
(assoc acc
(:installationId info)
(clojure.set/rename-keys info {:fcmToken :fcm-token :installationId :id})))
{}
device-info))))
(defn serialize-device-info [contact]
(update contact :device-info (fn [device-info]
(map
#(clojure.set/rename-keys % {:fcm-token :fcmToken :id :installationId})
(vals device-info)))))
(defn <-rpc [contact]
(-> contact (-> contact
(update :tags #(into #{} %)) deserialize-device-info
(update :tribute-to-talk core/deserialize) (update :tributeToTalk core/deserialize)
(update :system-tags (update :systemTags
#(reduce (fn [acc s] #(reduce (fn [acc s]
(conj acc (keyword (subs s 1)))) (conj acc (keyword (subs s 1))))
#{} #{}
%)))) %)) (clojure.set/rename-keys {:id :public-key
:photoPath :photo-path
:deviceInfo :device-info
:tributeToTalk :tribute-to-talk
:systemTags :system-tags
:lastUpdated :last-updated})))
(defn- serialize-contact [contact] (defn ->rpc [contact]
(-> contact (-> contact
(update :device-info #(or (vals %) [])) serialize-device-info
(update :tribute-to-talk core/serialize)
(update :system-tags #(mapv str %)) (update :system-tags #(mapv str %))
(update :tribute-to-talk core/serialize))) (clojure.set/rename-keys {:public-key :id
:photo-path :photoPath
:device-info :deviceInfo
:tribute-to-talk :tributeToTalk
:system-tags :systemTags
:last-updated :lastUpdated})))
(re-frame/reg-cofx (defn save-contact-rpc [{:keys [public-key] :as contact}]
:data-store/get-all-contacts (json-rpc/call {:method "shhext_saveContact"
(fn [coeffects _] :params [(->rpc contact)]
(assoc coeffects :all-contacts (map deserialize-contact :on-success #(log/debug "saved contact" public-key "successfuly")
(-> @core/account-realm :on-failure #(log/error "failed to save contact" public-key %)}))
(core/get-all :contact)
(core/all-clj :contact)))))) (defn fetch-contacts-rpc [on-success]
(json-rpc/call {:method "shhext_contacts"
:params []
:on-success #(on-success (map <-rpc %))
:on-failure #(log/error "failed to fetch contacts" %)}))
(defn save-contact-tx (defn save-contact-tx
"Returns tx function for saving contact" "Returns tx function for saving contact"
[{:keys [public-key] :as contact}] [{:keys [public-key] :as contact}]
(fn [realm] (save-contact-rpc contact))
(core/create realm
:contact
(serialize-contact contact)
true)))
(defn save-contacts-tx
"Returns tx function for saving contacts"
[contacts]
(fn [realm]
(doseq [contact contacts]
((save-contact-tx contact) realm))))
(defn- get-contact-by-id [public-key realm]
(.objectForPrimaryKey realm "contact" public-key))
(defn- get-messages-by-messages-ids (defn- get-messages-by-messages-ids
[message-ids] [message-ids]
@ -56,26 +72,13 @@
(.objects "message") (.objects "message")
(.filtered (str "(" (core/in-query "message-id" message-ids) ")"))))) (.filtered (str "(" (core/in-query "message-id" message-ids) ")")))))
(defn- get-chat
[public-key]
(core/single
(core/get-by-field @core/account-realm
:chat
:chat-id
public-key)))
(defn block-user-tx (defn block-user-tx
"Returns tx function for deleting user messages" "Returns tx function for deleting user messages"
[{:keys [public-key] :as contact} messages-ids] [{:keys [public-key] :as contact} messages-ids]
(fn [realm] (fn [realm]
(core/create realm :contact (serialize-contact contact) true) (data-store.chats/delete-chat-rpc public-key data-store.chats/one-to-one-chat-type)
(save-contact-rpc contact)
(when-let [user-messages (when-let [user-messages
(get-messages-by-messages-ids messages-ids)] (get-messages-by-messages-ids messages-ids)]
(core/delete realm user-messages)) (core/delete realm user-messages))))
(data-store.chats/delete-chat-rpc public-key data-store.chats/one-to-one-chat-type)))
(defn delete-contact-tx
"Returns tx function for deleting contact"
[public-key]
(fn [realm]
(core/delete realm (get-contact-by-id public-key realm))))

View File

@ -130,7 +130,6 @@
(handlers/register-handler-fx (handlers/register-handler-fx
:init.callback/multiaccount-change-success :init.callback/multiaccount-change-success
[(re-frame/inject-cofx :web3/get-web3) [(re-frame/inject-cofx :web3/get-web3)
(re-frame/inject-cofx :data-store/get-all-contacts)
(re-frame/inject-cofx :data-store/get-all-installations) (re-frame/inject-cofx :data-store/get-all-installations)
(re-frame/inject-cofx :data-store/all-chat-requests-ranges)] (re-frame/inject-cofx :data-store/all-chat-requests-ranges)]
multiaccount-change-success) multiaccount-change-success)

View File

@ -236,7 +236,6 @@
(fx/merge cofx (fx/merge cofx
{:notifications/get-fcm-token nil} {:notifications/get-fcm-token nil}
(initialize-multiaccount-db address) (initialize-multiaccount-db address)
(contact/load-contacts)
#(when (dev-mode? %) #(when (dev-mode? %)
(models.dev-server/start)) (models.dev-server/start))
(extensions.module/initialize) (extensions.module/initialize)

View File

@ -6,6 +6,7 @@
[status-im.ethereum.json-rpc :as json-rpc] [status-im.ethereum.json-rpc :as json-rpc]
[status-im.ethereum.subscriptions :as ethereum.subscriptions] [status-im.ethereum.subscriptions :as ethereum.subscriptions]
[status-im.chat.models.loading :as chat.loading] [status-im.chat.models.loading :as chat.loading]
[status-im.contact.core :as contact]
[status-im.ethereum.transactions.core :as transactions] [status-im.ethereum.transactions.core :as transactions]
[status-im.fleet.core :as fleet] [status-im.fleet.core :as fleet]
[status-im.i18n :as i18n] [status-im.i18n :as i18n]
@ -209,6 +210,7 @@
(mobile-network/on-network-status-change) (mobile-network/on-network-status-change)
(protocol/initialize-protocol) (protocol/initialize-protocol)
(chat.loading/initialize-chats {:to -1}) (chat.loading/initialize-chats {:to -1})
(contact/initialize-contacts)
(universal-links/process-stored-event) (universal-links/process-stored-event)
(chaos-mode/check-chaos-mode) (chaos-mode/check-chaos-mode)
(finish-keycard-setup) (finish-keycard-setup)

View File

@ -206,10 +206,11 @@
:topic topic}) :topic topic})
(fx/defn set-filters-initialized [{:keys [db]}] (fx/defn set-filters-initialized [{:keys [db]}]
{:db (assoc db :filters/initialized true)}) {:db (update db :filters/initialized inc)})
;; We check that both chats & contacts have been initialized
(defn filters-initialized? [db] (defn filters-initialized? [db]
(:filters/initialized db)) (>= (:filters/initialized db) 2))
(fx/defn handle-filters-added (fx/defn handle-filters-added
"Called every time we load a filter from statusgo, either from explicit call "Called every time we load a filter from statusgo, either from explicit call

View File

@ -35,8 +35,8 @@
(update :system-tags conj tag))] (update :system-tags conj tag))]
(fx/merge cofx (fx/merge cofx
{:db (-> db {:db (-> db
(assoc-in [:contacts/contacts public-key] contact)) (assoc-in [:contacts/contacts public-key] contact))}
:data-store/tx [(contacts-store/save-contact-tx contact)]} (contacts-store/save-contact-tx contact)
(add-to-whitelist public-key)))) (add-to-whitelist public-key))))
(fx/defn mark-tribute-paid (fx/defn mark-tribute-paid

View File

@ -0,0 +1,68 @@
(ns status-im.test.data-store.contacts
(:require [cljs.test :refer-macros [deftest is testing]]
[status-im.data-store.contacts :as c]))
(deftest contact->rpc
(let [contact {:public-key "pk"
:address "address"
:name "name"
:photo-path "photo-path"
:tribute-to-talk "tribute-to-talk"
:device-info {"1" {:id "1"
:timestamp 1
:fcm-token "1"}
"2" {:id "2"
:timestamp 2
:fcm-token 3}}
:last-updated 1
:system-tags #{:a :b}}
expected-contact {:id "pk"
:address "address"
:name "name"
:photoPath "photo-path"
:tributeToTalk "[\"~#'\",\"tribute-to-talk\"]"
:deviceInfo [{:installationId "1"
:timestamp 1
:fcmToken "1"}
{:installationId "2"
:timestamp 2
:fcmToken 3}]
:lastUpdated 1
:systemTags #{":a" ":b"}}]
(testing "->rpc"
(is (= expected-contact (update
(c/->rpc contact)
:systemTags
#(into #{} %)))))))
(deftest contact<-rpc
(let [contact {:id "pk"
:address "address"
:name "name"
:photoPath "photo-path"
:tributeToTalk "[\"~#'\",\"tribute-to-talk\"]"
:deviceInfo [{:installationId "1"
:timestamp 1
:fcmToken "1"}
{:installationId "2"
:timestamp 2
:fcmToken 3}]
:lastUpdated 1
:systemTags [":a" ":b"]}
expected-contact {:public-key "pk"
:address "address"
:name "name"
:photo-path "photo-path"
:tribute-to-talk "tribute-to-talk"
:device-info {"1" {:id "1"
:timestamp 1
:fcm-token "1"}
"2" {:id "2"
:timestamp 2
:fcm-token 3}}
:last-updated 1
:system-tags #{:a :b}}]
(testing "<-rpc"
(is (= expected-contact (c/<-rpc contact))))))

View File

@ -1,149 +1,145 @@
(ns status-im.test.models.contact (ns status-im.test.models.contact
(:require [cljs.test :refer-macros [deftest is testing]] (:require [cljs.test :refer-macros [deftest is testing]]
[status-im.ethereum.json-rpc :as json-rpc]
[status-im.contact.core :as model])) [status-im.contact.core :as model]))
(def public-key "0x04fcf40c526b09ff9fb22f4a5dbd08490ef9b64af700870f8a0ba2133f4251d5607ed83cd9047b8c2796576bc83fa0de23a13a4dced07654b8ff137fe744047917") (def public-key "0x04fcf40c526b09ff9fb22f4a5dbd08490ef9b64af700870f8a0ba2133f4251d5607ed83cd9047b8c2796576bc83fa0de23a13a4dced07654b8ff137fe744047917")
(def address "71adb0644e2b590e37dafdfea8bd58f0c7668c7f") (def address "71adb0644e2b590e37dafdfea8bd58f0c7668c7f")
(deftest handle-contact-update-test (deftest handle-contact-update-test
(testing "the contact is not in contacts" (with-redefs [json-rpc/call (constantly nil)]
(let [actual (model/handle-contact-update (testing "the contact is not in contacts"
public-key (let [actual (model/handle-contact-update
1 public-key
{:name "name" 1
:profile-image "image" {:name "name"
:address "address" :profile-image "image"
:device-info [{:id "1" :address "address"
:fcm-token "token-1"}] :device-info [{:id "1"
:fcm-token "token"} :fcm-token "token-1"}]
{:db {}}) :fcm-token "token"}
contact (get-in actual [:db :contacts/contacts public-key])] {:db {}})
(testing "it stores the contact in the database" contact (get-in actual [:db :contacts/contacts public-key])]
(is (:data-store/tx actual))) (testing "it adds a new contact"
(testing "it adds a new contact" (is (= {:public-key public-key
(is (= {:public-key public-key :photo-path "image"
:photo-path "image" :name "name"
:name "name" :last-updated 1000
:last-updated 1000 :system-tags #{:contact/request-received}
:system-tags #{:contact/request-received} :device-info {"1" {:id "1"
:device-info {"1" {:id "1" :timestamp 1
:timestamp 1 :fcm-token "token-1"}}
:fcm-token "token-1"}} :fcm-token "token"
:fcm-token "token" :address "address"}
:address "address"} contact)))))
contact))))) (testing "the contact is already in contacts"
(testing "the contact is already in contacts" (testing "timestamp is greater than last-updated"
(testing "timestamp is greater than last-updated" (let [actual (model/handle-contact-update
public-key
1
{:name "new-name"
:profile-image "new-image"
:device-info [{:id "2"
:fcm-token "token-2"}
{:id "3"
:fcm-token "token-3"}]
:address "new-address"
:fcm-token "new-token"}
{:db {:contacts/contacts
{public-key {:public-key public-key
:photo-path "old-image"
:name "old-name"
:last-updated 0
:device-info {"1" {:id "1"
:timestamp 0
:fcm-token "token-1"}
"2" {:id "2"
:timestamp 0
:fcm-token "token-2"}}
:system-tags #{:contact/added}
:fcm-token "old-token"
:address "old-address"}}}})
contact (get-in actual [:db :contacts/contacts public-key])]
(testing "it updates the contact and adds contact/request-received to system tags"
(is (= {:public-key public-key
:photo-path "new-image"
:name "new-name"
:last-updated 1000
:device-info {"1" {:id "1"
:fcm-token "token-1"
:timestamp 0}
"2" {:id "2"
:fcm-token "token-2"
:timestamp 1}
"3" {:id "3"
:fcm-token "token-3"
:timestamp 1}}
:system-tags #{:contact/added :contact/request-received}
:fcm-token "new-token"
:address "new-address"}
contact)))))
(testing "timestamp is equal to last-updated"
(let [actual (model/handle-contact-update
public-key
1
{:name "new-name"
:profile-image "new-image"
:address "new-address"
:fcm-token "new-token"}
{:db {:contacts/contacts
{public-key {:public-key public-key
:photo-path "old-image"
:name "old-name"
:last-updated 1000
:system-tags #{:contact/added}
:fcm-token "old-token"
:address "old-address"}}}})
contact (get-in actual [:db :contacts/contacts public-key])]
(testing "it does nothing"
(is (nil? actual)))))
(testing "timestamp is less than last-updated"
(let [actual (model/handle-contact-update
public-key
0
{:name "new-name"
:profile-image "new-image"
:address "new-address"
:fcm-token "new-token"}
{:db {:contacts/contacts
{public-key {:public-key public-key
:photo-path "old-image"
:name "old-name"
:last-updated 1000
:system-tags #{:contact/added :contact/request-received}
:fcm-token "old-token"
:address "old-address"}}}})
contact (get-in actual [:db :contacts/contacts public-key])]
(testing "it does nothing"
(is (nil? actual))))))
(testing "backward compatibility"
(let [actual (model/handle-contact-update (let [actual (model/handle-contact-update
public-key public-key
1 1
{:name "new-name" {:name "new-name"
:profile-image "new-image" :profile-image "new-image"}
:device-info [{:id "2"
:fcm-token "token-2"}
{:id "3"
:fcm-token "token-3"}]
:address "new-address"
:fcm-token "new-token"}
{:db {:contacts/contacts {:db {:contacts/contacts
{public-key {:public-key public-key {public-key {:public-key public-key
:photo-path "old-image" :photo-path "old-image"
:device-info {"1" {:id "1"
:fcm-token "token-1"}}
:name "old-name" :name "old-name"
:last-updated 0 :last-updated 0
:device-info {"1" {:id "1" :system-tags #{:contact/added}}}}})
:timestamp 0
:fcm-token "token-1"}
"2" {:id "2"
:timestamp 0
:fcm-token "token-2"}}
:system-tags #{:contact/added}
:fcm-token "old-token"
:address "old-address"}}}})
contact (get-in actual [:db :contacts/contacts public-key])] contact (get-in actual [:db :contacts/contacts public-key])]
(testing "it stores the contact in the database" (testing "it updates the contact"
(is (:data-store/tx actual)))
(testing "it updates the contact and adds contact/request-received to system tags"
(is (= {:public-key public-key (is (= {:public-key public-key
:photo-path "new-image" :photo-path "new-image"
:name "new-name" :name "new-name"
:last-updated 1000
:device-info {"1" {:id "1" :device-info {"1" {:id "1"
:fcm-token "token-1" :fcm-token "token-1"}}
:timestamp 0} :last-updated 1000
"2" {:id "2"
:fcm-token "token-2"
:timestamp 1}
"3" {:id "3"
:fcm-token "token-3"
:timestamp 1}}
:system-tags #{:contact/added :contact/request-received} :system-tags #{:contact/added :contact/request-received}
:fcm-token "new-token" :address address} contact)))))
:address "new-address"} (testing "the message is coming from us"
contact))))) (testing "it does not update contacts"
(testing "timestamp is equal to last-updated" (is (nil? (model/handle-contact-update "me" 1 {} {:db {:multiaccount {:public-key "me"}}})))))))
(let [actual (model/handle-contact-update
public-key
1
{:name "new-name"
:profile-image "new-image"
:address "new-address"
:fcm-token "new-token"}
{:db {:contacts/contacts
{public-key {:public-key public-key
:photo-path "old-image"
:name "old-name"
:last-updated 1000
:system-tags #{:contact/added}
:fcm-token "old-token"
:address "old-address"}}}})
contact (get-in actual [:db :contacts/contacts public-key])]
(testing "it does nothing"
(is (nil? actual)))))
(testing "timestamp is less than last-updated"
(let [actual (model/handle-contact-update
public-key
0
{:name "new-name"
:profile-image "new-image"
:address "new-address"
:fcm-token "new-token"}
{:db {:contacts/contacts
{public-key {:public-key public-key
:photo-path "old-image"
:name "old-name"
:last-updated 1000
:system-tags #{:contact/added :contact/request-received}
:fcm-token "old-token"
:address "old-address"}}}})
contact (get-in actual [:db :contacts/contacts public-key])]
(testing "it does nothing"
(is (nil? actual))))))
(testing "backward compatibility"
(let [actual (model/handle-contact-update
public-key
1
{:name "new-name"
:profile-image "new-image"}
{:db {:contacts/contacts
{public-key {:public-key public-key
:photo-path "old-image"
:device-info {"1" {:id "1"
:fcm-token "token-1"}}
:name "old-name"
:last-updated 0
:system-tags #{:contact/added}}}}})
contact (get-in actual [:db :contacts/contacts public-key])]
(testing "it stores the contact in the database"
(is (:data-store/tx actual)))
(testing "it updates the contact"
(is (= {:public-key public-key
:photo-path "new-image"
:name "new-name"
:device-info {"1" {:id "1"
:fcm-token "token-1"}}
:last-updated 1000
:system-tags #{:contact/added :contact/request-received}
:address address} contact)))))
(testing "the message is coming from us"
(testing "it does not update contacts"
(is (nil? (model/handle-contact-update "me" 1 {} {:db {:multiaccount {:public-key "me"}}}))))))

View File

@ -16,6 +16,7 @@
[status-im.test.contact-recovery.core] [status-im.test.contact-recovery.core]
[status-im.test.contacts.device-info] [status-im.test.contacts.device-info]
[status-im.test.data-store.chats] [status-im.test.data-store.chats]
[status-im.test.data-store.contacts]
[status-im.test.data-store.core] [status-im.test.data-store.core]
[status-im.test.data-store.realm.core] [status-im.test.data-store.realm.core]
[status-im.test.ethereum.abi-spec] [status-im.test.ethereum.abi-spec]
@ -100,6 +101,7 @@
'status-im.test.contacts.db 'status-im.test.contacts.db
'status-im.test.contacts.device-info 'status-im.test.contacts.device-info
'status-im.test.data-store.chats 'status-im.test.data-store.chats
'status-im.test.data-store.contacts
'status-im.test.data-store.core 'status-im.test.data-store.core
'status-im.test.data-store.realm.core 'status-im.test.data-store.realm.core
'status-im.test.ethereum.abi-spec 'status-im.test.ethereum.abi-spec

View File

@ -37,7 +37,6 @@
:multiaccounts/multiaccounts data/multiaccounts} :multiaccounts/multiaccounts data/multiaccounts}
cofx {:db db cofx {:db db
:web3 :web3 :web3 :web3
:all-contacts data/all-contacts
:all-installations []} :all-installations []}
efx (events/multiaccount-change-success cofx [nil "address"]) efx (events/multiaccount-change-success cofx [nil "address"])
new-db (:db efx)] new-db (:db efx)]
@ -50,9 +49,7 @@
(testing "Navigate to :home." (testing "Navigate to :home."
(is (= [:home nil] (efx :status-im.ui.screens.navigation/navigate-to)))) (is (= [:home nil] (efx :status-im.ui.screens.navigation/navigate-to))))
(testing "Multiaccount selected." (testing "Multiaccount selected."
(is (contains? new-db :multiaccount))) (is (contains? new-db :multiaccount))))))
(testing "Contacts initialized."
(is (= 2 (count (:contacts/contacts new-db))))))))
(deftest decryption-failure-on-multiaccount-change (deftest decryption-failure-on-multiaccount-change
(testing ":init.callback/multiaccount-change-error event received." (testing ":init.callback/multiaccount-change-error event received."

View File

@ -51,9 +51,7 @@
(testing "contact was tagged as tribute paid" (testing "contact was tagged as tribute paid"
(is (= (get-in result (is (= (get-in result
[:db :contacts/contacts "bob" :system-tags]) [:db :contacts/contacts "bob" :system-tags])
#{:tribute-to-talk/paid}))) #{:tribute-to-talk/paid})))))
(testing "change is persisted"
(is (:data-store/tx result)))))
(deftest mark-tribute-received (deftest mark-tribute-received
(let [result (whitelist/mark-tribute-received {:db {}} "bob")] (let [result (whitelist/mark-tribute-received {:db {}} "bob")]
@ -64,9 +62,7 @@
(testing "contact was tagged as tribute paid" (testing "contact was tagged as tribute paid"
(is (= (get-in result (is (= (get-in result
[:db :contacts/contacts "bob" :system-tags]) [:db :contacts/contacts "bob" :system-tags])
#{:tribute-to-talk/received}))) #{:tribute-to-talk/received})))))
(testing "change is persisted"
(is (:data-store/tx result)))))
(def sender-pk "0x04263d74e55775280e75b4a4e9a45ba59fc372793a869c5d9c4fa2100556d9963e3f4fbfa1724ec94a46e6da057540ab248ed1f5eb956e36e3129ecd50fade2c97") (def sender-pk "0x04263d74e55775280e75b4a4e9a45ba59fc372793a869c5d9c4fa2100556d9963e3f4fbfa1724ec94a46e6da057540ab248ed1f5eb956e36e3129ecd50fade2c97")
(def sender-address "0xdff1a5e4e57d9723b3294e0f4413372e3ea9a8ff") (def sender-address "0xdff1a5e4e57d9723b3294e0f4413372e3ea9a8ff")