@@ -118,4 +118,108 @@ contract DisputeManagerQueryAcceptDisputeTest is DisputeManagerTest {
118
118
vm.expectRevert (abi.encodeWithSelector (IDisputeManager.DisputeManagerDisputeNotInConflict.selector , disputeID));
119
119
disputeManager.acceptDisputeConflict (disputeID, tokensSlash, true , 0 );
120
120
}
121
+
122
+ function test_Query_Accept_Dispute_WithDelegation (
123
+ uint256 tokens ,
124
+ uint256 tokensDelegated ,
125
+ uint256 tokensSlash
126
+ ) public useIndexer useAllocation (tokens) useDelegation (tokensDelegated) {
127
+ tokensSlash = bound (
128
+ tokensSlash,
129
+ 1 ,
130
+ uint256 (maxSlashingPercentage).mulPPM (_calculateStakeSnapshot (tokens, tokensDelegated))
131
+ );
132
+
133
+ // Initial dispute with delegation slashing disabled
134
+ resetPrank (users.fisherman);
135
+ Attestation.Receipt memory receipt = _createAttestationReceipt (requestCID, responseCID, subgraphDeploymentId);
136
+ bytes memory attestationData = _createAtestationData (receipt, allocationIDPrivateKey);
137
+ bytes32 disputeID = _createQueryDispute (attestationData);
138
+
139
+ resetPrank (users.arbitrator);
140
+ _acceptDispute (disputeID, tokensSlash);
141
+ }
142
+
143
+ function test_Query_Accept_RevertWhen_SlashingOverMaxSlashPercentage_WithDelegation (
144
+ uint256 tokens ,
145
+ uint256 tokensDelegated ,
146
+ uint256 tokensSlash
147
+ ) public useIndexer useAllocation (tokens) useDelegation (tokensDelegated) {
148
+ uint256 maxTokensToSlash = uint256 (maxSlashingPercentage).mulPPM (
149
+ _calculateStakeSnapshot (tokens, tokensDelegated)
150
+ );
151
+ tokensSlash = bound (tokensSlash, maxTokensToSlash + 1 , type (uint256 ).max);
152
+
153
+ resetPrank (users.fisherman);
154
+ Attestation.Receipt memory receipt = _createAttestationReceipt (requestCID, responseCID, subgraphDeploymentId);
155
+ bytes memory attestationData = _createAtestationData (receipt, allocationIDPrivateKey);
156
+ bytes32 disputeID = _createQueryDispute (attestationData);
157
+
158
+ // max slashing percentage is 50%
159
+ resetPrank (users.arbitrator);
160
+ bytes memory expectedError = abi.encodeWithSelector (
161
+ IDisputeManager.DisputeManagerInvalidTokensSlash.selector ,
162
+ tokensSlash,
163
+ maxTokensToSlash
164
+ );
165
+ vm.expectRevert (expectedError);
166
+ disputeManager.acceptDispute (disputeID, tokensSlash);
167
+ }
168
+
169
+ function test_Query_Accept_Dispute_WithDelegation_DelegationSlashing (
170
+ uint256 tokens ,
171
+ uint256 tokensDelegated ,
172
+ uint256 tokensSlash
173
+ ) public useIndexer useAllocation (tokens) useDelegation (tokensDelegated) {
174
+ // enable delegation slashing
175
+ resetPrank (users.governor);
176
+ staking.setDelegationSlashingEnabled ();
177
+
178
+ tokensSlash = bound (
179
+ tokensSlash,
180
+ 1 ,
181
+ uint256 (maxSlashingPercentage).mulPPM (_calculateStakeSnapshot (tokens, tokensDelegated))
182
+ );
183
+
184
+ // Create a new dispute with delegation slashing enabled
185
+ resetPrank (users.fisherman);
186
+ Attestation.Receipt memory receipt = _createAttestationReceipt (requestCID, responseCID, subgraphDeploymentId);
187
+ bytes memory attestationData = _createAtestationData (receipt, allocationIDPrivateKey);
188
+ bytes32 disputeID = _createQueryDispute (attestationData);
189
+
190
+ resetPrank (users.arbitrator);
191
+ _acceptDispute (disputeID, tokensSlash);
192
+ }
193
+
194
+ function test_Query_Accept_RevertWhen_SlashingOverMaxSlashPercentage_WithDelegation_DelegationSlashing (
195
+ uint256 tokens ,
196
+ uint256 tokensDelegated ,
197
+ uint256 tokensSlash
198
+ ) public useIndexer useAllocation (tokens) useDelegation (tokensDelegated) {
199
+ // enable delegation slashing
200
+ resetPrank (users.governor);
201
+ staking.setDelegationSlashingEnabled ();
202
+
203
+ resetPrank (users.fisherman);
204
+ uint256 maxTokensToSlash = uint256 (maxSlashingPercentage).mulPPM (
205
+ _calculateStakeSnapshot (tokens, tokensDelegated)
206
+ );
207
+ tokensSlash = bound (tokensSlash, maxTokensToSlash + 1 , type (uint256 ).max);
208
+
209
+ // Create a new dispute with delegation slashing enabled
210
+ resetPrank (users.fisherman);
211
+ Attestation.Receipt memory receipt = _createAttestationReceipt (requestCID, responseCID, subgraphDeploymentId);
212
+ bytes memory attestationData = _createAtestationData (receipt, allocationIDPrivateKey);
213
+ bytes32 disputeID = _createQueryDispute (attestationData);
214
+
215
+ // max slashing percentage is 50%
216
+ resetPrank (users.arbitrator);
217
+ bytes memory expectedError = abi.encodeWithSelector (
218
+ IDisputeManager.DisputeManagerInvalidTokensSlash.selector ,
219
+ tokensSlash,
220
+ maxTokensToSlash
221
+ );
222
+ vm.expectRevert (expectedError);
223
+ disputeManager.acceptDispute (disputeID, tokensSlash);
224
+ }
121
225
}
0 commit comments