Skip to content

Commit

Permalink
fix: tests assuming address.json
Browse files Browse the repository at this point in the history
Signed-off-by: Tomás Migone <[email protected]>
  • Loading branch information
tmigone committed Dec 22, 2023
1 parent 62de693 commit 49c8eb0
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 16 deletions.
14 changes: 14 additions & 0 deletions packages/contracts/addresses.json
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,20 @@
"txHash": "0x20a0c0f2a26258e1c63f33f3a5651580bb74ea4bf0e66076ebbdda4fa41d5955"
}
},
"1337": {
"Controller": {
"address": "0x8C9eA3b7B74c0Ed904BF398F2fd25c17A83F4FAE",
"creationCodeHash": "0x5bde9a87bc4e8dd24d41900f0a19321c1dc6d3373d51bba093b130bb5b80a677",
"runtimeCodeHash": "0x7f0479db1d60ecf6295d92ea2359ebdd223640795613558b0594680f5d4922c9",
"txHash": "0x09d185ecf831dfb89d6d24d8800952a7c2b67676a11ed96466ff2ec3842987f6"
},
"GraphProxyAdmin": {
"address": "0xF4407c28ED10639Cb5e1AA5a3Be42108B45973E6",
"creationCodeHash": "0x68b304ac6bce7380d5e0f6b14a122f628bffebcc75f8205cb60f0baf578b79c3",
"runtimeCodeHash": "0x8d9ba87a745cf82ab407ebabe6c1490197084d320efb6c246d94bcc80e804417",
"txHash": "0xdb4715cf9bd9693c5817a997201866b01969c3c182429f0f5d6bd63943404880"
}
},
"42161": {
"GraphProxyAdmin": {
"address": "0x2983936aC20202a6555993448E0d5654AC8Ca5fd",
Expand Down
3 changes: 3 additions & 0 deletions packages/contracts/scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ fi

### Main

# Init address book
echo {} > addresses-local.json

mkdir -p reports

# Run using the standalone evm instance
Expand Down
31 changes: 17 additions & 14 deletions packages/contracts/test/gns.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
loadContractAt,
} from '@graphprotocol/sdk'
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'
import { SubgraphNFT } from '../build/types'

const { AddressZero, HashZero } = ethers.constants

Expand All @@ -45,7 +46,7 @@ const toFloat = (n: BigNumber) => parseFloat(formatGRT(n))
const toRound = (n: number) => n.toFixed(12)

describe('L1GNS', () => {
const graph = hre.graph()
const graph = hre.graph({ addressBook: 'addresses-local.json' })

let me: SignerWithAddress
let other: SignerWithAddress
Expand All @@ -65,6 +66,7 @@ describe('L1GNS', () => {
let curation: Curation
let controller: Controller
let proxyAdmin: GraphProxyAdmin
let subgraphNFT: SubgraphNFT
let l1GraphTokenGateway: L1GraphTokenGateway
let arbitrumMocks: ArbitrumL1Mocks

Expand Down Expand Up @@ -244,6 +246,7 @@ describe('L1GNS', () => {
controller = fixtureContracts.Controller as Controller
proxyAdmin = fixtureContracts.GraphProxyAdmin as GraphProxyAdmin
l1GraphTokenGateway = fixtureContracts.L1GraphTokenGateway as L1GraphTokenGateway
subgraphNFT = fixtureContracts.SubgraphNFT as SubgraphNFT

newSubgraph0 = buildSubgraph()
newSubgraph1 = buildSubgraph()
Expand Down Expand Up @@ -888,17 +891,17 @@ describe('L1GNS', () => {

describe('NFT descriptor', function () {
it('cannot be minted by an account that is not the minter (i.e. GNS)', async function () {
const tx = graph.contracts.SubgraphNFT.connect(me).mint(me.address, 1)
const tx = subgraphNFT.connect(me).mint(me.address, 1)
await expect(tx).revertedWith('Must be a minter')
})
it('cannot be burned by an account that is not the minter (i.e. GNS)', async function () {
const tx = graph.contracts.SubgraphNFT.connect(me).burn(1)
const tx = subgraphNFT.connect(me).burn(1)
await expect(tx).revertedWith('Must be a minter')
})
it('with token descriptor', async function () {
const subgraph0 = await publishNewSubgraph(me, newSubgraph0, gns, graph.chainId)

const tokenURI = await graph.contracts.SubgraphNFT.connect(me).tokenURI(subgraph0.id)
const tokenURI = await subgraphNFT.connect(me).tokenURI(subgraph0.id)

const sub = new SubgraphDeploymentID(newSubgraph0.subgraphMetadata)
expect(sub.ipfsHash).eq(tokenURI)
Expand All @@ -907,8 +910,8 @@ describe('L1GNS', () => {
it('with token descriptor and baseURI', async function () {
const subgraph0 = await publishNewSubgraph(me, newSubgraph0, gns, graph.chainId)

await graph.contracts.SubgraphNFT.connect(governor).setBaseURI('ipfs://')
const tokenURI = await graph.contracts.SubgraphNFT.connect(me).tokenURI(subgraph0.id)
await subgraphNFT.connect(governor).setBaseURI('ipfs://')
const tokenURI = await subgraphNFT.connect(me).tokenURI(subgraph0.id)

const sub = new SubgraphDeploymentID(newSubgraph0.subgraphMetadata)
expect('ipfs://' + sub.ipfsHash).eq(tokenURI)
Expand All @@ -917,8 +920,8 @@ describe('L1GNS', () => {
it('without token descriptor', async function () {
const subgraph0 = await publishNewSubgraph(me, newSubgraph0, gns, graph.chainId)

await graph.contracts.SubgraphNFT.connect(governor).setTokenDescriptor(AddressZero)
const tokenURI = await graph.contracts.SubgraphNFT.connect(me).tokenURI(subgraph0.id)
await subgraphNFT.connect(governor).setTokenDescriptor(AddressZero)
const tokenURI = await subgraphNFT.connect(me).tokenURI(subgraph0.id)

const sub = new SubgraphDeploymentID(newSubgraph0.subgraphMetadata)
expect(sub.bytes32).eq(tokenURI)
Expand All @@ -927,9 +930,9 @@ describe('L1GNS', () => {
it('without token descriptor and baseURI', async function () {
const subgraph0 = await publishNewSubgraph(me, newSubgraph0, gns, graph.chainId)

await graph.contracts.SubgraphNFT.connect(governor).setTokenDescriptor(AddressZero)
await graph.contracts.SubgraphNFT.connect(governor).setBaseURI('ipfs://')
const tokenURI = await graph.contracts.SubgraphNFT.connect(me).tokenURI(subgraph0.id)
await subgraphNFT.connect(governor).setTokenDescriptor(AddressZero)
await subgraphNFT.connect(governor).setBaseURI('ipfs://')
const tokenURI = await subgraphNFT.connect(me).tokenURI(subgraph0.id)

const sub = new SubgraphDeploymentID(newSubgraph0.subgraphMetadata)
expect('ipfs://' + sub.bytes32).eq(tokenURI)
Expand All @@ -940,9 +943,9 @@ describe('L1GNS', () => {
newSubgraphNoMetadata.subgraphMetadata = HashZero
const subgraph0 = await publishNewSubgraph(me, newSubgraphNoMetadata, gns, graph.chainId)

await graph.contracts.SubgraphNFT.connect(governor).setTokenDescriptor(AddressZero)
await graph.contracts.SubgraphNFT.connect(governor).setBaseURI('ipfs://')
const tokenURI = await graph.contracts.SubgraphNFT.connect(me).tokenURI(subgraph0.id)
await subgraphNFT.connect(governor).setTokenDescriptor(AddressZero)
await subgraphNFT.connect(governor).setBaseURI('ipfs://')
const tokenURI = await subgraphNFT.connect(me).tokenURI(subgraph0.id)
expect('ipfs://' + subgraph0.id).eq(tokenURI)
})
})
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/test/staking/allocation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const ABI_LIB_EXPONENTIAL = [
]

describe('Staking:Allocation', () => {
const graph = hre.graph()
const graph = hre.graph({ addressBook: 'addresses-local.json' })
let me: SignerWithAddress
let governor: SignerWithAddress
let indexer: SignerWithAddress
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/test/staking/rebate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export function exponentialRebates(
}

describe('Staking:rebates', () => {
const graph = hre.graph()
const graph = hre.graph({ addressBook: 'addresses-local.json' })

let libExponential: LibExponential
let fixture: NetworkFixture
Expand Down

0 comments on commit 49c8eb0

Please sign in to comment.