Skip to content

Commit 35c2751

Browse files
authored
Merge pull request #2324 from AmbireTech/fix/portfolio-cache-test
Fix: mock the values from velcro as we don't need it for the portfolio cache test
2 parents cd63182 + b7e4fee commit 35c2751

1 file changed

Lines changed: 30 additions & 1 deletion

File tree

src/controllers/portfolio/portfolio.test.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2190,14 +2190,43 @@ describe('Portfolio Controller ', () => {
21902190
it('Price cache is updated after portfolio discovery', async () => {
21912191
const { controller } = await prepareTest()
21922192

2193+
// Make the test deterministic: we only want to verify that discovery prices
2194+
// populate the controller cache, not that the external API is reachable.
2195+
// @ts-ignore
2196+
controller.batchedPortfolioDiscovery = jest.fn().mockResolvedValue({
2197+
networkId: '137',
2198+
chainId: 137,
2199+
accountAddr: account.addr,
2200+
erc20s: [],
2201+
erc721s: {},
2202+
hasHints: true,
2203+
prices: {
2204+
'0x0000000000000000000000000000000000000000': {
2205+
baseCurrency: 'usd',
2206+
price: 1,
2207+
usd_24h_change: 0,
2208+
usd_market_cap: 1,
2209+
usd_24h_vol: 1,
2210+
exchanges: []
2211+
}
2212+
},
2213+
lastUpdate: Date.now(),
2214+
defi: {
2215+
positions: [],
2216+
updatedAt: Date.now()
2217+
},
2218+
otherNetworksDefiCounts: {}
2219+
})
2220+
21932221
// @ts-ignore
21942222
expect(controller.tokenDataCache['137']).toBe(undefined)
21952223
// @ts-ignore
21962224
await controller.getPortfolioFromApiDiscovery({
21972225
chainId: 137n,
21982226
account,
21992227
hasKeys: true,
2200-
baseCurrency: 'usd'
2228+
baseCurrency: 'usd',
2229+
externalApiHintsResponse: null
22012230
})
22022231

22032232
// @ts-ignore

0 commit comments

Comments
 (0)