Skip to content

Commit b24377e

Browse files
committed
fix: e2e tests
1 parent 87bb02d commit b24377e

File tree

5 files changed

+36
-17
lines changed

5 files changed

+36
-17
lines changed
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
11
import { expect } from 'chai'
22
import hre from 'hardhat'
33
import { isGraphL2ChainId } from '@graphprotocol/sdk'
4+
import { NamedAccounts } from '@graphprotocol/sdk/gre'
45

56
describe('[L1] RewardsManager configuration', () => {
67
const graph = hre.graph()
78
const { RewardsManager } = graph.contracts
89

9-
before(function () {
10+
let namedAccounts: NamedAccounts
11+
12+
before(async function () {
1013
if (isGraphL2ChainId(graph.chainId)) this.skip()
14+
namedAccounts = await graph.getNamedAccounts()
1115
})
1216

1317
it('issuancePerBlock should match "issuancePerBlock" in the config file', async function () {
1418
const value = await RewardsManager.issuancePerBlock()
1519
expect(value).eq('114693500000000000000') // hardcoded as it's set with a function call rather than init parameter
1620
})
21+
22+
it('should allow subgraph availability oracle to deny rewards', async function () {
23+
const availabilityOracle = await RewardsManager.subgraphAvailabilityOracle()
24+
expect(availabilityOracle).eq(namedAccounts.availabilityOracle.address)
25+
})
1726
})

packages/contracts/test/e2e/deployment/config/l2/rewardsManager.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import hre from 'hardhat'
44

55
describe('[L2] RewardsManager configuration', () => {
66
const graph = hre.graph()
7-
const { RewardsManager } = graph.contracts
7+
const { RewardsManager, SubgraphAvailabilityManager } = graph.contracts
88

99
before(function () {
1010
if (isGraphL1ChainId(graph.chainId)) this.skip()
@@ -14,4 +14,9 @@ describe('[L2] RewardsManager configuration', () => {
1414
const value = await RewardsManager.issuancePerBlock()
1515
expect(value).eq('6036500000000000000') // hardcoded as it's set with a function call rather than init parameter
1616
})
17+
18+
it('should allow subgraph availability manager to deny rewards', async function () {
19+
const availabilityOracle = await RewardsManager.subgraphAvailabilityOracle()
20+
expect(availabilityOracle).eq(SubgraphAvailabilityManager.address)
21+
})
1722
})
Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
import { expect } from 'chai'
22
import hre from 'hardhat'
3-
import { NamedAccounts } from '@graphprotocol/sdk/gre'
43

54
describe('RewardsManager configuration', () => {
65
const {
7-
contracts: { RewardsManager, Controller, SubgraphAvailabilityManager },
6+
contracts: { RewardsManager, Controller },
87
} = hre.graph()
98

109
it('should be controlled by Controller', async function () {
1110
const controller = await RewardsManager.controller()
1211
expect(controller).eq(Controller.address)
1312
})
14-
15-
it('should allow subgraph availability oracle to deny rewards', async function () {
16-
const availabilityOracle = await RewardsManager.subgraphAvailabilityOracle()
17-
expect(availabilityOracle).eq(SubgraphAvailabilityManager.address)
18-
})
1913
})

packages/contracts/test/unit/rewards/subgraphAvailability.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { ethers } from 'hardhat'
66

77
import type { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'
88

9-
import { SubgraphAvailabilityManager } from '../../build/types/SubgraphAvailabilityManager'
10-
import { IRewardsManager } from '../../build/types/IRewardsManager'
9+
import { SubgraphAvailabilityManager } from '../../../build/types/SubgraphAvailabilityManager'
10+
import { IRewardsManager } from '../../../build/types/IRewardsManager'
1111

1212
import { NetworkFixture } from '../lib/fixtures'
1313

packages/sdk/src/gre/accounts.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const namedAccountList: AccountNames[] = [
1313
'arbitrator',
1414
'governor',
1515
'authority',
16+
'availabilityOracle',
1617
'pauseGuardian',
1718
'allocationExchangeOwner',
1819
]
@@ -24,8 +25,15 @@ export async function getNamedAccounts(
2425
const namedAccounts = namedAccountList.reduce(
2526
async (accountsPromise, name) => {
2627
const accounts = await accountsPromise
27-
const address = getItemValue(readConfig(graphConfigPath, true), `general/${name}`)
28-
accounts[name] = await SignerWithAddress.create(provider.getSigner(address))
28+
let address
29+
try {
30+
address = getItemValue(readConfig(graphConfigPath, true), `general/${name}`)
31+
} catch (e) {
32+
// Skip if not found
33+
}
34+
if (address) {
35+
accounts[name] = await SignerWithAddress.create(provider.getSigner(address))
36+
}
2937
return accounts
3038
},
3139
Promise.resolve({} as NamedAccounts),
@@ -45,10 +53,13 @@ export async function getTestAccounts(
4553
): Promise<SignerWithAddress[]> {
4654
// Get list of privileged accounts we don't want as test accounts
4755
const namedAccounts = await getNamedAccounts(provider, graphConfigPath)
48-
const blacklist = namedAccountList.map((a) => {
49-
const account = namedAccounts[a]
50-
return account.address
51-
})
56+
const blacklist = namedAccountList.reduce((accounts, name) => {
57+
const account = namedAccounts[name]
58+
if (account) {
59+
accounts.push(account.address)
60+
}
61+
return accounts
62+
}, [])
5263
blacklist.push((await getDeployer(provider)).address)
5364

5465
// Get signers and filter out blacklisted accounts

0 commit comments

Comments
 (0)