Skip to content

Commit

Permalink
fix integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
groninge01 committed Oct 14, 2024
1 parent 5fbf17d commit 54900ec
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 23 deletions.
2 changes: 1 addition & 1 deletion packages/lib/debug-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Address } from 'viem'
*/
export const balAddress = '0xba100000625a3754423978a60c9317c58a424e3d' as const
export const wETHAddress = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' as const
export const wjAuraAddress = '0x198d7387fa97a73f05b8578cdeff8f2a1f34cd1f' as const
export const wjAuraAddress = '0x198d7387Fa97A73F05b8578CdEFf8F2A1f34Cd1F' as const

export const bpt3PoolAddress = '0x79c58f70905f734641735bc61e45c19dd9ad60bc' as const
export const daiAddress = '0x6b175474e89094c44da98b954eedeac495271d0f' as const
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { HumanTokenAmountWithAddress } from '../../tokens/token.types'
describe('areEmptyAmounts', () => {
test('when all humanAmounts are empty, zero or zero with decimals', () => {
const humanAmountsIn: HumanTokenAmountWithAddress[] = [
{ tokenAddress: '0x198d7387fa97a73f05b8578cdeff8f2a1f34cd1f', humanAmount: '' },
{ tokenAddress: '0x198d7387Fa97A73F05b8578CdEFf8F2A1f34Cd1F', humanAmount: '' },
{ tokenAddress: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', humanAmount: '0' },
{ tokenAddress: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756bb3', humanAmount: '0.00' },
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { HumanTokenAmountWithAddress } from '@repo/lib/modules/tokens/token.type

function testGenerateLiquidityKeys(pool: Pool) {
const humanAmountsIn: HumanTokenAmountWithAddress[] = [
{ tokenAddress: '0x198d7387fa97a73f05b8578cdeff8f2a1f34cd1f', humanAmount: '0' },
{ tokenAddress: '0x198d7387Fa97A73F05b8578CdEFf8F2A1f34Cd1F', humanAmount: '0' },
{ tokenAddress: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', humanAmount: '0' },
]
return addLiquidityKeys.priceImpact({
Expand All @@ -30,7 +30,7 @@ describe('Generates expected query keys', () => {
[
"add-liquidity",
"price-impact",
"UnbalancedAddLiquidityV2Handler:0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266:0x68e3266c9c8bbd44ad9dca5afbfe629022aee9fe000200000000000000000512:0.2:[{"tokenAddress":"0x198d7387fa97a73f05b8578cdeff8f2a1f34cd1f","humanAmount":"0"},{"tokenAddress":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","humanAmount":"0"}]no-permit2",
"UnbalancedAddLiquidityV2Handler:0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266:0x68e3266c9c8bbd44ad9dca5afbfe629022aee9fe000200000000000000000512:0.2:[{"tokenAddress":"0x198d7387Fa97A73F05b8578CdEFf8F2A1f34Cd1F","humanAmount":"0"},{"tokenAddress":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","humanAmount":"0"}]no-permit2",
]
`
)
Expand All @@ -45,7 +45,7 @@ describe('Generates expected query keys', () => {
[
"add-liquidity",
"price-impact",
"UnbalancedAddLiquidityV2Handler:0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266:0xdac42eeb17758daa38caf9a3540c808247527ae3000200000000000000000a2b:0.2:{"tokenAddress":"0x198d7387fa97a73f05b8578cdeff8f2a1f34cd1f","humanAmount":"0"}no-permit2",
"UnbalancedAddLiquidityV2Handler:0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266:0xdac42eeb17758daa38caf9a3540c808247527ae3000200000000000000000a2b:0.2:{"tokenAddress":"0x198d7387Fa97A73F05b8578CdEFf8F2A1f34Cd1F","humanAmount":"0"}no-permit2",
]
`
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { testHook } from '@repo/lib/test/utils/custom-renderers'
import { waitFor } from '@testing-library/react'

import { getGqlChain } from '@repo/lib/config/app.config'
import { polAddress } from '@repo/lib/debug-helpers'
import { GqlChain } from '@repo/lib/shared/services/api/generated/graphql'
Expand Down Expand Up @@ -54,11 +53,11 @@ test('queries add liquidity transaction', async () => {

expect(result.current.sentTokens).toEqual([
{
tokenAddress: '0x198d7387Fa97A73F05b8578CdEFf8F2A1f34Cd1F',
tokenAddress: '0x198d7387fa97a73f05b8578cdeff8f2a1f34cd1f',
humanAmount: '12',
},
{
tokenAddress: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
tokenAddress: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
humanAmount: '0.04',
},
])
Expand Down Expand Up @@ -99,23 +98,23 @@ test('queries remove liquidity transaction', async () => {
expect(result.current.receivedTokens).toEqual([
{
humanAmount: '16597.845312687911573359',
tokenAddress: '0x198d7387Fa97A73F05b8578CdEFf8F2A1f34Cd1F',
tokenAddress: '0x198d7387fa97a73f05b8578cdeff8f2a1f34cd1f',
},
{
humanAmount: '4.553531492712836774',
tokenAddress: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
tokenAddress: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
},
])

expect(result.current.sentBptUnits).toBe('6439.400687368663510166')
})

describe('queries swap transaction', () => {
const polAddress = '0x0000000000000000000000000000000000001010'
const wPolAddress = '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270'
const maticAddress = '0x0000000000000000000000000000000000001010'
const wMaticAddress = '0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270'
const daiAddress = '0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063'

test('when the native asset is not included (from DAI to WPOL)', async () => {
test('when the native asset is not included (from DAI to WMATIC)', async () => {
const userAddress = '0xf76142b79Db34E57852d68F9c52C0E24f7349647'
// https://polygonscan.com/tx/0x11380dcffb24c512da18f032d9f7354d154cfda6bbab0633df182fcd202c4244
const txHash = '0x11380dcffb24c512da18f032d9f7354d154cfda6bbab0633df182fcd202c4244'
Expand All @@ -126,16 +125,16 @@ describe('queries swap transaction', () => {

expect(result.current.sentToken).toEqual({
humanAmount: '1',
tokenAddress: daiAddress,
tokenAddress: daiAddress.toLowerCase(),
})

expect(result.current.receivedToken).toEqual({
humanAmount: '1.419839650912753603',
tokenAddress: wPolAddress,
tokenAddress: wMaticAddress,
})
})

test('when the native asset is the token in (from POL to DAI)', async () => {
test('when the native asset is the token in (from MATIC to DAI)', async () => {
const userAddress = '0xf76142b79Db34E57852d68F9c52C0E24f7349647'
// https://polygonscan.com/tx/0x78ddd90502509a264a5e8f4f3732668db669e7614f4887f2a233ce39e5eafa7c
const txHash = '0x78ddd90502509a264a5e8f4f3732668db669e7614f4887f2a233ce39e5eafa7c'
Expand All @@ -146,16 +145,16 @@ describe('queries swap transaction', () => {

expect(result.current.sentToken).toEqual({
humanAmount: '1',
tokenAddress: polAddress,
tokenAddress: maticAddress,
})

expect(result.current.receivedToken).toEqual({
humanAmount: '0.693570611425675513',
tokenAddress: daiAddress,
tokenAddress: daiAddress.toLowerCase(),
})
})

test('when the native asset is the token out (from DAI to POL)', async () => {
test('when the native asset is the token out (from DAI to MATIC)', async () => {
const userAddress = '0xf76142b79Db34E57852d68F9c52C0E24f7349647'
// https://polygonscan.com/tx/0xe0b75845d13ae12029c8dfef68488b3bf35347460fafdb3a15a5c7f884226288
const txHash = '0xe0b75845d13ae12029c8dfef68488b3bf35347460fafdb3a15a5c7f884226288'
Expand All @@ -166,12 +165,12 @@ describe('queries swap transaction', () => {

expect(result.current.sentToken).toEqual({
humanAmount: '0.1',
tokenAddress: daiAddress,
tokenAddress: daiAddress.toLowerCase(),
})

expect(result.current.receivedToken).toEqual({
humanAmount: '0.241277224191485579',
tokenAddress: polAddress,
tokenAddress: maticAddress,
})
})
})
Expand Down
2 changes: 1 addition & 1 deletion packages/lib/shared/utils/query-errors.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ describe('Captures sentry error', () => {
"handler": {
"helpers": "[LiquidityActionHelpers]",
},
"humanAmountsIn": "[{"humanAmount":"3","tokenAddress":"0x198d7387fa97a73f05b8578cdeff8f2a1f34cd1f"},{"humanAmount":"0.01","tokenAddress":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"}]",
"humanAmountsIn": "[{"humanAmount":"3","tokenAddress":"0x198d7387Fa97A73F05b8578CdEFf8F2A1f34Cd1F"},{"humanAmount":"0.01","tokenAddress":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"}]",
"poolId": "0x68e3266c9c8bbd44ad9dca5afbfe629022aee9fe000200000000000000000512",
"poolType": "WEIGHTED",
"slippage": "0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/lib/vitest.config.integration.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import { InlineConfig } from 'vitest'
import { InlineConfig } from 'vitest/node'
import vitestUnitConfig from './vitest.config'

function setupFilesWithoutMswSetup() {
Expand Down

0 comments on commit 54900ec

Please sign in to comment.