@@ -3,43 +3,46 @@ import { ethers } from 'hardhat'
3
3
import { expect } from 'chai'
4
4
import hre from 'hardhat'
5
5
6
- import { DisputeManager , IGraphToken , IHorizonStaking , SubgraphService } from '../../../../typechain-types'
7
- import { createAttestationData } from '@graphprotocol/toolshed'
8
- import { SignerWithAddress } from '@nomicfoundation/hardhat-ethers/signers'
6
+ import { DisputeManager , IGraphToken , SubgraphService } from '../../../../typechain-types'
7
+ import { generateAttestationData } from '@graphprotocol/toolshed'
8
+ import { HardhatEthersSigner } from '@nomicfoundation/hardhat-ethers/signers'
9
+ import { HorizonStaking } from '@graphprotocol/horizon'
9
10
10
11
import { indexers } from '../../../../tasks/test/fixtures/indexers'
11
12
12
13
describe ( 'Query Conflict Disputes' , ( ) => {
13
14
let disputeManager : DisputeManager
14
15
let graphToken : IGraphToken
15
- let staking : IHorizonStaking
16
+ let staking : HorizonStaking
16
17
let subgraphService : SubgraphService
17
18
18
19
let snapshotId : string
20
+ let chainId : number
19
21
20
22
// Test addresses
21
- let fisherman : SignerWithAddress
22
- let arbitrator : SignerWithAddress
23
- let indexer : SignerWithAddress
24
- let relatedIndexer : SignerWithAddress
23
+ let fisherman : HardhatEthersSigner
24
+ let arbitrator : HardhatEthersSigner
25
+ let indexer : HardhatEthersSigner
26
+ let relatedIndexer : HardhatEthersSigner
25
27
26
28
// Allocation variables
27
- let allocationSigner : Wallet
28
- let relatedAllocationSigner : Wallet
29
+ let allocationPrivateKey : string
30
+ let relatedAllocationPrivateKey : string
29
31
let subgraphDeploymentId : string
30
32
31
33
// Dispute manager variables
32
34
let disputeDeposit : bigint
33
35
let fishermanRewardCut : bigint
34
36
let disputePeriod : bigint
37
+ let disputeManagerAddress : string
35
38
36
39
before ( async ( ) => {
37
40
// Get contracts
38
41
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
42
+ disputeManager = graph . subgraphService . contracts . DisputeManager
43
+ graphToken = graph . horizon . contracts . GraphToken
44
+ staking = graph . horizon . contracts . HorizonStaking
45
+ subgraphService = graph . subgraphService . contracts . SubgraphService
43
46
44
47
// Get signers
45
48
arbitrator = await graph . accounts . getArbitrator ( )
@@ -53,15 +56,19 @@ describe('Query Conflict Disputes', () => {
53
56
54
57
// Get allocation
55
58
const allocation = indexerFixture . allocations [ 0 ]
56
- allocationSigner = new Wallet ( allocation . allocationPrivateKey )
59
+ allocationPrivateKey = allocation . allocationPrivateKey
57
60
const relatedAllocation = relatedIndexerFixture . allocations [ 0 ]
58
- relatedAllocationSigner = new Wallet ( relatedAllocation . allocationPrivateKey )
61
+ relatedAllocationPrivateKey = relatedAllocation . allocationPrivateKey
59
62
subgraphDeploymentId = allocation . subgraphDeploymentID
60
63
61
64
// Dispute manager variables
62
65
disputeDeposit = await disputeManager . disputeDeposit ( )
63
66
fishermanRewardCut = await disputeManager . fishermanRewardCut ( )
64
67
disputePeriod = await disputeManager . disputePeriod ( )
68
+ disputeManagerAddress = await disputeManager . getAddress ( )
69
+
70
+ // Get chain ID
71
+ chainId = Number ( ( await ethers . provider . getNetwork ( ) ) . chainId )
65
72
} )
66
73
67
74
beforeEach ( async ( ) => {
@@ -82,19 +89,21 @@ describe('Query Conflict Disputes', () => {
82
89
const responseHash2 = ethers . keccak256 ( ethers . toUtf8Bytes ( 'test-response-2' ) )
83
90
84
91
// Create attestation data for both responses
85
- const attestationData1 = await createAttestationData (
86
- disputeManager ,
87
- allocationSigner ,
92
+ const attestationData1 = await generateAttestationData (
88
93
queryHash ,
89
94
responseHash1 ,
90
95
subgraphDeploymentId ,
96
+ allocationPrivateKey ,
97
+ disputeManagerAddress ,
98
+ chainId ,
91
99
)
92
- const attestationData2 = await createAttestationData (
93
- disputeManager ,
94
- relatedAllocationSigner ,
100
+ const attestationData2 = await generateAttestationData (
95
101
queryHash ,
96
102
responseHash2 ,
97
103
subgraphDeploymentId ,
104
+ relatedAllocationPrivateKey ,
105
+ disputeManagerAddress ,
106
+ chainId ,
98
107
)
99
108
100
109
// Approve dispute manager for dispute deposit
@@ -133,19 +142,21 @@ describe('Query Conflict Disputes', () => {
133
142
const responseHash2 = ethers . keccak256 ( ethers . toUtf8Bytes ( 'test-response-2' ) )
134
143
135
144
// Create attestation data for both responses
136
- const attestationData1 = await createAttestationData (
137
- disputeManager ,
138
- allocationSigner ,
145
+ const attestationData1 = await generateAttestationData (
139
146
queryHash ,
140
147
responseHash1 ,
141
148
subgraphDeploymentId ,
149
+ allocationPrivateKey ,
150
+ disputeManagerAddress ,
151
+ chainId ,
142
152
)
143
- const attestationData2 = await createAttestationData (
144
- disputeManager ,
145
- relatedAllocationSigner ,
153
+ const attestationData2 = await generateAttestationData (
146
154
queryHash ,
147
155
responseHash2 ,
148
156
subgraphDeploymentId ,
157
+ relatedAllocationPrivateKey ,
158
+ disputeManagerAddress ,
159
+ chainId ,
149
160
)
150
161
151
162
// Approve dispute manager for dispute deposit
@@ -197,19 +208,21 @@ describe('Query Conflict Disputes', () => {
197
208
const responseHash2 = ethers . keccak256 ( ethers . toUtf8Bytes ( 'test-response-2' ) )
198
209
199
210
// Create attestation data for both responses
200
- const attestationData1 = await createAttestationData (
201
- disputeManager ,
202
- allocationSigner ,
211
+ const attestationData1 = await generateAttestationData (
203
212
queryHash ,
204
213
responseHash1 ,
205
214
subgraphDeploymentId ,
215
+ allocationPrivateKey ,
216
+ disputeManagerAddress ,
217
+ chainId ,
206
218
)
207
- const attestationData2 = await createAttestationData (
208
- disputeManager ,
209
- relatedAllocationSigner ,
219
+ const attestationData2 = await generateAttestationData (
210
220
queryHash ,
211
221
responseHash2 ,
212
222
subgraphDeploymentId ,
223
+ relatedAllocationPrivateKey ,
224
+ disputeManagerAddress ,
225
+ chainId ,
213
226
)
214
227
215
228
// Approve dispute manager for dispute deposit
0 commit comments