From 7418297d945399a043122daa4b3d0d57fb39e77c Mon Sep 17 00:00:00 2001 From: Noah Zinsmeister Date: Tue, 21 Mar 2023 13:48:08 -0400 Subject: [PATCH] delete some tests --- .gitignore | 2 ++ contracts/test/TestERC20.sol | 4 --- remappings.txt | 3 ++ ...acle.spec.ts => GeomeanOracle.spec.ts.old} | 0 test/LimitOrderHook.t.sol | 16 +++++++++ .../__snapshots__/LimitOrderHook.spec.ts.snap | 17 ---------- ...quals.ts => checkObservationEquals.ts.old} | 0 .../shared/{constants.ts => constants.ts.old} | 0 test/shared/evmHelpers.ts | 16 --------- test/shared/expect.ts | 8 ----- test/shared/fixtures.ts | 22 ------------ test/shared/format.ts | 10 ------ test/shared/mockContract.ts | 34 ------------------- .../shared/{utilities.ts => utilities.ts.old} | 0 14 files changed, 21 insertions(+), 111 deletions(-) delete mode 100644 contracts/test/TestERC20.sol create mode 100644 remappings.txt rename test/{GeomeanOracle.spec.ts => GeomeanOracle.spec.ts.old} (100%) create mode 100644 test/LimitOrderHook.t.sol delete mode 100644 test/__snapshots__/LimitOrderHook.spec.ts.snap rename test/shared/{checkObservationEquals.ts => checkObservationEquals.ts.old} (100%) rename test/shared/{constants.ts => constants.ts.old} (100%) delete mode 100644 test/shared/evmHelpers.ts delete mode 100644 test/shared/expect.ts delete mode 100644 test/shared/fixtures.ts delete mode 100644 test/shared/format.ts delete mode 100644 test/shared/mockContract.ts rename test/shared/{utilities.ts => utilities.ts.old} (100%) diff --git a/.gitignore b/.gitignore index e69de29b..de5c2c73 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1,2 @@ +cache/ +foundry-out/ \ No newline at end of file diff --git a/contracts/test/TestERC20.sol b/contracts/test/TestERC20.sol deleted file mode 100644 index 4345a845..00000000 --- a/contracts/test/TestERC20.sol +++ /dev/null @@ -1,4 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity =0.8.19; - -import {TestERC20} from "@uniswap/core-next/contracts/test/TestERC20.sol"; diff --git a/remappings.txt b/remappings.txt new file mode 100644 index 00000000..b9e2c79f --- /dev/null +++ b/remappings.txt @@ -0,0 +1,3 @@ +@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/ +@uniswap/core-next/=lib/core-next/ +forge-std/=lib/forge-std/src/ diff --git a/test/GeomeanOracle.spec.ts b/test/GeomeanOracle.spec.ts.old similarity index 100% rename from test/GeomeanOracle.spec.ts rename to test/GeomeanOracle.spec.ts.old diff --git a/test/LimitOrderHook.t.sol b/test/LimitOrderHook.t.sol new file mode 100644 index 00000000..3dc2f3e7 --- /dev/null +++ b/test/LimitOrderHook.t.sol @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.19; + +import {Test} from "forge-std/Test.sol"; + +contract TestLimitOrderHook is Test { + function setUp() public { + MockHooks impl = new MockHooks(); + vm.etch(ALL_HOOKS_ADDRESS, address(impl).code); + mockHooks = MockHooks(ALL_HOOKS_ADDRESS); + (manager, key,) = Deployers.createFreshPool(mockHooks, 3000, SQRT_RATIO_1_1); + modifyPositionRouter = new PoolModifyPositionTest(IPoolManager(address(manager))); + swapRouter = new PoolSwapTest(IPoolManager(address(manager))); + donateRouter = new PoolDonateTest(IPoolManager(address(manager))); + } +} diff --git a/test/__snapshots__/LimitOrderHook.spec.ts.snap b/test/__snapshots__/LimitOrderHook.spec.ts.snap deleted file mode 100644 index 4f975cb4..00000000 --- a/test/__snapshots__/LimitOrderHook.spec.ts.snap +++ /dev/null @@ -1,17 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`LimitOrderHooks #afterSwap gas cost 1`] = ` -Object { - "calldataByteLength": 324, - "gasUsed": 444058, -} -`; - -exports[`LimitOrderHooks #kill gas cost 1`] = ` -Object { - "calldataByteLength": 260, - "gasUsed": 188109, -} -`; - -exports[`LimitOrderHooks bytecode size 1`] = `12536`; diff --git a/test/shared/checkObservationEquals.ts b/test/shared/checkObservationEquals.ts.old similarity index 100% rename from test/shared/checkObservationEquals.ts rename to test/shared/checkObservationEquals.ts.old diff --git a/test/shared/constants.ts b/test/shared/constants.ts.old similarity index 100% rename from test/shared/constants.ts rename to test/shared/constants.ts.old diff --git a/test/shared/evmHelpers.ts b/test/shared/evmHelpers.ts deleted file mode 100644 index cb73263e..00000000 --- a/test/shared/evmHelpers.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { ethers } from 'hardhat' - -export async function inOneBlock(timestamp: number, fn: () => void) { - await ethers.provider.send('evm_setAutomine', [false]) - await fn() - await ethers.provider.send('evm_setAutomine', [true]) - await ethers.provider.send('evm_mine', [timestamp]) -} - -export async function latestTimestamp(): Promise { - return (await ethers.provider.getBlock('latest')).timestamp -} - -export async function setNextBlocktime(time: number) { - await ethers.provider.send('evm_setNextBlockTimestamp', [time]) -} diff --git a/test/shared/expect.ts b/test/shared/expect.ts deleted file mode 100644 index ac8f19b2..00000000 --- a/test/shared/expect.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { expect, use } from 'chai' -import { solidity } from 'ethereum-waffle' -import { jestSnapshotPlugin } from 'mocha-chai-jest-snapshot' - -use(solidity) -use(jestSnapshotPlugin()) - -export { expect } diff --git a/test/shared/fixtures.ts b/test/shared/fixtures.ts deleted file mode 100644 index dfb9e668..00000000 --- a/test/shared/fixtures.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { BigNumber } from 'ethers' -import { ethers } from 'hardhat' -import { TestERC20 } from '../../typechain/TestERC20' - -interface TokensFixture { - token0: TestERC20 - token1: TestERC20 - token2: TestERC20 -} - -export async function tokensFixture(): Promise { - const tokenFactory = await ethers.getContractFactory('TestERC20') - const tokenA = (await tokenFactory.deploy(BigNumber.from(2).pow(255))) as TestERC20 - const tokenB = (await tokenFactory.deploy(BigNumber.from(2).pow(255))) as TestERC20 - const tokenC = (await tokenFactory.deploy(BigNumber.from(2).pow(255))) as TestERC20 - - const [token0, token1, token2] = [tokenA, tokenB, tokenC].sort((tokenA, tokenB) => - tokenA.address.toLowerCase() < tokenB.address.toLowerCase() ? -1 : 1 - ) - - return { token0, token1, token2 } -} diff --git a/test/shared/format.ts b/test/shared/format.ts deleted file mode 100644 index 8d23da5a..00000000 --- a/test/shared/format.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Decimal } from 'decimal.js' -import { BigNumberish } from 'ethers' - -export function formatTokenAmount(num: BigNumberish): string { - return new Decimal(num.toString()).dividedBy(new Decimal(10).pow(18)).toPrecision(5) -} - -export function formatPrice(price: BigNumberish): string { - return new Decimal(price.toString()).dividedBy(new Decimal(2).pow(96)).pow(2).toPrecision(5) -} diff --git a/test/shared/mockContract.ts b/test/shared/mockContract.ts deleted file mode 100644 index b365457a..00000000 --- a/test/shared/mockContract.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { FormatTypes, Interface } from 'ethers/lib/utils' -import hre, { ethers } from 'hardhat' -import { MockContract } from '../../typechain' - -export interface MockedContract { - address: string - called: (fn: string) => Promise - calledOnce: (fn: string) => Promise - calledWith: (fn: string, params: any[]) => Promise -} - -export const deployMockContract = async (contractInterface: Interface, address: string): Promise => { - await hre.network.provider.send('hardhat_setCode', [ - address, - (await hre.artifacts.readArtifact('MockContract')).deployedBytecode, - ]) - - const contractMock = (await ethers.getContractFactory('MockContract')).attach(address) as MockContract - - return { - address, - called: async (fn: string): Promise => { - return (await contractMock.timesCalled(contractInterface.getFunction(fn).format(FormatTypes.sighash))).gt(0) - }, - calledOnce: async (fn: string): Promise => { - return (await contractMock.timesCalled(contractInterface.getFunction(fn).format(FormatTypes.sighash))).eq(1) - }, - calledWith: async (fn: string, params: any[]): Promise => { - // Drop fn selector, keep 0x prefix so ethers interprets as byte string - const paramsBytes = '0x' + contractInterface.encodeFunctionData(fn, params).slice(10) - return contractMock.calledWith(contractInterface.getFunction(fn).format(FormatTypes.sighash), paramsBytes) - }, - } -} diff --git a/test/shared/utilities.ts b/test/shared/utilities.ts.old similarity index 100% rename from test/shared/utilities.ts rename to test/shared/utilities.ts.old