Skip to content

Commit d784cd9

Browse files
committed
fix api mocks
1 parent 14efbd0 commit d784cd9

File tree

5 files changed

+14
-17
lines changed

5 files changed

+14
-17
lines changed

test/e2e/tests/privacy/basic-functionality.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ async function mockApis(
8383
},
8484
};
8585
}),
86-
await mockEmptyPrices(mockServer, CHAIN_IDS.MAINNET),
86+
await mockEmptyPrices(mockServer),
8787
];
8888
}
8989

test/e2e/tests/swaps/swap-erc20-with-loaded-state.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ async function mockSwapQuotes(mockServer: MockttpServer) {
1818

1919
return [
2020
await mockEmptyHistoricalPrices(mockServer, ETH_ADDRESS, '0x1'),
21-
await mockEmptyPrices(mockServer, '1'),
21+
await mockEmptyPrices(mockServer),
2222
await mockServer
2323
.forGet('https://bridge.api.cx.metamask.io/token/1')
2424
.thenCallback(() => ({

test/e2e/tests/tokens/token-details.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('Token Details', function () {
3333
...fixtures,
3434
title: (this as Context).test?.fullTitle(),
3535
testSpecificMock: async (mockServer: Mockttp) => [
36-
await mockEmptyPrices(mockServer, chainId),
36+
await mockEmptyPrices(mockServer),
3737
await mockEmptyHistoricalPrices(mockServer, tokenAddress, chainId),
3838
],
3939
},
@@ -80,7 +80,7 @@ describe('Token Details', function () {
8080
title: (this as Context).test?.fullTitle(),
8181
ethConversionInUsd,
8282
testSpecificMock: async (mockServer: Mockttp) => [
83-
await mockSpotPrices(mockServer, chainId, {
83+
await mockSpotPrices(mockServer, {
8484
[tokenAddress.toLowerCase()]: marketData,
8585
}),
8686
await mockHistoricalPrices(mockServer, {

test/e2e/tests/tokens/token-list.spec.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ const isFirefox = process.env.SELENIUM_BROWSER === Browser.FIREFOX;
2020

2121
describe('Token List', function () {
2222
const chainId = CHAIN_IDS.MAINNET;
23-
const lineaChainId = CHAIN_IDS.LINEA_MAINNET;
2423
const tokenAddress = '0x2EFA2Cb29C2341d8E5Ba7D3262C9e9d6f1Bf3711';
2524
const symbol = 'foo';
2625

@@ -37,8 +36,7 @@ describe('Token List', function () {
3736
...fixtures,
3837
title: (this as Context).test?.fullTitle(),
3938
testSpecificMock: async (mockServer: Mockttp) => [
40-
await mockEmptyPrices(mockServer, chainId),
41-
await mockEmptyPrices(mockServer, lineaChainId),
39+
await mockEmptyPrices(mockServer),
4240
await mockEmptyHistoricalPrices(mockServer, tokenAddress, chainId),
4341
],
4442
},
@@ -84,9 +82,9 @@ describe('Token List', function () {
8482
title: (this as Context).test?.fullTitle(),
8583
ethConversionInUsd,
8684
testSpecificMock: async (mockServer: Mockttp) => [
87-
await mockSpotPrices(mockServer, chainId, {
88-
[zeroAddress()]: marketDataNative,
89-
[tokenAddress.toLowerCase()]: marketData,
85+
await mockSpotPrices(mockServer, {
86+
'eip155:1/slip44:60': marketDataNative,
87+
[`eip155:1/erc20:${tokenAddress.toLowerCase()}`]: marketData,
9088
}),
9189
await mockHistoricalPrices(mockServer, {
9290
address: tokenAddress,

test/e2e/tests/tokens/utils/mocks.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { Mockttp } from 'mockttp';
22
import { toChecksumHexAddress } from '../../../../../shared/modules/hexstring-utils';
33

4+
const PRICE_API_URL = 'https://price.api.cx.metamask.io';
5+
46
const getPriceUrl = (version: string, chainId: string, endpoint: string) =>
5-
`https://price.api.cx.metamask.io/${version}/chains/${chainId}/${endpoint}`;
7+
`${PRICE_API_URL}/${version}/chains/${chainId}/${endpoint}`;
68

7-
export const mockEmptyPrices = async (mockServer: Mockttp, chainId: string) => {
9+
export const mockEmptyPrices = async (mockServer: Mockttp) => {
810
return mockServer
9-
.forGet(getPriceUrl('v2', parseInt(chainId, 16).toString(), 'spot-prices'))
11+
.forGet(`${PRICE_API_URL}/v3/spot-prices`)
1012
.thenCallback(() => ({
1113
statusCode: 200,
1214
json: {},
@@ -28,16 +30,13 @@ export const mockEmptyHistoricalPrices = async (
2830

2931
export const mockSpotPrices = async (
3032
mockServer: Mockttp,
31-
chainIdToMock: string,
3233
prices: Record<
3334
string,
3435
{ price: number; pricePercentChange1d?: number; marketCap: number }
3536
>,
3637
) => {
3738
return mockServer
38-
.forGet(
39-
getPriceUrl('v2', parseInt(chainIdToMock, 16).toString(), 'spot-prices'),
40-
)
39+
.forGet(`${PRICE_API_URL}/v3/spot-prices`)
4140
.thenCallback(() => ({
4241
statusCode: 200,
4342
json: prices,

0 commit comments

Comments
 (0)