From 5ba284a67de71ec1ab771103ec0a39f3405c91a6 Mon Sep 17 00:00:00 2001 From: RabbitDoge <72658581+RabbitDoge@users.noreply.github.com> Date: Mon, 22 Mar 2021 21:03:19 +0900 Subject: [PATCH] test: Add tests for token config (#709) --- .env.test | 5 +++++ src/__tests__/config/tokens.test.ts | 28 ++++++++++++++++++++++++++++ src/config/constants/tokens.ts | 8 ++++---- 3 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 .env.test create mode 100644 src/__tests__/config/tokens.test.ts diff --git a/.env.test b/.env.test new file mode 100644 index 0000000000000..0317a81055803 --- /dev/null +++ b/.env.test @@ -0,0 +1,5 @@ +REACT_APP_CHAIN_ID = "56" + +REACT_APP_NODE_1 = "https://bsc-dataseed1.ninicoin.io" +REACT_APP_NODE_2 = "https://bsc-dataseed1.defibit.io" +REACT_APP_NODE_3 = "https://bsc-dataseed.binance.org" diff --git a/src/__tests__/config/tokens.test.ts b/src/__tests__/config/tokens.test.ts new file mode 100644 index 0000000000000..3923db2dc94b2 --- /dev/null +++ b/src/__tests__/config/tokens.test.ts @@ -0,0 +1,28 @@ +import map from 'lodash/map' +import omitBy from 'lodash/omitBy' +import erc20ABI from 'config/abi/erc20.json' +import tokens from 'config/constants/tokens' +import { Token } from 'config/constants/types' +import multicall from 'utils/multicall' + +// remove BNB because it's not a Bep20 token +const tokensToTest = omitBy(tokens, (token) => token.symbol.toLowerCase() === 'bnb') + +describe('Config tokens', () => { + it.each(map(tokensToTest, (token, key) => [key, token]))('Token %s', async (key, token: Token) => { + const [[symbol], [decimals]] = await multicall(erc20ABI, [ + { + address: token.address[56], + name: 'symbol', + }, + { + address: token.address[56], + name: 'decimals', + }, + ]) + + expect(key).toBe(token.symbol.toLowerCase()) + expect(token.symbol.toLowerCase()).toBe(symbol.toLowerCase()) + expect(token.decimals).toBe(parseInt(decimals, 10)) + }) +}) diff --git a/src/config/constants/tokens.ts b/src/config/constants/tokens.ts index 51f239e54f1a3..311858e62800e 100644 --- a/src/config/constants/tokens.ts +++ b/src/config/constants/tokens.ts @@ -435,8 +435,8 @@ const tokens = { decimals: 18, projectLink: 'https://pancakeswap.finance/', }, - blk: { - symbol: 'BLK', + blink: { + symbol: 'BLINK', address: { 56: '0x63870a18b6e42b01ef1ad8a2302ef50b7132054f', 97: '', @@ -741,8 +741,8 @@ const tokens = { decimals: 18, projectLink: 'https://tether.to/', }, - btc: { - symbol: 'BTC', + btcb: { + symbol: 'BTCB', address: { 56: '0x7130d2a12b9bcbfae4f2634d864a1ee1ce3ead9c', 97: '0xE02dF9e3e622DeBdD69fb838bB799E3F168902c5',