@@ -195,6 +195,81 @@ contract DisputeManagerTest is SubgraphServiceSharedTest {
195
195
return _disputeID;
196
196
}
197
197
198
+ struct Balances {
199
+ uint256 indexer;
200
+ uint256 fisherman;
201
+ uint256 arbitrator;
202
+ uint256 disputeManager;
203
+ uint256 staking;
204
+ }
205
+
206
+ function _createLegacyDispute (
207
+ address _allocationId ,
208
+ address _fisherman ,
209
+ uint256 _tokensSlash ,
210
+ uint256 _tokensRewards
211
+ ) internal returns (bytes32 ) {
212
+ (, address arbitrator , ) = vm.readCallers ();
213
+ address indexer = staking.getAllocation (_allocationId).indexer;
214
+
215
+ Balances memory beforeBalances = Balances ({
216
+ indexer: token.balanceOf (indexer),
217
+ fisherman: token.balanceOf (_fisherman),
218
+ arbitrator: token.balanceOf (arbitrator),
219
+ disputeManager: token.balanceOf (address (disputeManager)),
220
+ staking: token.balanceOf (address (staking))
221
+ });
222
+
223
+ vm.expectEmit (address (disputeManager));
224
+ emit IDisputeManager.LegacyDisputeCreated (
225
+ keccak256 (abi.encodePacked (_allocationId, "legacy " )),
226
+ indexer,
227
+ _fisherman,
228
+ _allocationId,
229
+ _tokensSlash,
230
+ _tokensRewards
231
+ );
232
+ vm.expectEmit (address (disputeManager));
233
+ emit IDisputeManager.DisputeAccepted (
234
+ keccak256 (abi.encodePacked (_allocationId, "legacy " )),
235
+ indexer,
236
+ _fisherman,
237
+ _tokensRewards
238
+ );
239
+ bytes32 _disputeId = disputeManager.createLegacyDispute (
240
+ _allocationId,
241
+ _fisherman,
242
+ _tokensSlash,
243
+ _tokensRewards
244
+ );
245
+
246
+ Balances memory afterBalances = Balances ({
247
+ indexer: token.balanceOf (indexer),
248
+ fisherman: token.balanceOf (_fisherman),
249
+ arbitrator: token.balanceOf (arbitrator),
250
+ disputeManager: token.balanceOf (address (disputeManager)),
251
+ staking: token.balanceOf (address (staking))
252
+ });
253
+
254
+ assertEq (afterBalances.indexer, beforeBalances.indexer);
255
+ assertEq (afterBalances.fisherman, beforeBalances.fisherman + _tokensRewards);
256
+ assertEq (afterBalances.arbitrator, beforeBalances.arbitrator);
257
+ assertEq (afterBalances.disputeManager, beforeBalances.disputeManager);
258
+ assertEq (afterBalances.staking, beforeBalances.staking - _tokensSlash);
259
+
260
+ IDisputeManager.Dispute memory dispute = _getDispute (_disputeId);
261
+ assertEq (dispute.indexer, indexer);
262
+ assertEq (dispute.fisherman, _fisherman);
263
+ assertEq (dispute.deposit, 0 );
264
+ assertEq (dispute.relatedDisputeId, bytes32 (0 ));
265
+ assertEq (uint8 (dispute.disputeType), uint8 (IDisputeManager.DisputeType.LegacyDispute));
266
+ assertEq (uint8 (dispute.status), uint8 (IDisputeManager.DisputeStatus.Accepted));
267
+ assertEq (dispute.createdAt, block .timestamp );
268
+ assertEq (dispute.stakeSnapshot, 0 );
269
+
270
+ return _disputeId;
271
+ }
272
+
198
273
struct BeforeValues_CreateQueryDisputeConflict {
199
274
Attestation.State attestation1;
200
275
Attestation.State attestation2;
0 commit comments