Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cammellos committed Jan 7, 2020
1 parent 9adce9e commit 4cc252a
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 32 deletions.
3 changes: 1 addition & 2 deletions src/status_im/tribute_to_talk/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/status_im/tribute_to_talk/db.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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))))
4 changes: 0 additions & 4 deletions test/cljs/status_im/test/contacts/db.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@

contacts {"0x04985040682b77a32bb4bb58268a0719bd24ca4d07c255153fe1eb2ccd5883669627bd1a092d7cc76e8e4b9104327667b19dcda3ac469f572efabe588c38c1985f"
{:last-updated 0,
:address "eca8218b5ebeb2c47ba94c1b6e0a779d78fff7bc",
:name "User B",
:photo-path "photo1",
:last-online 0,
:public-key
"0x04985040682b77a32bb4bb58268a0719bd24ca4d07c255153fe1eb2ccd5883669627bd1a092d7cc76e8e4b9104327667b19dcda3ac469f572efabe588c38c1985f"
:system-tags #{}}}
current-multiaccount {:last-updated 0,
:address "f23d28f538fd8cd4a90c2d96ca89f5bccca5383f",
:signed-up? true,
:sharing-usage-data? false,
:name "User A",
Expand All @@ -38,7 +36,6 @@
:identicon "generated"
:alias "generated"
:admin? true
:address "71adb0644e2b590e37dafdfea8bd58f0c7668c7f"
:public-key "0x04fcf40c526b09ff9fb22f4a5dbd08490ef9b64af700870f8a0ba2133f4251d5607ed83cd9047b8c2796576bc83fa0de23a13a4dced07654b8ff137fe744047917"
:system-tags #{}}
{:name "User A"
Expand All @@ -47,7 +44,6 @@
{:last-updated 0
:name "User B"
:photo-path "photo1"
:address "eca8218b5ebeb2c47ba94c1b6e0a779d78fff7bc"
:last-online 0
:public-key "0x04985040682b77a32bb4bb58268a0719bd24ca4d07c255153fe1eb2ccd5883669627bd1a092d7cc76e8e4b9104327667b19dcda3ac469f572efabe588c38c1985f"
:system-tags #{}}]))))))
1 change: 1 addition & 0 deletions test/cljs/status_im/test/data_store/messages.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
:response-to "a"}
:whisper-timestamp 1
:outgoing-status :sending
:command-parameters nil
:outgoing true
:message-type 0
:clock-value 2
Expand Down
33 changes: 10 additions & 23 deletions test/cljs/status_im/test/models/contact.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -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"
Expand All @@ -35,22 +32,19 @@
: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
:photo-path "new-image"
: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
Expand All @@ -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)))))
Expand All @@ -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))))))
Expand All @@ -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 {})))))))
Expand All @@ -121,15 +110,13 @@
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)
:system-tags #{}}
(str "0x" pk2) {:alias "generated"
:name "name-2"
:identicon "generated"
:address "7ab91a68f65c1365d8071302a71599273acb68a2"
:ens-verified false
:ens-verified-at 2
:public-key (str "0x" pk2)
Expand Down
63 changes: 62 additions & 1 deletion test/cljs/status_im/test/runner.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 4cc252a

Please sign in to comment.