[fix 6410] error when fetching history on certain accounts

- 1-1 chats don't have a topic anymore because they only use the
discovery topic so topic is nil for these chat
- this was causing an error when initializing whisper because the app
was trying to start a filter for each of the chat including the 1-1 with
no topic
- we now filter the transport/chats to only recover sym-key and start filter
for those with a topic
This commit is contained in:
yenda 2018-10-19 17:44:09 +02:00 committed by Roman Volosovskyi
parent 8bb08eecc5
commit 6b1c6c7d0a
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
2 changed files with 9 additions and 3 deletions

View File

@ -31,7 +31,7 @@
:private-key-id public-key
:topic topic}
:shh/restore-sym-keys {:web3 web3
:transport (:transport/chats db)
:transport (filter (comp :topic second) (:transport/chats db))
:on-success sym-key-added-callback}}
(inbox/connect-to-mailserver)
(message/resend-contact-messages [])))))

View File

@ -1,15 +1,21 @@
(ns status-im.test.transport.core
(:require [cljs.test :refer-macros [deftest is testing]]
[status-im.protocol.core :as protocol]
[status-im.transport.core :as transport]
[status-im.transport.message.core :as message]))
(deftest init-whisper
(let [cofx {:db {:account/account {:public-key "1"}
:transport/chats {"1" {:topic "topic-1"}
"2" {}
"3" {:topic "topic-3"}}
:semaphores #{}}}]
(testing "it adds the discover filter"
(is (= (:shh/add-discovery-filter (protocol/initialize-protocol cofx "user-address")))))
(is (= {:web3 nil :private-key-id "1" :topic "0xf8946aac"}
(:shh/add-discovery-filter (transport/init-whisper cofx "user-address")))))
(testing "it restores the sym-keys"
(is (= (:shh/restore-sym-keys (protocol/initialize-protocol cofx "user-address")))))
(is (= [["1" {:topic "topic-1"}] ["3" {:topic "topic-3"}]]
(-> (transport/init-whisper cofx "user-address") :shh/restore-sym-keys :transport))))
(testing "custom mailservers"
(let [ms-1 {:id "1"
:fleet :eth.beta