Fraschetti - Add tests for wallet_getWalletToken (#19210)
- Add tests for wallet_getWalletToken - Remove get-main-account - Add get-default-address function - Adapt constants/fixtures for recovered account
This commit is contained in:
parent
6d74d0396e
commit
90913500b4
|
@ -12,3 +12,11 @@
|
|||
:params args
|
||||
:on-success p-resolve
|
||||
:on-error p-reject}))))
|
||||
|
||||
(defn get-default-account
|
||||
[accounts]
|
||||
(first (filter :wallet accounts)))
|
||||
|
||||
(defn get-default-address
|
||||
[accounts]
|
||||
(:address (get-default-account accounts)))
|
||||
|
|
|
@ -14,10 +14,6 @@
|
|||
|
||||
(use-fixtures :each (h/fixture-session :recovered-account))
|
||||
|
||||
(defn get-main-account
|
||||
[accounts]
|
||||
(:address (first accounts)))
|
||||
|
||||
(defn assert-derived-account
|
||||
[response]
|
||||
(let [{:keys [address public-key]} (first response)]
|
||||
|
@ -28,13 +24,13 @@
|
|||
(deftest wallet-get-derived-addressess-contract-test
|
||||
(h/test-async :wallet/create-derived-addresses
|
||||
(fn []
|
||||
(p/let [sha3-pwd (native-module/sha3 integration-constants/password)
|
||||
(p/let [sha3-pwd-hash (native-module/sha3 integration-constants/password)
|
||||
derivation-path [integration-constants/derivation-path]
|
||||
accounts (contract-utils/call-rpc "accounts_getAccounts")
|
||||
main-account (get-main-account accounts)
|
||||
default-address (contract-utils/get-default-address accounts)
|
||||
response (contract-utils/call-rpc
|
||||
"wallet_getDerivedAddresses"
|
||||
sha3-pwd
|
||||
main-account
|
||||
sha3-pwd-hash
|
||||
default-address
|
||||
derivation-path)]
|
||||
(assert-derived-account response)))))
|
||||
|
|
|
@ -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,13 +29,9 @@
|
|||
(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
|
||||
|
@ -41,15 +39,13 @@
|
|||
(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))
|
||||
(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))))))))
|
||||
|
||||
(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)))))
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
|
||||
(def derivation-path "m/43'/60'/1581'/0'/0")
|
||||
|
||||
(def derived-address "0x542bf2d18e83ba176c151c949c53eee896fa5a3e")
|
||||
(def derived-address "0x64829fa755b9fda0c7ece27434970807aecc8c79")
|
||||
|
||||
(def recovery-account
|
||||
{:name "wallet-abc"
|
||||
:seed-phrase "destroy end torch puzzle develop note wise island disease chaos kind bus"
|
||||
:key-uid "0x6827f3d1e21ae723a24e0dcbac1853b5ed4d651c821a2326492ce8f2367ec905"
|
||||
:public-key
|
||||
"0x04937b2d8ed320f89a437e3c854213ec56b34c0c5a5a6105fd6f0850574d10af6988f128b4e2b7b7171f4599deda75584c7c75f7cdf0846f8d485a7f593a5f31f6"})
|
||||
"0x04ca1446090fa458f42a54307fb191daf132d295bd364a691a5434e1b5717e4cf3116e66b1f5188dd18f1b74fe70fe77cff02e5d6c279f3834f47176563393be1c"})
|
||||
|
|
Loading…
Reference in New Issue