From 49c8eb0097ab287a585882e48e24476e9bd3298d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Fri, 22 Dec 2023 15:45:44 -0300 Subject: [PATCH] fix: tests assuming address.json MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- packages/contracts/addresses.json | 14 +++++++++ packages/contracts/scripts/test | 3 ++ packages/contracts/test/gns.test.ts | 31 ++++++++++--------- .../contracts/test/staking/allocation.test.ts | 2 +- .../contracts/test/staking/rebate.test.ts | 2 +- 5 files changed, 36 insertions(+), 16 deletions(-) diff --git a/packages/contracts/addresses.json b/packages/contracts/addresses.json index 28ed041de..8110ef84d 100644 --- a/packages/contracts/addresses.json +++ b/packages/contracts/addresses.json @@ -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", diff --git a/packages/contracts/scripts/test b/packages/contracts/scripts/test index 55d249716..d49b8535f 100755 --- a/packages/contracts/scripts/test +++ b/packages/contracts/scripts/test @@ -26,6 +26,9 @@ fi ### Main +# Init address book +echo {} > addresses-local.json + mkdir -p reports # Run using the standalone evm instance diff --git a/packages/contracts/test/gns.test.ts b/packages/contracts/test/gns.test.ts index 5e4278ac0..f73c3e8ea 100644 --- a/packages/contracts/test/gns.test.ts +++ b/packages/contracts/test/gns.test.ts @@ -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 @@ -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 @@ -65,6 +66,7 @@ describe('L1GNS', () => { let curation: Curation let controller: Controller let proxyAdmin: GraphProxyAdmin + let subgraphNFT: SubgraphNFT let l1GraphTokenGateway: L1GraphTokenGateway let arbitrumMocks: ArbitrumL1Mocks @@ -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() @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) }) }) diff --git a/packages/contracts/test/staking/allocation.test.ts b/packages/contracts/test/staking/allocation.test.ts index c53b40c7d..c4a104312 100644 --- a/packages/contracts/test/staking/allocation.test.ts +++ b/packages/contracts/test/staking/allocation.test.ts @@ -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 diff --git a/packages/contracts/test/staking/rebate.test.ts b/packages/contracts/test/staking/rebate.test.ts index 1d1168d08..ba9dd3c89 100644 --- a/packages/contracts/test/staking/rebate.test.ts +++ b/packages/contracts/test/staking/rebate.test.ts @@ -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