Skip to content

Commit 88758f9

Browse files
committed
feat: add e2e deployment tests for L2s
Signed-off-by: Tomás Migone <[email protected]>
1 parent d65dd1f commit 88758f9

File tree

9 files changed

+93
-27
lines changed

9 files changed

+93
-27
lines changed

e2e/deployment/config/controller.test.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { expect } from 'chai'
22
import hre, { ethers } from 'hardhat'
33
import { NamedAccounts } from '../../../gre/type-extensions'
4+
import GraphChain from '../../../gre/helpers/network'
45

56
describe('Controller configuration', () => {
6-
const { contracts, getNamedAccounts } = hre.graph()
7-
const { Controller } = contracts
7+
const graph = hre.graph()
8+
const { Controller } = graph.contracts
89

9-
const proxyContracts = [
10+
const l1ProxyContracts = [
1011
'Curation',
1112
'GNS',
1213
'DisputeManager',
@@ -17,10 +18,21 @@ describe('Controller configuration', () => {
1718
'L1GraphTokenGateway',
1819
]
1920

21+
const l2ProxyContracts = [
22+
'Curation',
23+
'GNS',
24+
'DisputeManager',
25+
'EpochManager',
26+
'RewardsManager',
27+
'Staking',
28+
'L2GraphToken',
29+
'L2GraphTokenGateway',
30+
]
31+
2032
let namedAccounts: NamedAccounts
2133

2234
before(async () => {
23-
namedAccounts = await getNamedAccounts()
35+
namedAccounts = await graph.getNamedAccounts()
2436
})
2537

2638
const proxyShouldMatchDeployed = async (contractName: string) => {
@@ -30,7 +42,7 @@ describe('Controller configuration', () => {
3042
const address = await Controller.getContractProxy(
3143
ethers.utils.solidityKeccak256(['string'], [name]),
3244
)
33-
expect(address).eq(contracts[contractName].address)
45+
expect(address).eq(graph.contracts[contractName].address)
3446
}
3547

3648
it('should be owned by governor', async function () {
@@ -44,6 +56,7 @@ describe('Controller configuration', () => {
4456
})
4557

4658
describe('proxy contract', async function () {
59+
const proxyContracts = GraphChain.isL1(graph.chainId) ? l1ProxyContracts : l2ProxyContracts
4760
for (const contract of proxyContracts) {
4861
it(`${contract} should match deployed`, async function () {
4962
await proxyShouldMatchDeployed(contract)

e2e/deployment/config/graphToken.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe('GraphToken configuration', () => {
2323
it('deployer should not be minter', async function () {
2424
const deployer = await getDeployer()
2525
const deployerIsMinter = await GraphToken.isMinter(deployer.address)
26-
hre.network.config.chainId === 1337 ? this.skip() : expect(deployerIsMinter).eq(false)
26+
expect(deployerIsMinter).eq(false)
2727
})
2828

2929
it('RewardsManager should be minter', async function () {

e2e/deployment/config/l1/bridgeEscrow.test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import { expect } from 'chai'
22
import hre from 'hardhat'
3+
import GraphChain from '../../../../gre/helpers/network'
34

4-
describe('BridgeEscrow configuration', () => {
5-
const {
6-
contracts: { Controller, BridgeEscrow },
7-
} = hre.graph()
5+
describe('[L1] BridgeEscrow configuration', function () {
6+
const graph = hre.graph()
7+
const { Controller, BridgeEscrow } = graph.contracts
8+
9+
before(async function () {
10+
if (GraphChain.isL2(graph.chainId)) this.skip()
11+
})
812

913
it('should be controlled by Controller', async function () {
1014
const controller = await BridgeEscrow.controller()

e2e/deployment/config/l1/l1GraphTokenGateway.test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import { expect } from 'chai'
22
import hre from 'hardhat'
3+
import GraphChain from '../../../../gre/helpers/network'
34

4-
describe('L1GraphTokenGateway configuration', () => {
5-
const {
6-
contracts: { Controller, L1GraphTokenGateway },
7-
} = hre.graph()
5+
describe('[L1] L1GraphTokenGateway configuration', function () {
6+
const graph = hre.graph()
7+
const { Controller, L1GraphTokenGateway } = graph.contracts
8+
9+
before(async function () {
10+
if (GraphChain.isL2(graph.chainId)) this.skip()
11+
})
812

913
it('should be controlled by Controller', async function () {
1014
const controller = await L1GraphTokenGateway.controller()
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { expect } from 'chai'
2+
import hre from 'hardhat'
3+
import GraphChain from '../../../../gre/helpers/network'
4+
5+
describe('[L2] L2GraphTokenGateway configuration', function () {
6+
const graph = hre.graph()
7+
const { Controller, L2GraphTokenGateway } = graph.contracts
8+
9+
before(async function () {
10+
if (GraphChain.isL1(graph.chainId)) this.skip()
11+
})
12+
13+
it('should be controlled by Controller', async function () {
14+
const controller = await L2GraphTokenGateway.controller()
15+
expect(controller).eq(Controller.address)
16+
})
17+
})
Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
import { expect } from 'chai'
22
import hre from 'hardhat'
33
import { getItemValue } from '../../../../cli/config'
4+
import GraphChain from '../../../../gre/helpers/network'
45

5-
describe('GraphToken initialization', () => {
6-
const {
7-
graphConfig,
8-
contracts: { GraphToken },
9-
} = hre.graph()
6+
describe('[L1] GraphToken initialization', () => {
7+
const graph = hre.graph()
8+
const { GraphToken } = graph.contracts
9+
10+
before(async function () {
11+
if (GraphChain.isL2(graph.chainId)) this.skip()
12+
})
1013

1114
it('total supply should match "initialSupply" on the config file', async function () {
1215
const value = await GraphToken.totalSupply()
13-
const expected = getItemValue(graphConfig, 'contracts/GraphToken/init/initialSupply')
14-
hre.network.config.chainId === 1337 ? expect(value).eq(expected) : expect(value).gte(expected)
16+
const expected = getItemValue(graph.graphConfig, 'contracts/GraphToken/init/initialSupply')
17+
expect(value).eq(expected)
1518
})
1619
})
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { expect } from 'chai'
2+
import hre from 'hardhat'
3+
import GraphChain from '../../../../gre/helpers/network'
4+
5+
describe('[L2] GraphToken initialization', () => {
6+
const graph = hre.graph()
7+
const { GraphToken } = graph.contracts
8+
9+
before(async function () {
10+
if (GraphChain.isL1(graph.chainId)) this.skip()
11+
})
12+
13+
it('total supply should be zero', async function () {
14+
const value = await GraphToken.totalSupply()
15+
expect(value).eq(0)
16+
})
17+
})

hardhat.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,12 @@ const config: HardhatUserConfig = {
153153
process.env.FORK === 'true' ? getAccountsKeys() : { mnemonic: DEFAULT_TEST_MNEMONIC },
154154
},
155155
localnitrol1: {
156+
chainId: 1337,
156157
url: 'http://localhost:8545',
157158
accounts: { mnemonic: DEFAULT_TEST_MNEMONIC },
158159
},
159160
localnitrol2: {
161+
chainId: 412346,
160162
url: 'http://localhost:8547',
161163
accounts: { mnemonic: DEFAULT_TEST_MNEMONIC },
162164
},

tasks/deployment/ownership.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
import { ContractTransaction } from 'ethers'
22
import { task } from 'hardhat/config'
33
import { cliOpts } from '../../cli/defaults'
4+
import GraphChain from '../../gre/helpers/network'
45

56
task('migrate:ownership', 'Accepts ownership of protocol contracts on behalf of governor')
67
.addOptionalParam('addressBook', cliOpts.addressBook.description)
78
.addOptionalParam('graphConfig', cliOpts.graphConfig.description)
89
.setAction(async (taskArgs, hre) => {
9-
const { contracts, getNamedAccounts } = hre.graph(taskArgs)
10-
const { governor } = await getNamedAccounts()
10+
const graph = hre.graph(taskArgs)
11+
const { GraphToken, Controller, GraphProxyAdmin, SubgraphNFT } = graph.contracts
12+
const { governor } = await graph.getNamedAccounts()
1113

1214
console.log('> Accepting ownership of contracts')
1315
console.log(`- Governor: ${governor.address}`)
1416

1517
const txs: ContractTransaction[] = []
16-
txs.push(await contracts.GraphToken.connect(governor).acceptOwnership())
17-
txs.push(await contracts.Controller.connect(governor).acceptOwnership())
18-
txs.push(await contracts.GraphProxyAdmin.connect(governor).acceptOwnership())
19-
txs.push(await contracts.SubgraphNFT.connect(governor).acceptOwnership())
18+
txs.push(await GraphToken.connect(governor).acceptOwnership())
19+
txs.push(await Controller.connect(governor).acceptOwnership())
20+
txs.push(await GraphProxyAdmin.connect(governor).acceptOwnership())
21+
txs.push(await SubgraphNFT.connect(governor).acceptOwnership())
22+
23+
if (GraphChain.isL1(graph.chainId)) {
24+
txs.push(await GraphToken.connect(governor).acceptOwnership())
25+
}
2026

2127
await Promise.all(txs.map((tx) => tx.wait()))
2228
console.log('Done!')

0 commit comments

Comments
 (0)