Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bergeron committed May 31, 2024
1 parent 365706a commit 6dd2c8d
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 30 deletions.
3 changes: 1 addition & 2 deletions app/scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,7 @@ function saveTimestamp() {
* @property {object} identities - An object matching lower-case hex addresses to Identity objects with "address" and "name" (nickname) keys.
* @property {object} networkConfigurations - A list of network configurations, containing RPC provider details (eg chainId, rpcUrl, rpcPreferences).
* @property {Array} addressBook - A list of previously sent to addresses.
* @property {object} contractExchangeRatesByChainId - Info about current token prices keyed by chainId.
* @property {object} contractExchangeRates - Info about current token prices on current chain.
* @property {object} marketData - A map from chain ID -> contract address -> an object containing the token's market data.
* @property {Array} tokens - Tokens held by the current user, including their balances.
* @property {object} send - TODO: Document
* @property {boolean} useBlockie - Indicates preferred user identicon format. True for blockie, false for Jazzicon.
Expand Down
6 changes: 0 additions & 6 deletions test/data/mock-state.json
Original file line number Diff line number Diff line change
Expand Up @@ -687,12 +687,6 @@
"decimals": "18"
}
],
"contractExchangeRates": {
"0x108cf70c7d384c552f42c07c41c0e1e46d77ea0d": 0.00039345803819379796,
"0xd8f6a2ffb0fc5952d16c9768b71cfd35b6399aa5": 0.00008189274407698049,
"0x2260fac5e5542a773aa44fbcfedf7c193bc2c599": 0.0017123,
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48": 0.0000000018
},
"marketData": {
"0x89": {
"0x108cf70c7d384c552f42c07c41c0e1e46d77ea0d": {
Expand Down
3 changes: 0 additions & 3 deletions test/e2e/default-fixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,6 @@ function defaultFixture(inputChainId = CHAIN_IDS.LOCALHOST) {
ignoredTokens: [],
tokens: [],
},
// TokenRatesController: {
// contractExchangeRates: {},
// },
TransactionController: {
transactions: {},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@
"fcmToken": "string",
"accounts": "object",
"accountsByChainId": "object",
"contractExchangeRatesByChainId": "object",
"unapprovedDecryptMsgs": "object",
"unapprovedDecryptMsgCount": 0,
"unapprovedEncryptionPublicKeyMsgs": "object",
Expand Down
3 changes: 3 additions & 0 deletions test/e2e/tests/swap-send/swap-send-test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,9 @@ export const getSwapSendFixtures = (
},
})
// TODO fix TST exchange rate (not visible atm)
// Note: The token rates controller has deprecated `contractExchangeRates` in favor of
// a new `marketData` structure. See https://github.com/MetaMask/core/pull/4206
//
// .withTokenRatesController({
// contractExchangeRates: {
// '0x581c3C1A2A4EBDE2A0Df29B5cf4c116E42945947':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,11 @@ const renderUseTokenExchangeRate = (
},
},
marketData: {
'0x89': {
'0x5': {
'0xdAC17F958D2ee523a2206206994597C13D831ec7': { value: 0.5 },
'0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e': { value: 3.304588 },
},
},
providerConfig: {
ticker: 'ETH',
},
...metaMaskState,
},
};
Expand Down
1 change: 0 additions & 1 deletion ui/components/app/wallet-overview/eth-overview.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ describe('EthOverview', () => {
accounts: [],
},
],
contractExchangeRates: {},
},
};

Expand Down
1 change: 0 additions & 1 deletion ui/components/app/wallet-overview/token-overview.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ describe('TokenOverview', () => {
accounts: [],
},
],
contractExchangeRates: {},
mmiConfiguration: {
portfolio: {
enabled: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ const store = configureStore({
conversionRate: 231.06,
},
},
contractExchangeRates: {
...mockState.metamask.contractExchangeRates,
'0x0bc529c00c6401aef6d220be8c6ea1667f6ad93e': 0.01,
marketData: {
...mockState.metamask.marketData,
'0x1': {
...mockState.metamask.marketData['0x1'],
'0x0bc529c00c6401aef6d220be8c6ea1667f6ad93e': { value: 0.01 }
}
},
tokens: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ const store = (
// TODO: Replace `any` with type
// eslint-disable-next-line @typescript-eslint/no-explicit-any
tokenList = {} as any,
// TODO: Replace `any` with type
// eslint-disable-next-line @typescript-eslint/no-explicit-any
contractExchangeRates = {} as any,
) =>
configureStore({
...mockSendState,
Expand All @@ -24,7 +21,6 @@ const store = (
conversionRate: 11.1,
},
},
contractExchangeRates,
providerConfig: {
chainId: '0x1',
ticker: nativeTicker,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ const createStore = ({
metamask: {
...mockSendState.metamask,
preferences: { useNativeCurrencyAsPrimaryCurrency },
contractExchangeRates: {
'0x0bc529c00c6401aef6d220be8c6ea1667f6ad93e': 2,
marketData: {
...mockSendState.metamask.marketData,
'0x5': {
...mockSendState.metamask.marketData['0x5'],
'0x0bc529c00c6401aef6d220be8c6ea1667f6ad93e': { value: 2 },
},
},
},
appState: { ...mockSendState.appState, sendInputCurrencySwitched },
Expand Down
8 changes: 5 additions & 3 deletions ui/hooks/useAccountTotalFiatBalance.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ const renderUseAccountTotalFiatBalance = (address) => {
conversionRate: 1612.92,
},
},
contractExchangeRates: {
'0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48': 0.0006189,
'0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e': 3.304588,
marketData: {
[CHAIN_IDS.MAINNET]: {
'0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48': { value: 0.0006189 },
'0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e': { value: 3.304588 },
},
},
accountsByChainId: {
[CHAIN_IDS.MAINNET]: {
Expand Down

0 comments on commit 6dd2c8d

Please sign in to comment.