@@ -195,6 +195,14 @@ 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
+
198
206
function _createLegacyDispute (
199
207
address _allocationId ,
200
208
address _fisherman ,
@@ -204,40 +212,62 @@ contract DisputeManagerTest is SubgraphServiceSharedTest {
204
212
(, address arbitrator , ) = vm.readCallers ();
205
213
address indexer = staking.getAllocation (_allocationId).indexer;
206
214
207
- bytes32 expectedDisputeId = keccak256 (abi.encodePacked (_allocationId, "legacy " ));
208
- uint256 disputeDeposit = 0 ;
209
-
210
- uint256 beforeIndexerBalance = token.balanceOf (indexer);
211
- uint256 beforeFishermanBalance = token.balanceOf (_fisherman);
212
- uint256 beforeArbitratorBalance = token.balanceOf (arbitrator);
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
+ });
213
222
214
223
vm.expectEmit (address (disputeManager));
215
224
emit IDisputeManager.LegacyDisputeCreated (
216
- expectedDisputeId ,
225
+ keccak256 ( abi.encodePacked (_allocationId, " legacy " )) ,
217
226
indexer,
218
227
_fisherman,
219
228
_allocationId,
220
229
_tokensSlash,
221
230
_tokensRewards
222
231
);
223
232
vm.expectEmit (address (disputeManager));
224
- emit IDisputeManager.DisputeAccepted (expectedDisputeId, indexer, _fisherman, _tokensRewards);
233
+ emit IDisputeManager.DisputeAccepted (
234
+ keccak256 (abi.encodePacked (_allocationId, "legacy " )),
235
+ indexer,
236
+ _fisherman,
237
+ _tokensRewards
238
+ );
225
239
bytes32 _disputeId = disputeManager.createLegacyDispute (
226
240
_allocationId,
227
241
_fisherman,
228
242
_tokensSlash,
229
243
_tokensRewards
230
244
);
231
245
232
- uint256 afterIndexerBalance = token.balanceOf (indexer);
233
- uint256 afterFishermanBalance = token.balanceOf (_fisherman);
234
- uint256 afterArbitratorBalance = token.balanceOf (arbitrator);
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);
235
259
236
- assertEq (afterIndexerBalance, beforeIndexerBalance - _tokensSlash);
237
- assertEq (afterFishermanBalance, beforeFishermanBalance + _tokensRewards);
238
- assertEq (afterArbitratorBalance, beforeArbitratorBalance);
239
- assertTrue (disputeManager.isDisputeCreated (_disputeId));
240
- assertEq (expectedDisputeId, _disputeId);
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;
241
271
}
242
272
243
273
struct BeforeValues_CreateQueryDisputeConflict {
0 commit comments