@@ -226,7 +226,38 @@ contract SubgraphServiceIndexingAgreementAcceptTest is SubgraphServiceIndexingAg
226
226
subgraphService.acceptIndexingAgreement (ctx.indexers[0 ].allocationId, accepted);
227
227
}
228
228
229
- function test_SubgraphService_AcceptIndexingAgreement_Revert_WhenAgreementAlreadyAllocated () public {}
229
+ function test_SubgraphService_AcceptIndexingAgreement_Revert_WhenAgreementAlreadyAllocated (
230
+ Seed memory seed ,
231
+ uint256 alternativeNonce
232
+ ) public {
233
+ Context storage ctx = _newCtx (seed);
234
+ IndexerState memory indexerState = _withIndexer (ctx);
235
+
236
+ // First, accept an indexing agreement on the allocation
237
+ (IRecurringCollector.SignedRCA memory accepted , ) = _withAcceptedIndexingAgreement (ctx, indexerState);
238
+ vm.assume (accepted.rca.nonce != alternativeNonce);
239
+
240
+ // Now try to accept a different agreement on the same allocation
241
+ // Create a new agreement with different nonce to ensure different agreement ID
242
+ IRecurringCollector.RecurringCollectionAgreement
243
+ memory newRCA = _generateAcceptableRecurringCollectionAgreement (ctx, indexerState.addr);
244
+ newRCA.nonce = alternativeNonce; // Different nonce to ensure different agreement ID
245
+
246
+ // Sign the new agreement
247
+ IRecurringCollector.SignedRCA memory newSignedRCA = _recurringCollectorHelper.generateSignedRCA (
248
+ newRCA,
249
+ ctx.payer.signerPrivateKey
250
+ );
251
+
252
+ // Expect the error when trying to accept a second agreement on the same allocation
253
+ bytes memory expectedErr = abi.encodeWithSelector (
254
+ IndexingAgreement.AllocationAlreadyHasIndexingAgreement.selector ,
255
+ indexerState.allocationId
256
+ );
257
+ vm.expectRevert (expectedErr);
258
+ resetPrank (indexerState.addr);
259
+ subgraphService.acceptIndexingAgreement (indexerState.allocationId, newSignedRCA);
260
+ }
230
261
231
262
function test_SubgraphService_AcceptIndexingAgreement_Revert_WhenInvalidTermsData (Seed memory seed ) public {
232
263
Context storage ctx = _newCtx (seed);
0 commit comments