Skip to content

Commit fa57fbc

Browse files
committed
fix: update expected errors and assertions in failing tests
1 parent 9742dd8 commit fa57fbc

5 files changed

Lines changed: 24 additions & 15 deletions

File tree

packages/subgraph-service/test/unit/subgraphService/allocation/resize.t.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ pragma solidity ^0.8.27;
33

44
import { SubgraphServiceTest } from "../SubgraphService.t.sol";
55
import { ISubgraphService } from "@graphprotocol/interfaces/contracts/subgraph-service/ISubgraphService.sol";
6-
import { IAllocationManager } from "@graphprotocol/interfaces/contracts/subgraph-service/internal/IAllocationManager.sol";
6+
import { AllocationHandler } from "../../../../contracts/libraries/AllocationHandler.sol";
77
import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol";
88

99
contract SubgraphServiceAllocationResizeTest is SubgraphServiceTest {
@@ -85,7 +85,7 @@ contract SubgraphServiceAllocationResizeTest is SubgraphServiceTest {
8585
) public useIndexer useAllocation(tokens) {
8686
vm.expectRevert(
8787
abi.encodeWithSelector(
88-
IAllocationManager.AllocationManagerAllocationSameSize.selector,
88+
AllocationHandler.AllocationHandlerAllocationSameSize.selector,
8989
allocationId,
9090
tokens
9191
)
@@ -101,7 +101,7 @@ contract SubgraphServiceAllocationResizeTest is SubgraphServiceTest {
101101
bytes memory data = abi.encode(allocationId);
102102
_stopService(users.indexer, data);
103103
vm.expectRevert(
104-
abi.encodeWithSelector(IAllocationManager.AllocationManagerAllocationClosed.selector, allocationId)
104+
abi.encodeWithSelector(AllocationHandler.AllocationHandlerAllocationClosed.selector, allocationId)
105105
);
106106
subgraphService.resizeAllocation(users.indexer, allocationId, resizeTokens);
107107
}

packages/subgraph-service/test/unit/subgraphService/allocation/start.t.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
55
import { ProvisionManager } from "@graphprotocol/horizon/contracts/data-service/utilities/ProvisionManager.sol";
66
import { ProvisionTracker } from "@graphprotocol/horizon/contracts/data-service/libraries/ProvisionTracker.sol";
77
import { IAllocation } from "@graphprotocol/interfaces/contracts/subgraph-service/internal/IAllocation.sol";
8-
import { IAllocationManager } from "@graphprotocol/interfaces/contracts/subgraph-service/internal/IAllocationManager.sol";
8+
import { AllocationHandler } from "../../../../contracts/libraries/AllocationHandler.sol";
99
import { ILegacyAllocation } from "@graphprotocol/interfaces/contracts/subgraph-service/internal/ILegacyAllocation.sol";
1010
import { ISubgraphService } from "@graphprotocol/interfaces/contracts/subgraph-service/ISubgraphService.sol";
1111
import { SubgraphServiceTest } from "../SubgraphService.t.sol";
@@ -94,7 +94,7 @@ contract SubgraphServiceAllocationStartTest is SubgraphServiceTest {
9494
bytes32 digest = subgraphService.encodeAllocationProof(users.indexer, address(0));
9595
(uint8 v, bytes32 r, bytes32 s) = vm.sign(allocationIdPrivateKey, digest);
9696
bytes memory data = abi.encode(subgraphDeployment, tokens, address(0), abi.encodePacked(r, s, v));
97-
vm.expectRevert(abi.encodeWithSelector(IAllocationManager.AllocationManagerInvalidZeroAllocationId.selector));
97+
vm.expectRevert(abi.encodeWithSelector(AllocationHandler.AllocationHandlerInvalidZeroAllocationId.selector));
9898
subgraphService.startService(users.indexer, data);
9999
}
100100

@@ -110,7 +110,7 @@ contract SubgraphServiceAllocationStartTest is SubgraphServiceTest {
110110
bytes memory data = abi.encode(subgraphDeployment, tokens, allocationId, abi.encodePacked(r, s, v));
111111
vm.expectRevert(
112112
abi.encodeWithSelector(
113-
IAllocationManager.AllocationManagerInvalidAllocationProof.selector,
113+
AllocationHandler.AllocationHandlerInvalidAllocationProof.selector,
114114
signer,
115115
allocationId
116116
)

packages/subgraph-service/test/unit/subgraphService/collect/collect.t.sol

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ pragma solidity ^0.8.27;
33

44
import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol";
55

6-
import { ISubgraphService } from "@graphprotocol/interfaces/contracts/subgraph-service/ISubgraphService.sol";
6+
import { IndexingAgreementDecoder } from "../../../../contracts/libraries/IndexingAgreementDecoder.sol";
77
import { SubgraphServiceTest } from "../SubgraphService.t.sol";
88

99
contract SubgraphServiceCollectTest is SubgraphServiceTest {
@@ -14,10 +14,14 @@ contract SubgraphServiceCollectTest is SubgraphServiceTest {
1414
function test_SubgraphService_Collect_RevertWhen_InvalidPayment(
1515
uint256 tokens
1616
) public useIndexer useAllocation(tokens) {
17-
IGraphPayments.PaymentTypes invalidPaymentType = IGraphPayments.PaymentTypes.IndexingFee;
17+
IGraphPayments.PaymentTypes paymentType = IGraphPayments.PaymentTypes.IndexingFee;
1818
vm.expectRevert(
19-
abi.encodeWithSelector(ISubgraphService.SubgraphServiceInvalidPaymentType.selector, invalidPaymentType)
19+
abi.encodeWithSelector(
20+
IndexingAgreementDecoder.IndexingAgreementDecoderInvalidData.selector,
21+
"decodeCollectData",
22+
""
23+
)
2024
);
21-
subgraphService.collect(users.indexer, invalidPaymentType, "");
25+
subgraphService.collect(users.indexer, paymentType, "");
2226
}
2327
}

packages/subgraph-service/test/unit/subgraphService/collect/indexing/indexing.t.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
pragma solidity ^0.8.27;
33

44
import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol";
5-
import { IAllocationManager } from "@graphprotocol/interfaces/contracts/subgraph-service/internal/IAllocationManager.sol";
5+
import { AllocationHandler } from "../../../../../contracts/libraries/AllocationHandler.sol";
66
import { IRewardsManager } from "@graphprotocol/interfaces/contracts/contracts/rewards/IRewardsManager.sol";
77

88
import { ISubgraphService } from "@graphprotocol/interfaces/contracts/subgraph-service/ISubgraphService.sol";
@@ -270,7 +270,7 @@ contract SubgraphServiceCollectIndexingTest is SubgraphServiceTest {
270270

271271
// Attempt to collect on closed allocation should revert
272272
vm.expectRevert(
273-
abi.encodeWithSelector(IAllocationManager.AllocationManagerAllocationClosed.selector, allocationId)
273+
abi.encodeWithSelector(AllocationHandler.AllocationHandlerAllocationClosed.selector, allocationId)
274274
);
275275
subgraphService.collect(users.indexer, paymentType, data);
276276
}

packages/subgraph-service/test/unit/subgraphService/indexing-agreement/integration.t.sol

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,21 +110,26 @@ contract SubgraphServiceIndexingAgreementIntegrationTest is SubgraphServiceIndex
110110
IndexerState memory indexerState = _withIndexer(ctx);
111111
(, bytes16 agreementId) = _withAcceptedIndexingAgreement(ctx, indexerState);
112112

113+
// Ensure enough gap so that reward distribution (1% of tokens) doesn't undo the over-allocation
114+
vm.assume(indexerState.tokens > MINIMUM_PROVISION_TOKENS * 2);
115+
113116
// Reduce indexer's provision to force over-allocation after collecting rewards
114-
uint256 extraTokens = indexerState.tokens - minimumProvisionTokens;
115-
vm.assume(extraTokens > 0);
117+
uint256 extraTokens = indexerState.tokens - MINIMUM_PROVISION_TOKENS;
116118
_removeTokensFromProvision(indexerState, extraTokens);
117119

118120
// Verify indexer will be over-allocated after presenting POI
119121
assertTrue(subgraphService.isOverAllocated(indexerState.addr));
120122

123+
// Advance past allocation creation epoch so POI is not considered "too young"
124+
vm.roll(block.number + EPOCH_LENGTH);
125+
121126
// Collect indexing rewards - this should trigger allocation closure and agreement cancellation
122127
bytes memory collectData = abi.encode(indexerState.allocationId, bytes32("poi"), bytes("metadata"));
123128
resetPrank(indexerState.addr);
124129
subgraphService.collect(indexerState.addr, IGraphPayments.PaymentTypes.IndexingRewards, collectData);
125130

126131
// Verify the indexing agreement was properly cancelled
127-
IndexingAgreement.AgreementWrapper memory agreement = subgraphService.getIndexingAgreement(agreementId);
132+
IIndexingAgreement.AgreementWrapper memory agreement = subgraphService.getIndexingAgreement(agreementId);
128133
assertEq(
129134
uint8(agreement.collectorAgreement.state),
130135
uint8(IRecurringCollector.AgreementState.CanceledByServiceProvider)

0 commit comments

Comments
 (0)