From 4cc252a915c55477f8e39b1510aaa91a72ffd5fa Mon Sep 17 00:00:00 2001 From: Andrea Maria Piana Date: Tue, 7 Jan 2020 15:41:07 +0100 Subject: [PATCH] fix tests --- src/status_im/tribute_to_talk/core.cljs | 3 +- src/status_im/tribute_to_talk/db.cljs | 3 +- test/cljs/status_im/test/contacts/db.cljs | 4 -- .../status_im/test/data_store/messages.cljs | 1 + test/cljs/status_im/test/models/contact.cljs | 33 +++------- test/cljs/status_im/test/runner.cljs | 63 ++++++++++++++++++- 6 files changed, 75 insertions(+), 32 deletions(-) diff --git a/src/status_im/tribute_to_talk/core.cljs b/src/status_im/tribute_to_talk/core.cljs index 9ac7a1dd592d..90da1578b01f 100644 --- a/src/status_im/tribute_to_talk/core.cljs +++ b/src/status_im/tribute_to_talk/core.cljs @@ -231,8 +231,7 @@ (not (whitelist/whitelisted-by? (get-in db [:contacts/contacts public-key])))) (if-let [contract (contracts/get-address db :status/tribute-to-talk)] - ;;TODO can't use (ethereum/public-key->address public-key) anymore - (let [address nil] + (let [address (ethereum/public-key->address public-key)] {:tribute-to-talk/get-tribute {:contract contract :address address diff --git a/src/status_im/tribute_to_talk/db.cljs b/src/status_im/tribute_to_talk/db.cljs index 957037abfa37..f8ec6900a982 100644 --- a/src/status_im/tribute_to_talk/db.cljs +++ b/src/status_im/tribute_to_talk/db.cljs @@ -69,6 +69,5 @@ (js/parseInt transaction-block))) (.lessThanOrEqualTo (money/bignumber tribute-required) (money/bignumber value)) - ;;TODO can't use (ethereum/public-key->address from-public-key) anymore - (ethereum/address= nil + (ethereum/address= (ethereum/public-key->address from-public-key) from)))) diff --git a/test/cljs/status_im/test/contacts/db.cljs b/test/cljs/status_im/test/contacts/db.cljs index 5d6ac57acdfb..db3c9a1f2cf2 100644 --- a/test/cljs/status_im/test/contacts/db.cljs +++ b/test/cljs/status_im/test/contacts/db.cljs @@ -15,7 +15,6 @@ contacts {"0x04985040682b77a32bb4bb58268a0719bd24ca4d07c255153fe1eb2ccd5883669627bd1a092d7cc76e8e4b9104327667b19dcda3ac469f572efabe588c38c1985f" {:last-updated 0, - :address "eca8218b5ebeb2c47ba94c1b6e0a779d78fff7bc", :name "User B", :photo-path "photo1", :last-online 0, @@ -23,7 +22,6 @@ "0x04985040682b77a32bb4bb58268a0719bd24ca4d07c255153fe1eb2ccd5883669627bd1a092d7cc76e8e4b9104327667b19dcda3ac469f572efabe588c38c1985f" :system-tags #{}}} current-multiaccount {:last-updated 0, - :address "f23d28f538fd8cd4a90c2d96ca89f5bccca5383f", :signed-up? true, :sharing-usage-data? false, :name "User A", @@ -38,7 +36,6 @@ :identicon "generated" :alias "generated" :admin? true - :address "71adb0644e2b590e37dafdfea8bd58f0c7668c7f" :public-key "0x04fcf40c526b09ff9fb22f4a5dbd08490ef9b64af700870f8a0ba2133f4251d5607ed83cd9047b8c2796576bc83fa0de23a13a4dced07654b8ff137fe744047917" :system-tags #{}} {:name "User A" @@ -47,7 +44,6 @@ {:last-updated 0 :name "User B" :photo-path "photo1" - :address "eca8218b5ebeb2c47ba94c1b6e0a779d78fff7bc" :last-online 0 :public-key "0x04985040682b77a32bb4bb58268a0719bd24ca4d07c255153fe1eb2ccd5883669627bd1a092d7cc76e8e4b9104327667b19dcda3ac469f572efabe588c38c1985f" :system-tags #{}}])))))) diff --git a/test/cljs/status_im/test/data_store/messages.cljs b/test/cljs/status_im/test/data_store/messages.cljs index 26a7cb62a7fe..07ad6450f5e4 100644 --- a/test/cljs/status_im/test/data_store/messages.cljs +++ b/test/cljs/status_im/test/data_store/messages.cljs @@ -19,6 +19,7 @@ :response-to "a"} :whisper-timestamp 1 :outgoing-status :sending + :command-parameters nil :outgoing true :message-type 0 :clock-value 2 diff --git a/test/cljs/status_im/test/models/contact.cljs b/test/cljs/status_im/test/models/contact.cljs index 2d72d6b56429..fdfde85ed533 100644 --- a/test/cljs/status_im/test/models/contact.cljs +++ b/test/cljs/status_im/test/models/contact.cljs @@ -6,7 +6,6 @@ [status-im.contact.core :as model])) (def public-key "0x04fcf40c526b09ff9fb22f4a5dbd08490ef9b64af700870f8a0ba2133f4251d5607ed83cd9047b8c2796576bc83fa0de23a13a4dced07654b8ff137fe744047917") -(def address "71adb0644e2b590e37dafdfea8bd58f0c7668c7f") (deftest handle-contact-update-test (with-redefs [json-rpc/call (constantly nil)] @@ -16,16 +15,14 @@ public-key 1 {:name "name" - :profile-image "image" - :address "address"}) + :profile-image "image"}) contact (get-in actual [:db :contacts/contacts public-key])] (testing "it adds a new contact" (is (= {:public-key public-key :photo-path "image" :name "name" :last-updated 1000 - :system-tags #{:contact/request-received} - :address "address"} + :system-tags #{:contact/request-received}} contact))))) (testing "the contact is already in contacts" (testing "timestamp is greater than last-updated" @@ -35,13 +32,11 @@ :photo-path "old-image" :name "old-name" :last-updated 0 - :system-tags #{:contact/added} - :address "old-address"}}}} + :system-tags #{:contact/added}}}}} public-key 1 {:name "new-name" - :profile-image "new-image" - :address "new-address"}) + :profile-image "new-image"}) 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 @@ -49,8 +44,7 @@ :name "new-name" :last-updated 1000 - :system-tags #{:contact/added :contact/request-received} - :address "new-address"} + :system-tags #{:contact/added :contact/request-received}} contact))))) (testing "timestamp is equal to last-updated" (let [actual (model/handle-contact-update @@ -59,13 +53,11 @@ :photo-path "old-image" :name "old-name" :last-updated 1000 - :system-tags #{:contact/added} - :address "old-address"}}}} + :system-tags #{:contact/added}}}}} public-key 1 {:name "new-name" - :profile-image "new-image" - :address "new-address"}) + :profile-image "new-image"}) contact (get-in actual [:db :contacts/contacts public-key])] (testing "it does nothing" (is (nil? actual))))) @@ -76,13 +68,11 @@ :photo-path "old-image" :name "old-name" :last-updated 1000 - :system-tags #{:contact/added :contact/request-received} - :address "old-address"}}}} + :system-tags #{:contact/added :contact/request-received}}}}} public-key 0 {:name "new-name" - :profile-image "new-image" - :address "new-address"}) + :profile-image "new-image"}) contact (get-in actual [:db :contacts/contacts public-key])] (testing "it does nothing" (is (nil? actual)))))) @@ -106,8 +96,7 @@ :name "new-name" :last-updated 1000 - :system-tags #{:contact/added :contact/request-received} - :address address} contact))))) + :system-tags #{:contact/added :contact/request-received}} contact))))) (testing "the message is coming from us" (testing "it does not update contacts" (is (nil? (model/handle-contact-update {:db {:multiaccount {:public-key "me"}}} "me" 1 {}))))))) @@ -121,7 +110,6 @@ expected {(str "0x" pk1) {:alias "generated" :identicon "generated" :name "name-1" - :address "6dd28d3d14c6ded091ed38a6735350ce92fe1956" :ens-verified true :ens-verified-at 1 :public-key (str "0x" pk1) @@ -129,7 +117,6 @@ (str "0x" pk2) {:alias "generated" :name "name-2" :identicon "generated" - :address "7ab91a68f65c1365d8071302a71599273acb68a2" :ens-verified false :ens-verified-at 2 :public-key (str "0x" pk2) diff --git a/test/cljs/status_im/test/runner.cljs b/test/cljs/status_im/test/runner.cljs index 56f967ea7017..e6331520bfd7 100644 --- a/test/cljs/status_im/test/runner.cljs +++ b/test/cljs/status_im/test/runner.cljs @@ -70,4 +70,65 @@ (set! goog.DEBUG false) -(doo-tests) +(doo-tests + 'status-im.test.browser.core + 'status-im.test.browser.permissions + 'status-im.test.chat.db + 'status-im.test.chat.models + 'status-im.test.chat.models.input + 'status-im.test.chat.models.message + 'status-im.test.chat.models.message-list + 'status-im.test.chat.views.photos + 'status-im.test.transport.filters.core + 'status-im.test.contacts.db + 'status-im.test.data-store.chats + 'status-im.test.data-store.messages + 'status-im.test.data-store.contacts + 'status-im.test.ethereum.abi-spec + 'status-im.test.ethereum.core + 'status-im.test.ethereum.eip55 + 'status-im.test.ethereum.eip681 + 'status-im.test.ethereum.ens + 'status-im.test.ethereum.mnemonic + 'status-im.test.ethereum.stateofus + 'status-im.test.fleet.core + 'status-im.test.hardwallet.core + 'status-im.test.i18n + 'status-im.test.mailserver.core + 'status-im.test.mailserver.topics + 'status-im.test.models.bootnode + 'status-im.test.models.contact + 'status-im.test.multiaccounts.login.core + 'status-im.test.multiaccounts.model + 'status-im.test.multiaccounts.recover.core + 'status-im.test.multiaccounts.update.core + 'status-im.test.network.core + 'status-im.test.pairing.core + 'status-im.test.search.core + 'status-im.test.sign-in.flow + 'status-im.test.stickers.core + 'status-im.test.signing.core + 'status-im.test.signing.gas + 'status-im.test.transport.core + 'status-im.test.tribute-to-talk.core + 'status-im.test.tribute-to-talk.db + 'status-im.test.tribute-to-talk.whitelist + 'status-im.test.ui.screens.currency-settings.models + 'status-im.test.ui.screens.wallet.db + 'status-im.test.utils.async + 'status-im.test.utils.clocks + 'status-im.test.utils.contenthash + 'status-im.test.utils.datetime + 'status-im.test.utils.fx + 'status-im.test.utils.http + 'status-im.test.utils.money + 'status-im.test.utils.prices + 'status-im.test.utils.random + 'status-im.test.utils.security + 'status-im.test.utils.signing-phrase.core + 'status-im.test.utils.transducers + 'status-im.test.utils.universal-links.core + 'status-im.test.utils.utils + 'status-im.test.wallet.subs + 'status-im.test.wallet.transactions + 'status-im.test.wallet.transactions.subs)