Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion e2e/deployment/config/controller.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { expect } from 'chai'
import hre, { ethers } from 'hardhat'
import { chainIdIsL2 } from '../../../cli/utils'
import { NamedAccounts } from '../../../tasks/type-extensions'

describe('Controller configuration', () => {
const { contracts, getNamedAccounts } = hre.graph()
const { Controller } = contracts

const proxyContracts = [
const proxyContractsL1 = [
'Curation',
'GNS',
'DisputeManager',
Expand All @@ -18,12 +19,29 @@ describe('Controller configuration', () => {
'L1Reservoir',
]

const proxyContractsL2 = [
'Curation',
'GNS',
'DisputeManager',
'EpochManager',
'RewardsManager',
'Staking',
'L2GraphToken',
'L2GraphTokenGateway',
'L2Reservoir',
]

let namedAccounts: NamedAccounts

before(async () => {
namedAccounts = await getNamedAccounts()
})

it('protocol should be unpaused', async function () {
const paused = await contracts.Controller.paused()
expect(paused).eq(false)
})

const proxyShouldMatchDeployed = async (contractName: string) => {
// remove L1/L2 prefix, contracts are not registered as L1/L2 on controller
const name = contractName.replace(/(^L1|L2)/gi, '')
Expand All @@ -45,6 +63,8 @@ describe('Controller configuration', () => {
})

describe('proxy contract', async function () {
const chainId = (await hre.ethers.provider.getNetwork()).chainId
const proxyContracts = chainIdIsL2(chainId) ? proxyContractsL2 : proxyContractsL1
for (const contract of proxyContracts) {
it(`${contract} should match deployed`, async function () {
await proxyShouldMatchDeployed(contract)
Expand Down
2 changes: 1 addition & 1 deletion e2e/deployment/config/graphToken.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('GraphToken configuration', () => {
it('deployer should not be minter', async function () {
const deployer = await getDeployer()
const deployerIsMinter = await GraphToken.isMinter(deployer.address)
hre.network.config.chainId === 1337 ? this.skip() : expect(deployerIsMinter).eq(false)
expect(deployerIsMinter).eq(false)
})

it('RewardsManager should not be a minter', async function () {
Expand Down
8 changes: 7 additions & 1 deletion e2e/deployment/config/l1/bridgeEscrow.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import { expect } from 'chai'
import hre from 'hardhat'
import { chainIdIsL2 } from '../../../../cli/utils'

describe('BridgeEscrow configuration', () => {
describe('[L1] BridgeEscrow configuration', () => {
const {
contracts: { Controller, BridgeEscrow },
} = hre.graph()

before(async function () {
const chainId = (await hre.ethers.provider.getNetwork()).chainId
if (chainIdIsL2(chainId)) this.skip()
})

it('should be controlled by Controller', async function () {
const controller = await BridgeEscrow.controller()
expect(controller).eq(Controller.address)
Expand Down
8 changes: 7 additions & 1 deletion e2e/deployment/config/l1/graphToken.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import { expect } from 'chai'
import hre from 'hardhat'
import { chainIdIsL2 } from '../../../../cli/utils'

describe('GraphToken configuration', () => {
describe('[L1] GraphToken configuration', () => {
const {
contracts: { GraphToken, L1Reservoir },
} = hre.graph()

before(async function () {
const chainId = (await hre.ethers.provider.getNetwork()).chainId
if (chainIdIsL2(chainId)) this.skip()
})

it('L1Reservoir should be a minter', async function () {
const deployerIsMinter = await GraphToken.isMinter(L1Reservoir.address)
expect(deployerIsMinter).eq(true)
Expand Down
77 changes: 76 additions & 1 deletion e2e/deployment/config/l1/l1GraphTokenGateway.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,88 @@
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'
import { expect } from 'chai'
import hre from 'hardhat'
import { chainIdIsL2 } from '../../../../cli/utils'

describe('L1GraphTokenGateway configuration', () => {
describe('[L1] L1GraphTokenGateway configuration', () => {
const {
contracts: { Controller, L1GraphTokenGateway },
getTestAccounts,
} = hre.graph()

let unauthorized: SignerWithAddress

before(async function () {
const chainId = (await hre.ethers.provider.getNetwork()).chainId
if (chainIdIsL2(chainId)) this.skip()

unauthorized = (await getTestAccounts())[0]
})

it('bridge should be unpaused', async function () {
const paused = await L1GraphTokenGateway.paused()
expect(paused).eq(false)
})

it('should be controlled by Controller', async function () {
const controller = await L1GraphTokenGateway.controller()
expect(controller).eq(Controller.address)
})

describe('calls with unauthorized user', () => {
it('initialize should revert', async function () {
const tx = L1GraphTokenGateway.connect(unauthorized).initialize(unauthorized.address)
await expect(tx).revertedWith('Caller must be the implementation')
})

it('setArbitrumAddresses should revert', async function () {
const tx = L1GraphTokenGateway.connect(unauthorized).setArbitrumAddresses(
unauthorized.address,
unauthorized.address,
)
await expect(tx).revertedWith('Caller must be Controller governor')
})

it('setL2TokenAddress should revert', async function () {
const tx = L1GraphTokenGateway.connect(unauthorized).setL2TokenAddress(unauthorized.address)
await expect(tx).revertedWith('Caller must be Controller governor')
})

it('setL2CounterpartAddress should revert', async function () {
const tx = L1GraphTokenGateway.connect(unauthorized).setL2CounterpartAddress(
unauthorized.address,
)
await expect(tx).revertedWith('Caller must be Controller governor')
})

it('setEscrowAddress should revert', async function () {
const tx = L1GraphTokenGateway.connect(unauthorized).setEscrowAddress(unauthorized.address)
await expect(tx).revertedWith('Caller must be Controller governor')
})

it('addToCallhookWhitelist should revert', async function () {
const tx = L1GraphTokenGateway.connect(unauthorized).addToCallhookWhitelist(
unauthorized.address,
)
await expect(tx).revertedWith('Caller must be Controller governor')
})

it('removeFromCallhookWhitelist should revert', async function () {
const tx = L1GraphTokenGateway.connect(unauthorized).removeFromCallhookWhitelist(
unauthorized.address,
)
await expect(tx).revertedWith('Caller must be Controller governor')
})

it('finalizeInboundTransfer should revert', async function () {
const tx = L1GraphTokenGateway.connect(unauthorized).finalizeInboundTransfer(
unauthorized.address,
unauthorized.address,
unauthorized.address,
'100',
'0x00',
)

await expect(tx).revertedWith('ONLY_COUNTERPART_GATEWAY')
})
})
})
8 changes: 7 additions & 1 deletion e2e/deployment/config/l1/l1Reservoir.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import { expect } from 'chai'
import hre from 'hardhat'
import { getItemValue } from '../../../../cli/config'
import { chainIdIsL2 } from '../../../../cli/utils'

describe('L1Reservoir configuration', () => {
describe('[L1] L1Reservoir configuration', () => {
const {
graphConfig,
contracts: { Controller, L1Reservoir },
} = hre.graph()

before(async function () {
const chainId = (await hre.ethers.provider.getNetwork()).chainId
if (chainIdIsL2(chainId)) this.skip()
})

it('should be controlled by Controller', async function () {
const controller = await L1Reservoir.controller()
expect(controller).eq(Controller.address)
Expand Down
43 changes: 43 additions & 0 deletions e2e/deployment/config/l2/l2GraphToken.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'
import { expect } from 'chai'
import hre from 'hardhat'
import { chainIdIsL2 } from '../../../../cli/utils'

describe('[L2] L2GraphToken', () => {
const {
contracts: { L2GraphToken },
getTestAccounts,
} = hre.graph()

let unauthorized: SignerWithAddress

before(async function () {
const chainId = (await hre.ethers.provider.getNetwork()).chainId
if (!chainIdIsL2(chainId)) this.skip()

unauthorized = (await getTestAccounts())[0]
})

describe('calls with unauthorized user', () => {
it('mint should revert', async function () {
const tx = L2GraphToken.connect(unauthorized).mint(
unauthorized.address,
'1000000000000000000000',
)
await expect(tx).revertedWith('Only minter can call')
})

it('bridgeMint should revert', async function () {
const tx = L2GraphToken.connect(unauthorized).bridgeMint(
unauthorized.address,
'1000000000000000000000',
)
await expect(tx).revertedWith('NOT_GATEWAY')
})

it('setGateway should revert', async function () {
const tx = L2GraphToken.connect(unauthorized).setGateway(unauthorized.address)
await expect(tx).revertedWith('Only Governor can call')
})
})
})
66 changes: 66 additions & 0 deletions e2e/deployment/config/l2/l2GraphTokenGateway.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'
import { expect } from 'chai'
import hre from 'hardhat'
import { chainIdIsL2 } from '../../../../cli/utils'

describe('[L2] L2GraphTokenGateway configuration', () => {
const {
contracts: { Controller, L2GraphTokenGateway },
getTestAccounts,
} = hre.graph()

let unauthorized: SignerWithAddress

before(async function () {
const chainId = (await hre.ethers.provider.getNetwork()).chainId
if (!chainIdIsL2(chainId)) this.skip()

unauthorized = (await getTestAccounts())[0]
})

it('bridge should be unpaused', async function () {
const paused = await L2GraphTokenGateway.paused()
expect(paused).eq(false)
})

it('should be controlled by Controller', async function () {
const controller = await L2GraphTokenGateway.controller()
expect(controller).eq(Controller.address)
})

describe('calls with unauthorized user', () => {
it('initialize should revert', async function () {
const tx = L2GraphTokenGateway.connect(unauthorized).initialize(unauthorized.address)
await expect(tx).revertedWith('Caller must be the implementation')
})

it('setL2Router should revert', async function () {
const tx = L2GraphTokenGateway.connect(unauthorized).setL2Router(unauthorized.address)
await expect(tx).revertedWith('Caller must be Controller governor')
})

it('setL1TokenAddress should revert', async function () {
const tx = L2GraphTokenGateway.connect(unauthorized).setL1TokenAddress(unauthorized.address)
await expect(tx).revertedWith('Caller must be Controller governor')
})

it('setL1CounterpartAddress should revert', async function () {
const tx = L2GraphTokenGateway.connect(unauthorized).setL1CounterpartAddress(
unauthorized.address,
)
await expect(tx).revertedWith('Caller must be Controller governor')
})

it('finalizeInboundTransfer should revert', async function () {
const tx = L2GraphTokenGateway.connect(unauthorized).finalizeInboundTransfer(
unauthorized.address,
unauthorized.address,
unauthorized.address,
'1000000000000',
'0x00',
)

await expect(tx).revertedWith('ONLY_COUNTERPART_GATEWAY')
})
})
})
19 changes: 19 additions & 0 deletions e2e/deployment/config/l2/l2Reservoir.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { expect } from 'chai'
import hre from 'hardhat'
import { chainIdIsL2 } from '../../../../cli/utils'

describe('[L2] L2Reservoir configuration', () => {
const {
contracts: { Controller, L2Reservoir },
} = hre.graph()

before(async function () {
const chainId = (await hre.ethers.provider.getNetwork()).chainId
if (!chainIdIsL2(chainId)) this.skip()
})

it('should be controlled by Controller', async function () {
const controller = await L2Reservoir.controller()
expect(controller).eq(Controller.address)
})
})
11 changes: 0 additions & 11 deletions e2e/deployment/config/protocol.test.ts

This file was deleted.

14 changes: 12 additions & 2 deletions e2e/deployment/init/l1/graphToken.test.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
import { expect } from 'chai'
import hre from 'hardhat'
import { getItemValue } from '../../../../cli/config'
import { chainIdIsL2 } from '../../../../cli/utils'

describe('GraphToken initialization', () => {
describe('[L1] GraphToken initialization', () => {
const {
graphConfig,
contracts: { GraphToken },
} = hre.graph()

let chainId: number
before(async function () {
chainId = (await hre.ethers.provider.getNetwork()).chainId
if (chainIdIsL2(chainId)) this.skip()
})

it('total supply should match "initialSupply" on the config file', async function () {
const value = await GraphToken.totalSupply()
const expected = getItemValue(graphConfig, 'contracts/GraphToken/init/initialSupply')
hre.network.config.chainId === 1337 ? expect(value).eq(expected) : expect(value).gte(expected)

chainId === 1337 || chainId === 412346
? expect(value).eq(expected)
: expect(value).gte(expected)
})
})
Loading