Commit e8ea9654 authored by smartcontracts's avatar smartcontracts Committed by GitHub

Merge pull request #2022 from PatriceVignola/use-hardhat-ethers

test: use hardhat-ethers for importing factories in integration tests
parents 42ae2a6b 968fb38d
---
'@eth-optimism/integration-tests': patch
---
Use hardhat-ethers for importing factories in integration tests
import { utils, Wallet, Contract, ContractFactory } from 'ethers' import { utils, Wallet, Contract } from 'ethers'
import { ethers } from 'hardhat'
import { actor, setupActor, run, setupRun } from './lib/convenience' import { actor, setupActor, run, setupRun } from './lib/convenience'
import { OptimismEnv } from '../test/shared/env' import { OptimismEnv } from '../test/shared/env'
import StateDOS from '../artifacts/contracts/StateDOS.sol/StateDOS.json'
import { expect } from 'chai' import { expect } from 'chai'
interface Context { interface Context {
...@@ -16,11 +16,7 @@ actor('Trie DoS accounts', () => { ...@@ -16,11 +16,7 @@ actor('Trie DoS accounts', () => {
setupActor(async () => { setupActor(async () => {
env = await OptimismEnv.new() env = await OptimismEnv.new()
const factory = new ContractFactory( const factory = await ethers.getContractFactory('StateDOS', env.l2Wallet)
StateDOS.abi,
StateDOS.bytecode,
env.l2Wallet
)
contract = await factory.deploy() contract = await factory.deploy()
await contract.deployed() await contract.deployed()
}) })
......
...@@ -2,11 +2,10 @@ import { expect } from './shared/setup' ...@@ -2,11 +2,10 @@ import { expect } from './shared/setup'
/* Imports: External */ /* Imports: External */
import { Contract, ContractFactory } from 'ethers' import { Contract, ContractFactory } from 'ethers'
import { ethers } from 'hardhat'
import { applyL1ToL2Alias, awaitCondition } from '@eth-optimism/core-utils' import { applyL1ToL2Alias, awaitCondition } from '@eth-optimism/core-utils'
/* Imports: Internal */ /* 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 { Direction } from './shared/watcher-utils'
import { OptimismEnv } from './shared/env' import { OptimismEnv } from './shared/env'
import { isMainnet } from './shared/utils' import { isMainnet } from './shared/utils'
...@@ -22,19 +21,16 @@ describe('Basic L1<>L2 Communication', async () => { ...@@ -22,19 +21,16 @@ describe('Basic L1<>L2 Communication', async () => {
before(async () => { before(async () => {
env = await OptimismEnv.new() env = await OptimismEnv.new()
Factory__L1SimpleStorage = new ContractFactory( Factory__L1SimpleStorage = await ethers.getContractFactory(
simpleStorageJson.abi, 'SimpleStorage',
simpleStorageJson.bytecode,
env.l1Wallet env.l1Wallet
) )
Factory__L2SimpleStorage = new ContractFactory( Factory__L2SimpleStorage = await ethers.getContractFactory(
simpleStorageJson.abi, 'SimpleStorage',
simpleStorageJson.bytecode,
env.l2Wallet env.l2Wallet
) )
Factory__L2Reverter = new ContractFactory( Factory__L2Reverter = await ethers.getContractFactory(
l2ReverterJson.abi, 'Reverter',
l2ReverterJson.bytecode,
env.l2Wallet env.l2Wallet
) )
}) })
......
...@@ -18,7 +18,6 @@ import { ...@@ -18,7 +18,6 @@ import {
TransactionReceipt, TransactionReceipt,
TransactionRequest, TransactionRequest,
} from '@ethersproject/providers' } from '@ethersproject/providers'
import simpleStorageJson from '../artifacts/contracts/SimpleStorage.sol/SimpleStorage.json'
describe('Basic RPC tests', () => { describe('Basic RPC tests', () => {
let env: OptimismEnv let env: OptimismEnv
...@@ -491,9 +490,8 @@ describe('Basic RPC tests', () => { ...@@ -491,9 +490,8 @@ describe('Basic RPC tests', () => {
describe('debug_traceTransaction', () => { describe('debug_traceTransaction', () => {
it('should match debug_traceBlock', async () => { it('should match debug_traceBlock', async () => {
const storage = new ContractFactory( const storage = await ethers.getContractFactory(
simpleStorageJson.abi, 'SimpleStorage',
simpleStorageJson.bytecode,
env.l2Wallet env.l2Wallet
) )
const tx = (await storage.deploy()).deployTransaction const tx = (await storage.deploy()).deployTransaction
......
import { expect } from './shared/setup' import { expect } from './shared/setup'
/* Imports: External */ /* Imports: External */
import { Contract, ContractFactory, Wallet, utils } from 'ethers' import { Contract, Wallet, utils } from 'ethers'
import { ethers } from 'hardhat'
/* Imports: Internal */ /* Imports: Internal */
import { OptimismEnv } from './shared/env' import { OptimismEnv } from './shared/env'
...@@ -16,7 +17,6 @@ import { ...@@ -16,7 +17,6 @@ import {
} from './shared/stress-test-helpers' } from './shared/stress-test-helpers'
/* Imports: Artifacts */ /* Imports: Artifacts */
import simpleStorageJson from '../artifacts/contracts/SimpleStorage.sol/SimpleStorage.json'
import { fundUser, isLiveNetwork, isMainnet } from './shared/utils' import { fundUser, isLiveNetwork, isMainnet } from './shared/utils'
// Need a big timeout to allow for all transactions to be processed. // Need a big timeout to allow for all transactions to be processed.
...@@ -60,14 +60,12 @@ describe('stress tests', () => { ...@@ -60,14 +60,12 @@ describe('stress tests', () => {
let L2SimpleStorage: Contract let L2SimpleStorage: Contract
let L1SimpleStorage: Contract let L1SimpleStorage: Contract
beforeEach(async () => { beforeEach(async () => {
const factory__L1SimpleStorage = new ContractFactory( const factory__L1SimpleStorage = await ethers.getContractFactory(
simpleStorageJson.abi, 'SimpleStorage',
simpleStorageJson.bytecode,
env.l1Wallet env.l1Wallet
) )
const factory__L2SimpleStorage = new ContractFactory( const factory__L2SimpleStorage = await ethers.getContractFactory(
simpleStorageJson.abi, 'SimpleStorage',
simpleStorageJson.bytecode,
env.l2Wallet env.l2Wallet
) )
L1SimpleStorage = await factory__L1SimpleStorage.deploy() L1SimpleStorage = await factory__L1SimpleStorage.deploy()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment