-
Notifications
You must be signed in to change notification settings - Fork 987
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fraschetti - Add tests for wallet_getWalletToken #19210
Changes from all commits
5637af2
0d8a4d3
a993457
8e696d3
94a1e09
d922b52
24410eb
24171c3
ad7dd92
c52146b
595acaa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -15,6 +15,8 @@ | |||||||||
|
||||||||||
(use-fixtures :each (h/fixture-session)) | ||||||||||
|
||||||||||
(def number-of-networks 3) | ||||||||||
|
||||||||||
(defn assert-accounts-get-accounts | ||||||||||
[result] | ||||||||||
(is (true? (some :wallet result))) | ||||||||||
|
@@ -27,29 +29,23 @@ | |||||||||
(p/let [result (contract-utils/call-rpc "accounts_getAccounts")] | ||||||||||
(assert-accounts-get-accounts result))))) | ||||||||||
|
||||||||||
(defn get-default-account | ||||||||||
[accounts] | ||||||||||
(first (filter :wallet accounts))) | ||||||||||
|
||||||||||
(defn check-emoji-is-updated | ||||||||||
[test-emoji accounts] | ||||||||||
(let [default-account (get-default-account accounts)] | ||||||||||
(let [default-account (contract-utils/get-default-account accounts)] | ||||||||||
(is (= (:emoji default-account) test-emoji)))) | ||||||||||
|
||||||||||
(deftest accounts-save-accounts-contract | ||||||||||
(h/test-async :contract/accounts-save-account | ||||||||||
(fn [] | ||||||||||
(p/let [test-emoji (emoji-picker.utils/random-emoji) | ||||||||||
account (contract-utils/call-rpc "accounts_getAccounts") | ||||||||||
default-account (get-default-account account) | ||||||||||
default-account (contract-utils/get-default-account account) | ||||||||||
_ (contract-utils/call-rpc | ||||||||||
"accounts_saveAccount" | ||||||||||
(data-store/<-account (merge default-account {:emoji test-emoji}))) | ||||||||||
accounts (contract-utils/call-rpc "accounts_getAccounts")] | ||||||||||
(check-emoji-is-updated test-emoji accounts))))) | ||||||||||
|
||||||||||
(def number-of-networks 3) | ||||||||||
|
||||||||||
(defn assert-ethereum-chains | ||||||||||
[response] | ||||||||||
(is (= number-of-networks (count response))) | ||||||||||
|
@@ -65,3 +61,29 @@ | |||||||||
(fn [] | ||||||||||
(p/let [response (contract-utils/call-rpc "wallet_getEthereumChains")] | ||||||||||
(assert-ethereum-chains response))))) | ||||||||||
|
||||||||||
(defn assert-wallet-tokens | ||||||||||
[tokens] | ||||||||||
(let [flattened-tokens (mapcat val tokens)] | ||||||||||
(doseq [token flattened-tokens] | ||||||||||
(is (not-empty (:symbol token))) | ||||||||||
(is (:decimals token)) | ||||||||||
(is (contains? token :balancesPerChain)) | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A simple one up the top of my mind:
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No worries. It's just that we calculate the fiat balance in the client app (Mobile/Desktop) using the market values we get from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. make sense. Thank you! I;'ve included |
||||||||||
(is (contains? token :marketValuesPerCurrency)) | ||||||||||
(is (contains? (:marketValuesPerCurrency token) :usd)) | ||||||||||
(let [balances-per-chain (:balancesPerChain token)] | ||||||||||
(doseq [[_ balance] balances-per-chain] | ||||||||||
(is (contains? balance :rawBalance)) | ||||||||||
(let [raw-balance (:rawBalance balance)] | ||||||||||
(is (not-empty raw-balance)) | ||||||||||
(is (re-matches #"\d+" raw-balance)))))))) | ||||||||||
|
||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cc @smohamedjavid looks good here in the assertion? ^^ |
||||||||||
(deftest wallet-get-walet-token-test | ||||||||||
(h/test-async :wallet/get-wallet-token | ||||||||||
(fn [] | ||||||||||
(p/let [accounts (contract-utils/call-rpc "accounts_getAccounts") | ||||||||||
default-address (contract-utils/get-default-address accounts) | ||||||||||
response (contract-utils/call-rpc | ||||||||||
"wallet_getWalletToken" | ||||||||||
[default-address])] | ||||||||||
(assert-wallet-tokens response))))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imo this is better defined in the test file. Do really need this defined as a global constant? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yah, I can roll back because this might change in future tests