forked from Uniswap/interface
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidateTokenList.test.ts
More file actions
42 lines (37 loc) · 1.2 KB
/
Copy pathvalidateTokenList.test.ts
File metadata and controls
42 lines (37 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { TokenInfo } from '@uniswap/token-lists'
import { validateTokens } from './validateTokenList'
const INVALID_TOKEN: TokenInfo = {
name: 'Dai Stablecoin',
address: '0xD3ADB33F',
symbol: 'DAI',
decimals: 18,
chainId: 1,
}
const INLINE_TOKEN_LIST = [
{
name: 'Dai Stablecoin',
address: '0x6B175474E89094C44Da98b954EedeAC495271d0F',
symbol: 'DAI',
decimals: 18,
chainId: 1,
logoURI:
'https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0x6B175474E89094C44Da98b954EedeAC495271d0F/logo.png',
},
{
name: 'USDCoin',
address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
symbol: 'USDC',
decimals: 6,
chainId: 1,
logoURI:
'https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/logo.png',
},
]
describe('validateTokens', () => {
it('throws on invalid tokens', async () => {
await expect(validateTokens([INVALID_TOKEN])).rejects.toThrow(/^Tokens failed validation:.*address/)
})
it('validates the passed token info', async () => {
await expect(validateTokens(INLINE_TOKEN_LIST)).resolves.toBe(INLINE_TOKEN_LIST)
})
})