Skip to content

Separate internal and external imports within integration tests #2017

@smartcontracts

Description

@smartcontracts

Is your feature request related to a problem? Please describe.
I have a habit of separating internal and external imports inside of TypeScript files. This makes it very easy to see which utilities are being pulled in from external dependencies. Our goal should be to eventually replace many of our external dependencies with simple functions of our own (for security reasons), so it's ideal to be able to quickly see when there are unnecessary external imports. Some of our integration tests currently have this, but others do not. It should be easy to standardize the remaining files around this pattern.

Describe the solution you'd like
Standardize all of the TypeScript files within integration-tests/tests around the pattern described above. Here's an example of how to organize the imports:

import { expect } from './shared/setup'
/* Imports: External */
import { Contract, ContractFactory } from 'ethers'
import { applyL1ToL2Alias, awaitCondition } from '@eth-optimism/core-utils'
/* Imports: Internal */
import simpleStorageJson from '../artifacts/contracts/SimpleStorage.sol/SimpleStorage.json'
import l2ReverterJson from '../artifacts/contracts/Reverter.sol/Reverter.json'
import { Direction } from './shared/watcher-utils'
import { OptimismEnv } from './shared/env'
import { isMainnet } from './shared/utils'

Note the /* Imports: External */ and /* Imports: Internal */ comments that define the two sections. External imports first, then internal imports. Also note that import { expect } from './shared/setup' should always be at the top of the file. See here for an example of a file where the imports need to be cleaned up:

import { expect } from './shared/setup'
import { BigNumber, Contract, ContractFactory, Wallet } from 'ethers'
import { ethers } from 'hardhat'
import {
fundUser,
encodeSolidityRevertMessage,
gasPriceForL2,
} from './shared/utils'
import { OptimismEnv } from './shared/env'

This should be:

import { expect } from './shared/setup' 

/* Imports: External */
import { BigNumber, Contract, ContractFactory, Wallet } from 'ethers' 
import { ethers } from 'hardhat' 

/* Imports: Internal */
import { 
  fundUser, 
  encodeSolidityRevertMessage, 
  gasPriceForL2, 
} from './shared/utils' 
import { OptimismEnv } from './shared/env' 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions