From f43ee05c16a273b760f34c3a225ba676c786a37e Mon Sep 17 00:00:00 2001 From: Mark Barrasso <4982406+barrasso@users.noreply.github.com> Date: Thu, 9 Dec 2021 16:11:53 -0500 Subject: [PATCH] Create a setup script for the integration tests --- .../test/basic-l1-l2-communication.spec.ts | 2 +- integration-tests/test/bridged-tokens.ts | 3 ++- integration-tests/test/contracts.spec.ts | 6 ++---- integration-tests/test/fee-payment.spec.ts | 4 +--- integration-tests/test/native-eth-ovm-calls.spec.ts | 6 ++---- integration-tests/test/native-eth.spec.ts | 2 +- integration-tests/test/ovmcontext.spec.ts | 2 +- integration-tests/test/predeploys.spec.ts | 4 +--- integration-tests/test/queue-ingestion.spec.ts | 2 +- integration-tests/test/replica.spec.ts | 2 +- integration-tests/test/rpc.spec.ts | 8 ++------ integration-tests/test/shared/setup.ts | 10 ++++++++++ integration-tests/test/stress-tests.spec.ts | 2 +- integration-tests/test/whitelist.spec.ts | 6 ++---- 14 files changed, 28 insertions(+), 31 deletions(-) create mode 100644 integration-tests/test/shared/setup.ts diff --git a/integration-tests/test/basic-l1-l2-communication.spec.ts b/integration-tests/test/basic-l1-l2-communication.spec.ts index 25adb249e04b9..2f84b823809e7 100644 --- a/integration-tests/test/basic-l1-l2-communication.spec.ts +++ b/integration-tests/test/basic-l1-l2-communication.spec.ts @@ -1,4 +1,4 @@ -import { expect } from 'chai' +import { expect } from './shared/setup' /* Imports: External */ import { Contract, ContractFactory } from 'ethers' diff --git a/integration-tests/test/bridged-tokens.ts b/integration-tests/test/bridged-tokens.ts index 5b466f659e54b..f992f2aad7769 100644 --- a/integration-tests/test/bridged-tokens.ts +++ b/integration-tests/test/bridged-tokens.ts @@ -1,7 +1,8 @@ +import { expect } from './shared/setup' + import { BigNumber, Contract, ContractFactory, utils, Wallet } from 'ethers' import { ethers } from 'hardhat' import * as L2Artifact from '@eth-optimism/contracts/artifacts/contracts/standards/L2StandardERC20.sol/L2StandardERC20.json' -import { expect } from 'chai' import { OptimismEnv } from './shared/env' import { isLiveNetwork, isMainnet } from './shared/utils' diff --git a/integration-tests/test/contracts.spec.ts b/integration-tests/test/contracts.spec.ts index c5103ebdd0405..521a705be7699 100644 --- a/integration-tests/test/contracts.spec.ts +++ b/integration-tests/test/contracts.spec.ts @@ -1,7 +1,7 @@ +import { expect } from './shared/setup' + import { BigNumber, Contract, ContractFactory, utils, Wallet } from 'ethers' import { ethers } from 'hardhat' -import { solidity } from 'ethereum-waffle' -import chai, { expect } from 'chai' import { UniswapV3Deployer } from 'uniswap-v3-deploy-plugin/dist/deployer/UniswapV3Deployer' import { OptimismEnv } from './shared/env' @@ -10,8 +10,6 @@ import { FeeAmount, TICK_SPACINGS } from '@uniswap/v3-sdk' import { abi as NFTABI } from '@uniswap/v3-periphery/artifacts/contracts/NonfungiblePositionManager.sol/NonfungiblePositionManager.json' import { abi as RouterABI } from '@uniswap/v3-periphery/artifacts/contracts/SwapRouter.sol/SwapRouter.json' -chai.use(solidity) - // Below methods taken from the Uniswap test suite, see // https://github.com/Uniswap/v3-periphery/blob/main/test/shared/ticks.ts const getMinTick = (tickSpacing: number) => diff --git a/integration-tests/test/fee-payment.spec.ts b/integration-tests/test/fee-payment.spec.ts index b284eeda1a7f5..2dec3d69f51dc 100644 --- a/integration-tests/test/fee-payment.spec.ts +++ b/integration-tests/test/fee-payment.spec.ts @@ -1,6 +1,4 @@ -import chai, { expect } from 'chai' -import chaiAsPromised from 'chai-as-promised' -chai.use(chaiAsPromised) +import { expect } from './shared/setup' /* Imports: External */ import { BigNumber, utils } from 'ethers' diff --git a/integration-tests/test/native-eth-ovm-calls.spec.ts b/integration-tests/test/native-eth-ovm-calls.spec.ts index fd20c51214118..ae6261435baa8 100644 --- a/integration-tests/test/native-eth-ovm-calls.spec.ts +++ b/integration-tests/test/native-eth-ovm-calls.spec.ts @@ -1,15 +1,13 @@ +import { expect } from './shared/setup' + import { BigNumber, Contract, ContractFactory, Wallet } from 'ethers' import { ethers } from 'hardhat' -import chai, { expect } from 'chai' import { fundUser, encodeSolidityRevertMessage, gasPriceForL2, } from './shared/utils' import { OptimismEnv } from './shared/env' -import { solidity } from 'ethereum-waffle' - -chai.use(solidity) describe('Native ETH value integration tests', () => { let env: OptimismEnv diff --git a/integration-tests/test/native-eth.spec.ts b/integration-tests/test/native-eth.spec.ts index 2099d7eee960f..7df06492064a5 100644 --- a/integration-tests/test/native-eth.spec.ts +++ b/integration-tests/test/native-eth.spec.ts @@ -1,4 +1,4 @@ -import { expect } from 'chai' +import { expect } from './shared/setup' /* Imports: External */ import { Wallet, utils, BigNumber } from 'ethers' diff --git a/integration-tests/test/ovmcontext.spec.ts b/integration-tests/test/ovmcontext.spec.ts index 98cba0e2b90e6..30c620e99aaa3 100644 --- a/integration-tests/test/ovmcontext.spec.ts +++ b/integration-tests/test/ovmcontext.spec.ts @@ -1,4 +1,4 @@ -import { expect } from 'chai' +import { expect } from './shared/setup' /* Imports: External */ import { ethers } from 'hardhat' diff --git a/integration-tests/test/predeploys.spec.ts b/integration-tests/test/predeploys.spec.ts index a4710e3234756..57131585dc6b3 100644 --- a/integration-tests/test/predeploys.spec.ts +++ b/integration-tests/test/predeploys.spec.ts @@ -1,6 +1,4 @@ -import chai, { expect } from 'chai' -import { solidity } from 'ethereum-waffle' -chai.use(solidity) +import { expect } from './shared/setup' /* Imports: Internal */ import { ethers } from 'ethers' diff --git a/integration-tests/test/queue-ingestion.spec.ts b/integration-tests/test/queue-ingestion.spec.ts index 28ddec60ba860..c79de341600c2 100644 --- a/integration-tests/test/queue-ingestion.spec.ts +++ b/integration-tests/test/queue-ingestion.spec.ts @@ -1,4 +1,4 @@ -import { expect } from 'chai' +import { expect } from './shared/setup' /* Imports: Internal */ import { providers } from 'ethers' diff --git a/integration-tests/test/replica.spec.ts b/integration-tests/test/replica.spec.ts index b4ea35b8b4a0f..165461d90fe8c 100644 --- a/integration-tests/test/replica.spec.ts +++ b/integration-tests/test/replica.spec.ts @@ -1,3 +1,4 @@ +import { expect } from './shared/setup' import { OptimismEnv } from './shared/env' import { defaultTransactionFactory, @@ -5,7 +6,6 @@ import { sleep, isLiveNetwork, } from './shared/utils' -import { expect } from 'chai' import { TransactionReceipt } from '@ethersproject/abstract-provider' describe('Replica Tests', () => { diff --git a/integration-tests/test/rpc.spec.ts b/integration-tests/test/rpc.spec.ts index 19936a2c7d296..0cd4a99af292a 100644 --- a/integration-tests/test/rpc.spec.ts +++ b/integration-tests/test/rpc.spec.ts @@ -1,8 +1,9 @@ +import { expect } from './shared/setup' + import { expectApprox, injectL2Context } from '@eth-optimism/core-utils' import { Wallet, BigNumber, Contract, ContractFactory } from 'ethers' import { serialize } from '@ethersproject/transactions' import { ethers } from 'hardhat' -import chai, { expect } from 'chai' import { sleep, l2Provider, @@ -12,18 +13,13 @@ import { isLiveNetwork, gasPriceForL2, } from './shared/utils' -import chaiAsPromised from 'chai-as-promised' import { OptimismEnv } from './shared/env' import { TransactionReceipt, TransactionRequest, } from '@ethersproject/providers' -import { solidity } from 'ethereum-waffle' import simpleStorageJson from '../artifacts/contracts/SimpleStorage.sol/SimpleStorage.json' -chai.use(chaiAsPromised) -chai.use(solidity) - describe('Basic RPC tests', () => { let env: OptimismEnv let wallet: Wallet diff --git a/integration-tests/test/shared/setup.ts b/integration-tests/test/shared/setup.ts new file mode 100644 index 0000000000000..af83838b25967 --- /dev/null +++ b/integration-tests/test/shared/setup.ts @@ -0,0 +1,10 @@ +/* External Imports */ +import chai = require('chai') +import chaiAsPromised from 'chai-as-promised' +import { solidity } from 'ethereum-waffle' + +chai.use(solidity) +chai.use(chaiAsPromised) +const expect = chai.expect + +export { expect } diff --git a/integration-tests/test/stress-tests.spec.ts b/integration-tests/test/stress-tests.spec.ts index 56dc669c6317c..c7c032ab41010 100644 --- a/integration-tests/test/stress-tests.spec.ts +++ b/integration-tests/test/stress-tests.spec.ts @@ -1,4 +1,4 @@ -import { expect } from 'chai' +import { expect } from './shared/setup' /* Imports: External */ import { Contract, ContractFactory, Wallet, utils } from 'ethers' diff --git a/integration-tests/test/whitelist.spec.ts b/integration-tests/test/whitelist.spec.ts index dda34cf77f0b2..0e64d661d3371 100644 --- a/integration-tests/test/whitelist.spec.ts +++ b/integration-tests/test/whitelist.spec.ts @@ -1,16 +1,14 @@ +import { expect } from './shared/setup' + /* Imports: External */ import { ContractFactory } from 'ethers' import { ethers } from 'hardhat' -import chai, { expect } from 'chai' -import { solidity } from 'ethereum-waffle' import { predeploys } from '@eth-optimism/contracts' /* Imports: Internal */ import { OptimismEnv } from './shared/env' import { l2Provider } from './shared/utils' -chai.use(solidity) - describe('Whitelist', async () => { const initialAmount = 1000 const tokenName = 'OVM Test'