Skip to content

Commit

Permalink
test: Add tests for token config (pancakeswap#709)
Browse files Browse the repository at this point in the history
  • Loading branch information
RabbitDoge authored Mar 22, 2021
1 parent 515ee53 commit 5ba284a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -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"
28 changes: 28 additions & 0 deletions src/__tests__/config/tokens.test.ts
Original file line number Diff line number Diff line change
@@ -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))
})
})
8 changes: 4 additions & 4 deletions src/config/constants/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,8 @@ const tokens = {
decimals: 18,
projectLink: 'https://pancakeswap.finance/',
},
blk: {
symbol: 'BLK',
blink: {
symbol: 'BLINK',
address: {
56: '0x63870a18b6e42b01ef1ad8a2302ef50b7132054f',
97: '',
Expand Down Expand Up @@ -741,8 +741,8 @@ const tokens = {
decimals: 18,
projectLink: 'https://tether.to/',
},
btc: {
symbol: 'BTC',
btcb: {
symbol: 'BTCB',
address: {
56: '0x7130d2a12b9bcbfae4f2634d864a1ee1ce3ead9c',
97: '0xE02dF9e3e622DeBdD69fb838bB799E3F168902c5',
Expand Down

0 comments on commit 5ba284a

Please sign in to comment.