Skip to content

Commit 968fb38

Browse files
test: use hardhat-ethers for importing factories in integration tests
1 parent 3174f03 commit 968fb38

5 files changed

Lines changed: 23 additions & 30 deletions

File tree

.changeset/spicy-kiwis-double.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@eth-optimism/integration-tests': patch
3+
---
4+
5+
Use hardhat-ethers for importing factories in integration tests

integration-tests/actor-tests/state-dos.test.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { utils, Wallet, Contract, ContractFactory } from 'ethers'
1+
import { utils, Wallet, Contract } from 'ethers'
2+
import { ethers } from 'hardhat'
23
import { actor, setupActor, run, setupRun } from './lib/convenience'
34
import { OptimismEnv } from '../test/shared/env'
4-
import StateDOS from '../artifacts/contracts/StateDOS.sol/StateDOS.json'
55
import { expect } from 'chai'
66

77
interface Context {
@@ -16,11 +16,7 @@ actor('Trie DoS accounts', () => {
1616
setupActor(async () => {
1717
env = await OptimismEnv.new()
1818

19-
const factory = new ContractFactory(
20-
StateDOS.abi,
21-
StateDOS.bytecode,
22-
env.l2Wallet
23-
)
19+
const factory = await ethers.getContractFactory('StateDOS', env.l2Wallet)
2420
contract = await factory.deploy()
2521
await contract.deployed()
2622
})

integration-tests/test/basic-l1-l2-communication.spec.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ import { expect } from './shared/setup'
22

33
/* Imports: External */
44
import { Contract, ContractFactory } from 'ethers'
5+
import { ethers } from 'hardhat'
56
import { applyL1ToL2Alias, awaitCondition } from '@eth-optimism/core-utils'
67

78
/* Imports: Internal */
8-
import simpleStorageJson from '../artifacts/contracts/SimpleStorage.sol/SimpleStorage.json'
9-
import l2ReverterJson from '../artifacts/contracts/Reverter.sol/Reverter.json'
109
import { Direction } from './shared/watcher-utils'
1110
import { OptimismEnv } from './shared/env'
1211
import { isMainnet } from './shared/utils'
@@ -22,19 +21,16 @@ describe('Basic L1<>L2 Communication', async () => {
2221

2322
before(async () => {
2423
env = await OptimismEnv.new()
25-
Factory__L1SimpleStorage = new ContractFactory(
26-
simpleStorageJson.abi,
27-
simpleStorageJson.bytecode,
24+
Factory__L1SimpleStorage = await ethers.getContractFactory(
25+
'SimpleStorage',
2826
env.l1Wallet
2927
)
30-
Factory__L2SimpleStorage = new ContractFactory(
31-
simpleStorageJson.abi,
32-
simpleStorageJson.bytecode,
28+
Factory__L2SimpleStorage = await ethers.getContractFactory(
29+
'SimpleStorage',
3330
env.l2Wallet
3431
)
35-
Factory__L2Reverter = new ContractFactory(
36-
l2ReverterJson.abi,
37-
l2ReverterJson.bytecode,
32+
Factory__L2Reverter = await ethers.getContractFactory(
33+
'Reverter',
3834
env.l2Wallet
3935
)
4036
})

integration-tests/test/rpc.spec.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
TransactionReceipt,
1919
TransactionRequest,
2020
} from '@ethersproject/providers'
21-
import simpleStorageJson from '../artifacts/contracts/SimpleStorage.sol/SimpleStorage.json'
2221

2322
describe('Basic RPC tests', () => {
2423
let env: OptimismEnv
@@ -491,9 +490,8 @@ describe('Basic RPC tests', () => {
491490

492491
describe('debug_traceTransaction', () => {
493492
it('should match debug_traceBlock', async () => {
494-
const storage = new ContractFactory(
495-
simpleStorageJson.abi,
496-
simpleStorageJson.bytecode,
493+
const storage = await ethers.getContractFactory(
494+
'SimpleStorage',
497495
env.l2Wallet
498496
)
499497
const tx = (await storage.deploy()).deployTransaction

integration-tests/test/stress-tests.spec.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { expect } from './shared/setup'
22

33
/* Imports: External */
4-
import { Contract, ContractFactory, Wallet, utils } from 'ethers'
4+
import { Contract, Wallet, utils } from 'ethers'
5+
import { ethers } from 'hardhat'
56

67
/* Imports: Internal */
78
import { OptimismEnv } from './shared/env'
@@ -16,7 +17,6 @@ import {
1617
} from './shared/stress-test-helpers'
1718

1819
/* Imports: Artifacts */
19-
import simpleStorageJson from '../artifacts/contracts/SimpleStorage.sol/SimpleStorage.json'
2020
import { fundUser, isLiveNetwork, isMainnet } from './shared/utils'
2121

2222
// Need a big timeout to allow for all transactions to be processed.
@@ -60,14 +60,12 @@ describe('stress tests', () => {
6060
let L2SimpleStorage: Contract
6161
let L1SimpleStorage: Contract
6262
beforeEach(async () => {
63-
const factory__L1SimpleStorage = new ContractFactory(
64-
simpleStorageJson.abi,
65-
simpleStorageJson.bytecode,
63+
const factory__L1SimpleStorage = await ethers.getContractFactory(
64+
'SimpleStorage',
6665
env.l1Wallet
6766
)
68-
const factory__L2SimpleStorage = new ContractFactory(
69-
simpleStorageJson.abi,
70-
simpleStorageJson.bytecode,
67+
const factory__L2SimpleStorage = await ethers.getContractFactory(
68+
'SimpleStorage',
7169
env.l2Wallet
7270
)
7371
L1SimpleStorage = await factory__L1SimpleStorage.deploy()

0 commit comments

Comments
 (0)