Skip to content

Commit

Permalink
fix: fix e2e deployment tests
Browse files Browse the repository at this point in the history
Signed-off-by: Tomás Migone <[email protected]>
  • Loading branch information
tmigone committed Aug 1, 2022
1 parent efbee4b commit e001034
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 10 deletions.
2 changes: 2 additions & 0 deletions cli/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { chainIdIsL2 } from './utils'
import { SubgraphNFT } from '../build/types/SubgraphNFT'
import { GraphCurationToken } from '../build/types/GraphCurationToken'
import { SubgraphNFTDescriptor } from '../build/types/SubgraphNFTDescriptor'
import { L1Reservoir } from '../build/types/L1Reservoir'

export interface NetworkContracts {
EpochManager: EpochManager
Expand All @@ -43,6 +44,7 @@ export interface NetworkContracts {
GraphGovernance: GraphGovernance
AllocationExchange: AllocationExchange
L1GraphTokenGateway: L1GraphTokenGateway
L1Reservoir: L1Reservoir
BridgeEscrow: BridgeEscrow
L2GraphToken: L2GraphToken
L2GraphTokenGateway: L2GraphTokenGateway
Expand Down
13 changes: 13 additions & 0 deletions e2e/deployment/config/bridgeEscrow.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { expect } from 'chai'
import hre from 'hardhat'

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

it('should be controlled by Controller', async function () {
const controller = await BridgeEscrow.controller()
expect(controller).eq(Controller.address)
})
})
11 changes: 8 additions & 3 deletions e2e/deployment/config/controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ describe('Controller configuration', () => {
'RewardsManager',
'Staking',
'GraphToken',
'L1GraphTokenGateway',
'L1Reservoir',
]

let namedAccounts: NamedAccounts
Expand All @@ -23,10 +25,13 @@ describe('Controller configuration', () => {
})

const proxyShouldMatchDeployed = async (contractName: string) => {
const curationAddress = await Controller.getContractProxy(
ethers.utils.solidityKeccak256(['string'], [contractName]),
// remove L1/L2 prefix, contracts are not registered as L1/L2 on controller
const name = contractName.replace(/(^L1|L2)/gi, '')

const address = await Controller.getContractProxy(
ethers.utils.solidityKeccak256(['string'], [name]),
)
expect(curationAddress).eq(contracts[contractName].address)
expect(address).eq(contracts[contractName].address)
}

it('should be owned by governor', async function () {
Expand Down
9 changes: 7 additions & 2 deletions e2e/deployment/config/graphToken.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { NamedAccounts } from '../../../tasks/type-extensions'
describe('GraphToken configuration', () => {
const {
getNamedAccounts,
contracts: { GraphToken, RewardsManager },
contracts: { GraphToken, RewardsManager, L1Reservoir },
getDeployer,
} = hre.graph()

Expand All @@ -26,8 +26,13 @@ describe('GraphToken configuration', () => {
hre.network.config.chainId === 1337 ? this.skip() : expect(deployerIsMinter).eq(false)
})

it('RewardsManager should be minter', async function () {
it('RewardsManager should not be a minter', async function () {
const deployerIsMinter = await GraphToken.isMinter(RewardsManager.address)
expect(deployerIsMinter).eq(false)
})

it('L1Reservoir should be a minter', async function () {
const deployerIsMinter = await GraphToken.isMinter(L1Reservoir.address)
expect(deployerIsMinter).eq(true)
})
})
13 changes: 13 additions & 0 deletions e2e/deployment/config/l1GraphTokenGateway.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { expect } from 'chai'
import hre from 'hardhat'

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

it('should be controlled by Controller', async function () {
const controller = await L1GraphTokenGateway.controller()
expect(controller).eq(Controller.address)
})
})
21 changes: 21 additions & 0 deletions e2e/deployment/config/l1Reservoir.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { expect } from 'chai'
import hre from 'hardhat'
import { getItemValue } from '../../../cli/config'

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

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

it('dripInterval should match "dripInterval" in the config file', async function () {
const value = await L1Reservoir.dripInterval()
const expected = getItemValue(graphConfig, 'contracts/L1Reservoir/init/dripInterval')
expect(value).eq(expected)
})
})
5 changes: 0 additions & 5 deletions e2e/deployment/config/rewardsManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ describe('RewardsManager configuration', () => {
expect(controller).eq(Controller.address)
})

it('issuanceRate should match "issuanceRate" in the config file', async function () {
const value = await RewardsManager.issuanceRate()
expect(value).eq('1000000012184945188') // hardcoded as it's set with a function call rather than init parameter
})

it('should allow subgraph availability oracle to deny rewards', async function () {
const availabilityOracle = await RewardsManager.subgraphAvailabilityOracle()
expect(availabilityOracle).eq(namedAccounts.availabilityOracle.address)
Expand Down

0 comments on commit e001034

Please sign in to comment.