infrastructure-upgrade/lib/v3-core/test/shared/checkObservationEquals.ts
T-Hax 735546619e
init
Signed-off-by: T-Hax <>
2023-04-08 18:46:18 +00:00

39 lines
1.1 KiB
TypeScript

import { BigNumber, BigNumberish } from 'ethers'
import { expect } from './expect'
// helper function because we cannot do a simple deep equals with the
// observation result object returned from ethers because it extends array
export default function checkObservationEquals(
{
tickCumulative,
blockTimestamp,
initialized,
secondsPerLiquidityCumulativeX128,
}: {
tickCumulative: BigNumber
secondsPerLiquidityCumulativeX128: BigNumber
initialized: boolean
blockTimestamp: number
},
expected: {
tickCumulative: BigNumberish
secondsPerLiquidityCumulativeX128: BigNumberish
initialized: boolean
blockTimestamp: number
}
) {
expect(
{
initialized,
blockTimestamp,
tickCumulative: tickCumulative.toString(),
secondsPerLiquidityCumulativeX128: secondsPerLiquidityCumulativeX128.toString(),
},
`observation is equivalent`
).to.deep.eq({
...expected,
tickCumulative: expected.tickCumulative.toString(),
secondsPerLiquidityCumulativeX128: expected.secondsPerLiquidityCumulativeX128.toString(),
})
}