Skip to content

Commit

Permalink
add more unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
jsy1218 committed Jul 19, 2024
1 parent 264472a commit 0ba3858
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion test/mocha/e2e/quote.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,7 @@ describe('quote', function () {
// if fee-on-transfer flag is not enabled, most likely the simulation will fail due to quote not subtracting the tax
simulateFromAddress: enableFeeOnTransferFeeFetching ? simulateFromAddress : undefined,
portionBips: FLAT_PORTION.bips,
portionRecipient: FLAT_PORTION.recipient
portionRecipient: FLAT_PORTION.recipient,
}

const queryParams = qs.stringify(quoteReq)
Expand Down
16 changes: 16 additions & 0 deletions test/mocha/integ/graphql/graphql-token-fee-fetcher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,15 @@ describe('integration test for GraphQLTokenFeeFetcher', () => {
expect(tokenFeeMap[WETH9[ChainId.MAINNET]!.address]).to.not.be.undefined
expect(tokenFeeMap[WETH9[ChainId.MAINNET]!.address]?.buyFeeBps).to.be.undefined
expect(tokenFeeMap[WETH9[ChainId.MAINNET]!.address]?.sellFeeBps).to.be.undefined
expect(tokenFeeMap[WETH9[ChainId.MAINNET]!.address]?.feeTakenOnTransfer).to.not.be.undefined

Check failure on line 67 in test/mocha/integ/graphql/graphql-token-fee-fetcher.test.ts

View workflow job for this annotation

GitHub Actions / Run tests

Property 'feeTakenOnTransfer' does not exist on type 'TokenFeeResult'.
expect(tokenFeeMap[WETH9[ChainId.MAINNET]!.address]?.externalTransferFailed).to.not.be.undefined

Check failure on line 68 in test/mocha/integ/graphql/graphql-token-fee-fetcher.test.ts

View workflow job for this annotation

GitHub Actions / Run tests

Property 'externalTransferFailed' does not exist on type 'TokenFeeResult'.
expect(tokenFeeMap[WETH9[ChainId.MAINNET]!.address]?.sellReverted).to.not.be.undefined

Check failure on line 69 in test/mocha/integ/graphql/graphql-token-fee-fetcher.test.ts

View workflow job for this annotation

GitHub Actions / Run tests

Property 'sellReverted' does not exist on type 'TokenFeeResult'.
expect(tokenFeeMap[BITBOY.address]).to.not.be.undefined
expect(tokenFeeMap[BITBOY.address]?.buyFeeBps?._hex).equals(BITBOY.buyFeeBps?._hex)
expect(tokenFeeMap[BITBOY.address]?.sellFeeBps?._hex).equals(BITBOY.sellFeeBps?._hex)
expect(tokenFeeMap[BITBOY.address]?.feeTakenOnTransfer).equals(false)

Check failure on line 73 in test/mocha/integ/graphql/graphql-token-fee-fetcher.test.ts

View workflow job for this annotation

GitHub Actions / Run tests

Property 'feeTakenOnTransfer' does not exist on type 'TokenFeeResult'.
expect(tokenFeeMap[BITBOY.address]?.externalTransferFailed).equals(true)

Check failure on line 74 in test/mocha/integ/graphql/graphql-token-fee-fetcher.test.ts

View workflow job for this annotation

GitHub Actions / Run tests

Property 'externalTransferFailed' does not exist on type 'TokenFeeResult'.
expect(tokenFeeMap[BITBOY.address]?.sellReverted).equals(false)

Check failure on line 75 in test/mocha/integ/graphql/graphql-token-fee-fetcher.test.ts

View workflow job for this annotation

GitHub Actions / Run tests

Property 'sellReverted' does not exist on type 'TokenFeeResult'.
})

it('Fetch BULLET and BITBOY, should return BOTH', async () => {
Expand All @@ -77,9 +83,16 @@ describe('integration test for GraphQLTokenFeeFetcher', () => {
expect(tokenFeeMap[BULLET.address]).to.not.be.undefined
expect(tokenFeeMap[BULLET.address]?.buyFeeBps?._hex).equals(BULLET.buyFeeBps?._hex)
expect(tokenFeeMap[BULLET.address]?.sellFeeBps?._hex).equals(BULLET.sellFeeBps?._hex)
expect(tokenFeeMap[BULLET.address]?.feeTakenOnTransfer).equals(false)

Check failure on line 86 in test/mocha/integ/graphql/graphql-token-fee-fetcher.test.ts

View workflow job for this annotation

GitHub Actions / Run tests

Property 'feeTakenOnTransfer' does not exist on type 'TokenFeeResult'.
expect(tokenFeeMap[BULLET.address]?.externalTransferFailed).equals(false)

Check failure on line 87 in test/mocha/integ/graphql/graphql-token-fee-fetcher.test.ts

View workflow job for this annotation

GitHub Actions / Run tests

Property 'externalTransferFailed' does not exist on type 'TokenFeeResult'.
expect(tokenFeeMap[BULLET.address]?.sellReverted).equals(false)

expect(tokenFeeMap[BITBOY.address]).to.not.be.undefined
expect(tokenFeeMap[BITBOY.address]?.buyFeeBps?._hex).equals(BITBOY.buyFeeBps?._hex)
expect(tokenFeeMap[BITBOY.address]?.sellFeeBps?._hex).equals(BITBOY.sellFeeBps?._hex)
expect(tokenFeeMap[BITBOY.address]?.feeTakenOnTransfer).equals(false)
expect(tokenFeeMap[BITBOY.address]?.externalTransferFailed).equals(true)
expect(tokenFeeMap[BITBOY.address]?.sellReverted).equals(false)

expect(spyGraphQLFetcher.calledOnce).to.be.true
expect(spyOnChainFetcher.calledOnce).to.be.false
Expand All @@ -97,6 +110,9 @@ describe('integration test for GraphQLTokenFeeFetcher', () => {
expect(tokenFeeMap[BITBOY.address]).to.not.be.undefined
expect(tokenFeeMap[BITBOY.address]?.buyFeeBps?._hex).equals(BITBOY.buyFeeBps?._hex)
expect(tokenFeeMap[BITBOY.address]?.sellFeeBps?._hex).equals(BITBOY.sellFeeBps?._hex)
expect(tokenFeeMap[BITBOY.address]?.feeTakenOnTransfer).equals(false)
expect(tokenFeeMap[BITBOY.address]?.externalTransferFailed).equals(true)
expect(tokenFeeMap[BITBOY.address]?.sellReverted).equals(false)

expect(spyGraphQLFetcher.calledOnce).to.be.true
expect(spyOnChainFetcher.calledOnce).to.be.true
Expand Down

0 comments on commit 0ba3858

Please sign in to comment.