Skip to content

Commit 23a35ee

Browse files
committed
chore: rebase and use new toolshed package
1 parent 0d6413a commit 23a35ee

File tree

25 files changed

+197
-419
lines changed

25 files changed

+197
-419
lines changed

packages/hardhat-graph-protocol/src/sdk/deployments/subgraph-service/actions/subgraphService.ts

-129
This file was deleted.

packages/hardhat-graph-protocol/src/sdk/deployments/subgraph-service/utils/allocation.ts

-21
This file was deleted.

packages/hardhat-graph-protocol/src/sdk/index.ts

-12
This file was deleted.

packages/subgraph-service/scripts/test/integration

+8-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
set -eo pipefail
44

5+
NON_INTERACTIVE=${NON_INTERACTIVE:-false}
6+
57
# Set environment variables for this script
6-
export HARDHAT_FORK=true
78
export SECURE_ACCOUNTS_DISABLE_PROVIDER=true
9+
export FORK_FROM_CHAIN_ID=${FORK_FROM_CHAIN_ID:-421614}
810

911
# Function to cleanup resources
1012
cleanup() {
@@ -80,14 +82,17 @@ else
8082
sleep 10
8183
fi
8284

85+
# Setup subgraph service address book
86+
jq '{"31337": ."'"$FORK_FROM_CHAIN_ID"'"}' addresses.json > addresses-localhost.json
87+
8388
# Run Horizon pre-upgrade steps
8489
cd ../horizon
8590

8691
# Setup pre horizon migration state needed for the e2e tests
87-
npx hardhat test:integration:pre-upgrade --network localhost
92+
npx hardhat test:seed --network localhost
8893

8994
# Transfer ownership of protocol to hardhat signer 1
90-
npx hardhat test:integration:transfer-ownership --network localhost
95+
npx hardhat test:transfer-ownership --network localhost
9196

9297
# Run Horizon steps 1 deployment
9398
npx hardhat deploy:migrate --network localhost --horizon-config e2e-test --step 1 --account-index 0 --patch-config

packages/subgraph-service/tasks/test/integration.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { glob } from 'glob'
22
import { task } from 'hardhat/config'
33
import { TASK_TEST } from 'hardhat/builtin-tasks/task-names'
44

5-
import { printBanner } from 'hardhat-graph-protocol/sdk'
5+
import { printBanner } from '@graphprotocol/toolshed/utils'
66

77
task('test:integration', 'Runs all integration tests')
88
.addParam(

packages/subgraph-service/tasks/test/post-upgrade.ts

+6-13
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { keccak256, toUtf8Bytes } from 'ethers'
22
import { task } from 'hardhat/config'
33

44
import { DisputeManager, SubgraphService } from '../../typechain-types'
5-
import { generateAllocationProof, HorizonStakingActions } from 'hardhat-graph-protocol/sdk'
65
import { IHorizonStaking } from '@graphprotocol/horizon'
76

87
import { indexers } from './fixtures/indexers'
@@ -11,9 +10,10 @@ task('test:post-upgrade', 'Test the post-upgrade state for integration tests')
1110
.setAction(async (_, hre) => {
1211
// Get contracts
1312
const graph = hre.graph()
14-
const horizonStaking = graph.horizon!.contracts.HorizonStaking as unknown as IHorizonStaking
15-
const subgraphService = graph.subgraphService!.contracts.SubgraphService as unknown as SubgraphService
16-
const disputeManager = graph.subgraphService!.contracts.DisputeManager as unknown as DisputeManager
13+
const { generateAllocationProof } = graph.subgraphService.actions
14+
const horizonStaking = graph.horizon.contracts.HorizonStaking as unknown as IHorizonStaking
15+
const subgraphService = graph.subgraphService.contracts.SubgraphService as unknown as SubgraphService
16+
const disputeManager = graph.subgraphService.contracts.DisputeManager as unknown as DisputeManager
1717

1818
// Get configs
1919
const disputePeriod = await disputeManager.getDisputePeriod()
@@ -54,14 +54,7 @@ task('test:post-upgrade', 'Test the post-upgrade state for integration tests')
5454
console.log(`Creating subgraph service provision for indexer: ${indexer.address}`)
5555

5656
const indexerSigner = await hre.ethers.getSigner(indexer.address)
57-
await HorizonStakingActions.createProvision({
58-
horizonStaking,
59-
serviceProvider: indexerSigner,
60-
verifier: await subgraphService.getAddress(),
61-
tokens: indexer.provisionTokens,
62-
maxVerifierCut: maxSlashingCut,
63-
thawingPeriod: disputePeriod,
64-
})
57+
await horizonStaking.connect(indexerSigner).provision(indexer.address, await subgraphService.getAddress(), indexer.provisionTokens, maxSlashingCut, disputePeriod)
6558

6659
console.log(`Provision created for indexer with ${indexer.provisionTokens} tokens`)
6760

@@ -94,7 +87,7 @@ task('test:post-upgrade', 'Test the post-upgrade state for integration tests')
9487
console.log(`Starting allocation: ${allocation.allocationID}`)
9588

9689
// Build allocation proof
97-
const signature = await generateAllocationProof(subgraphService, indexer.address, allocation.allocationPrivateKey)
90+
const signature = await generateAllocationProof(allocation.allocationPrivateKey, [indexer.address, allocation.allocationID])
9891
const subgraphDeploymentId = allocation.subgraphDeploymentID
9992
const allocationTokens = allocation.tokens
10093
const allocationId = allocation.allocationID

packages/subgraph-service/test/integration/after-transition-period/dispute-manager/governance.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('DisputeManager Governance', () => {
1717

1818
before(async () => {
1919
const graph = hre.graph()
20-
disputeManager = graph.subgraphService!.contracts.DisputeManager as unknown as DisputeManager
20+
disputeManager = graph.subgraphService.contracts.DisputeManager as unknown as DisputeManager
2121

2222
// Get signers
2323
const signers = await ethers.getSigners()

packages/subgraph-service/test/integration/after-transition-period/dispute-manager/indexing-disputes.test.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ethers } from 'hardhat'
2+
import { EventLog } from 'ethers'
23
import { expect } from 'chai'
34
import hre from 'hardhat'
4-
import { EventLog } from 'ethers'
55

66
import { DisputeManager, IGraphToken, IHorizonStaking, SubgraphService } from '../../../../typechain-types'
77
import { SignerWithAddress } from '@nomicfoundation/hardhat-ethers/signers'
@@ -31,10 +31,10 @@ describe('Indexing Disputes', () => {
3131
before(async () => {
3232
// Get contracts
3333
const graph = hre.graph()
34-
disputeManager = graph.subgraphService!.contracts.DisputeManager as unknown as DisputeManager
35-
graphToken = graph.horizon!.contracts.GraphToken as unknown as IGraphToken
36-
staking = graph.horizon!.contracts.HorizonStaking as unknown as IHorizonStaking
37-
subgraphService = graph.subgraphService!.contracts.SubgraphService as unknown as SubgraphService
34+
disputeManager = graph.subgraphService.contracts.DisputeManager as unknown as DisputeManager
35+
graphToken = graph.horizon.contracts.GraphToken as unknown as IGraphToken
36+
staking = graph.horizon.contracts.HorizonStaking as unknown as IHorizonStaking
37+
subgraphService = graph.subgraphService.contracts.SubgraphService as unknown as SubgraphService
3838

3939
// Get signers
4040
const signers = await ethers.getSigners()

packages/subgraph-service/test/integration/after-transition-period/dispute-manager/query-conflict-disputes.test.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { expect } from 'chai'
44
import hre from 'hardhat'
55

66
import { DisputeManager, IGraphToken, IHorizonStaking, SubgraphService } from '../../../../typechain-types'
7-
import { createAttestationData } from 'hardhat-graph-protocol/sdk'
7+
import { createAttestationData } from '@graphprotocol/toolshed'
88
import { SignerWithAddress } from '@nomicfoundation/hardhat-ethers/signers'
99

1010
import { indexers } from '../../../../tasks/test/fixtures/indexers'
@@ -36,10 +36,10 @@ describe('Query Conflict Disputes', () => {
3636
before(async () => {
3737
// Get contracts
3838
const graph = hre.graph()
39-
disputeManager = graph.subgraphService!.contracts.DisputeManager as unknown as DisputeManager
40-
graphToken = graph.horizon!.contracts.GraphToken as unknown as IGraphToken
41-
staking = graph.horizon!.contracts.HorizonStaking as unknown as IHorizonStaking
42-
subgraphService = graph.subgraphService!.contracts.SubgraphService as unknown as SubgraphService
39+
disputeManager = graph.subgraphService.contracts.DisputeManager as unknown as DisputeManager
40+
graphToken = graph.horizon.contracts.GraphToken as unknown as IGraphToken
41+
staking = graph.horizon.contracts.HorizonStaking as unknown as IHorizonStaking
42+
subgraphService = graph.subgraphService.contracts.SubgraphService as unknown as SubgraphService
4343

4444
// Get signers
4545
const signers = await ethers.getSigners()

packages/subgraph-service/test/integration/after-transition-period/dispute-manager/query-disputes.test.ts

+9-5
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import { expect } from 'chai'
44
import hre from 'hardhat'
55

66
import { DisputeManager, IGraphToken, IHorizonStaking, SubgraphService } from '../../../../typechain-types'
7-
import { createAttestationData } from 'hardhat-graph-protocol/sdk'
7+
import { createAttestationData } from '@graphprotocol/toolshed'
88
import { SignerWithAddress } from '@nomicfoundation/hardhat-ethers/signers'
99

1010
import { indexers } from '../../../../tasks/test/fixtures/indexers'
11+
import { setGRTBalance } from '@graphprotocol/toolshed/hardhat'
1112

1213
describe('Query Disputes', () => {
1314
let disputeManager: DisputeManager
@@ -34,10 +35,10 @@ describe('Query Disputes', () => {
3435
before(async () => {
3536
// Get contracts
3637
const graph = hre.graph()
37-
disputeManager = graph.subgraphService!.contracts.DisputeManager as unknown as DisputeManager
38-
graphToken = graph.horizon!.contracts.GraphToken as unknown as IGraphToken
39-
staking = graph.horizon!.contracts.HorizonStaking as unknown as IHorizonStaking
40-
subgraphService = graph.subgraphService!.contracts.SubgraphService as unknown as SubgraphService
38+
disputeManager = graph.subgraphService.contracts.DisputeManager as unknown as DisputeManager
39+
graphToken = graph.horizon.contracts.GraphToken as unknown as IGraphToken
40+
staking = graph.horizon.contracts.HorizonStaking as unknown as IHorizonStaking
41+
subgraphService = graph.subgraphService.contracts.SubgraphService as unknown as SubgraphService
4142

4243
// Get signers
4344
const signers = await ethers.getSigners()
@@ -57,6 +58,9 @@ describe('Query Disputes', () => {
5758
disputeDeposit = await disputeManager.disputeDeposit()
5859
fishermanRewardCut = await disputeManager.fishermanRewardCut()
5960
disputePeriod = await disputeManager.disputePeriod()
61+
62+
// Set GRT balance for fisherman
63+
await setGRTBalance(graph.provider, graphToken.target, fisherman.address, ethers.parseEther('1000000'))
6064
})
6165

6266
beforeEach(async () => {

packages/subgraph-service/test/integration/after-transition-period/subgraph-service/governance.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('Subgraph Service Governance', () => {
1717

1818
before(async () => {
1919
const graph = hre.graph()
20-
subgraphService = graph.subgraphService!.contracts.SubgraphService as unknown as SubgraphService
20+
subgraphService = graph.subgraphService.contracts.SubgraphService as unknown as SubgraphService
2121

2222
// Get signers
2323
const signers = await ethers.getSigners()

0 commit comments

Comments
 (0)