diff --git a/packages/contracts/test/e2e/deployment/config/l1/rewardsManager.test.ts b/packages/contracts/test/e2e/deployment/config/l1/rewardsManager.test.ts index 0f9807d92..b7781fd96 100644 --- a/packages/contracts/test/e2e/deployment/config/l1/rewardsManager.test.ts +++ b/packages/contracts/test/e2e/deployment/config/l1/rewardsManager.test.ts @@ -1,17 +1,26 @@ import { expect } from 'chai' import hre from 'hardhat' import { isGraphL2ChainId } from '@graphprotocol/sdk' +import { NamedAccounts } from '@graphprotocol/sdk/gre' describe('[L1] RewardsManager configuration', () => { const graph = hre.graph() const { RewardsManager } = graph.contracts - before(function () { + let namedAccounts: NamedAccounts + + before(async function () { if (isGraphL2ChainId(graph.chainId)) this.skip() + namedAccounts = await graph.getNamedAccounts() }) it('issuancePerBlock should match "issuancePerBlock" in the config file', async function () { const value = await RewardsManager.issuancePerBlock() expect(value).eq('114693500000000000000') // 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) + }) }) diff --git a/packages/contracts/test/e2e/deployment/config/l2/rewardsManager.test.ts b/packages/contracts/test/e2e/deployment/config/l2/rewardsManager.test.ts index 9759ba78d..c324dc6bf 100644 --- a/packages/contracts/test/e2e/deployment/config/l2/rewardsManager.test.ts +++ b/packages/contracts/test/e2e/deployment/config/l2/rewardsManager.test.ts @@ -4,7 +4,7 @@ import hre from 'hardhat' describe('[L2] RewardsManager configuration', () => { const graph = hre.graph() - const { RewardsManager } = graph.contracts + const { RewardsManager, SubgraphAvailabilityManager } = graph.contracts before(function () { if (isGraphL1ChainId(graph.chainId)) this.skip() @@ -14,4 +14,9 @@ describe('[L2] RewardsManager configuration', () => { const value = await RewardsManager.issuancePerBlock() expect(value).eq('6036500000000000000') // hardcoded as it's set with a function call rather than init parameter }) + + it('should allow subgraph availability manager to deny rewards', async function () { + const availabilityOracle = await RewardsManager.subgraphAvailabilityOracle() + expect(availabilityOracle).eq(SubgraphAvailabilityManager.address) + }) }) diff --git a/packages/contracts/test/e2e/deployment/config/rewardsManager.test.ts b/packages/contracts/test/e2e/deployment/config/rewardsManager.test.ts index a3234dcba..e120392b6 100644 --- a/packages/contracts/test/e2e/deployment/config/rewardsManager.test.ts +++ b/packages/contracts/test/e2e/deployment/config/rewardsManager.test.ts @@ -1,19 +1,13 @@ import { expect } from 'chai' import hre from 'hardhat' -import { NamedAccounts } from '@graphprotocol/sdk/gre' describe('RewardsManager configuration', () => { const { - contracts: { RewardsManager, Controller, SubgraphAvailabilityManager }, + contracts: { RewardsManager, Controller }, } = hre.graph() it('should be controlled by Controller', async function () { const controller = await RewardsManager.controller() expect(controller).eq(Controller.address) }) - - it('should allow subgraph availability oracle to deny rewards', async function () { - const availabilityOracle = await RewardsManager.subgraphAvailabilityOracle() - expect(availabilityOracle).eq(SubgraphAvailabilityManager.address) - }) }) diff --git a/packages/contracts/test/unit/rewards/subgraphAvailability.test.ts b/packages/contracts/test/unit/rewards/subgraphAvailability.test.ts index 7d82c2960..93352a5b1 100644 --- a/packages/contracts/test/unit/rewards/subgraphAvailability.test.ts +++ b/packages/contracts/test/unit/rewards/subgraphAvailability.test.ts @@ -6,8 +6,8 @@ import { ethers } from 'hardhat' import type { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers' -import { SubgraphAvailabilityManager } from '../../build/types/SubgraphAvailabilityManager' -import { IRewardsManager } from '../../build/types/IRewardsManager' +import { SubgraphAvailabilityManager } from '../../../build/types/SubgraphAvailabilityManager' +import { IRewardsManager } from '../../../build/types/IRewardsManager' import { NetworkFixture } from '../lib/fixtures' diff --git a/packages/sdk/src/gre/accounts.ts b/packages/sdk/src/gre/accounts.ts index c7adcc588..ed9b216c3 100644 --- a/packages/sdk/src/gre/accounts.ts +++ b/packages/sdk/src/gre/accounts.ts @@ -13,6 +13,7 @@ const namedAccountList: AccountNames[] = [ 'arbitrator', 'governor', 'authority', + 'availabilityOracle', 'pauseGuardian', 'allocationExchangeOwner', ] @@ -24,8 +25,15 @@ export async function getNamedAccounts( const namedAccounts = namedAccountList.reduce( async (accountsPromise, name) => { const accounts = await accountsPromise - const address = getItemValue(readConfig(graphConfigPath, true), `general/${name}`) - accounts[name] = await SignerWithAddress.create(provider.getSigner(address)) + let address + try { + address = getItemValue(readConfig(graphConfigPath, true), `general/${name}`) + } catch (e) { + // Skip if not found + } + if (address) { + accounts[name] = await SignerWithAddress.create(provider.getSigner(address)) + } return accounts }, Promise.resolve({} as NamedAccounts), @@ -45,10 +53,13 @@ export async function getTestAccounts( ): Promise { // Get list of privileged accounts we don't want as test accounts const namedAccounts = await getNamedAccounts(provider, graphConfigPath) - const blacklist = namedAccountList.map((a) => { - const account = namedAccounts[a] - return account.address - }) + const blacklist = namedAccountList.reduce((accounts, name) => { + const account = namedAccounts[name] + if (account) { + accounts.push(account.address) + } + return accounts + }, []) blacklist.push((await getDeployer(provider)).address) // Get signers and filter out blacklisted accounts