Skip to content

Commit 9742dd8

Browse files
committed
chore: rename test constants to UPPER_SNAKE_CASE and update imports
1 parent 26c6c44 commit 9742dd8

10 files changed

Lines changed: 65 additions & 58 deletions

File tree

packages/subgraph-service/test/unit/SubgraphBaseTest.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ abstract contract SubgraphBaseTest is Utils, Constants {
158158
"RecurringCollector",
159159
"1",
160160
address(controller),
161-
revokeSignerThawingPeriod
161+
REVOKE_SIGNER_THAWING_PERIOD
162162
);
163163

164164
address subgraphServiceImplementation = address(

packages/subgraph-service/test/unit/libraries/IndexingAgreement.t.sol

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

44
import { Test } from "forge-std/Test.sol";
55

6-
import { IRecurringCollector } from "@graphprotocol/horizon/contracts/interfaces/IRecurringCollector.sol";
6+
import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol";
7+
import { IIndexingAgreement } from "@graphprotocol/interfaces/contracts/subgraph-service/internal/IIndexingAgreement.sol";
78
import { IndexingAgreement } from "../../../contracts/libraries/IndexingAgreement.sol";
89
import { Directory } from "../../../contracts/utilities/Directory.sol";
910

@@ -41,7 +42,7 @@ contract IndexingAgreementTest is Test {
4142
abi.encode(collectorAgreement)
4243
);
4344

44-
IndexingAgreement.AgreementWrapper memory wrapper = IndexingAgreement.get(_storageManager, agreementId);
45+
IIndexingAgreement.AgreementWrapper memory wrapper = IndexingAgreement.get(_storageManager, agreementId);
4546
assertEq(wrapper.collectorAgreement.dataService, address(this));
4647
}
4748

@@ -78,9 +79,9 @@ contract IndexingAgreementTest is Test {
7879
collectorAgreement.dataService = address(this);
7980
collectorAgreement.state = IRecurringCollector.AgreementState.Accepted;
8081

81-
_storageManager.agreements[agreementId] = IndexingAgreement.State({
82+
_storageManager.agreements[agreementId] = IIndexingAgreement.State({
8283
allocationId: allocationId,
83-
version: IndexingAgreement.IndexingAgreementVersion.V1
84+
version: IIndexingAgreement.IndexingAgreementVersion.V1
8485
});
8586

8687
vm.mockCall(

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { IAllocation } from "@graphprotocol/interfaces/contracts/subgraph-servic
1414
import { IAllocationManager } from "@graphprotocol/interfaces/contracts/subgraph-service/internal/IAllocationManager.sol";
1515
import { ILinkedList } from "@graphprotocol/interfaces/contracts/horizon/internal/ILinkedList.sol";
1616
import { ILegacyAllocation } from "@graphprotocol/interfaces/contracts/subgraph-service/internal/ILegacyAllocation.sol";
17+
import { StakeClaims } from "@graphprotocol/horizon/contracts/data-service/libraries/StakeClaims.sol";
1718

1819
import { Allocation } from "../../../contracts/libraries/Allocation.sol";
1920
import { SubgraphServiceSharedTest } from "../shared/SubgraphServiceShared.t.sol";

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

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ pragma solidity 0.8.33;
33

44
import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol";
55
import { ProvisionManager } from "@graphprotocol/horizon/contracts/data-service/utilities/ProvisionManager.sol";
6-
import { IRecurringCollector } from "@graphprotocol/horizon/contracts/interfaces/IRecurringCollector.sol";
6+
import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol";
7+
import { IAllocation } from "@graphprotocol/interfaces/contracts/subgraph-service/internal/IAllocation.sol";
78

89
import { Allocation } from "../../../../contracts/libraries/Allocation.sol";
910
import { IndexingAgreement } from "../../../../contracts/libraries/IndexingAgreement.sol";
1011
import { IndexingAgreementDecoder } from "../../../../contracts/libraries/IndexingAgreementDecoder.sol";
1112
import { AllocationHandler } from "../../../../contracts/libraries/AllocationHandler.sol";
12-
import { ISubgraphService } from "../../../../contracts/interfaces/ISubgraphService.sol";
13+
import { ISubgraphService } from "@graphprotocol/interfaces/contracts/subgraph-service/ISubgraphService.sol";
1314

1415
import { SubgraphServiceIndexingAgreementSharedTest } from "./shared.t.sol";
1516

@@ -54,18 +55,18 @@ contract SubgraphServiceIndexingAgreementAcceptTest is SubgraphServiceIndexingAg
5455
address allocationId,
5556
IRecurringCollector.SignedRCA memory signedRCA
5657
) public withSafeIndexerOrOperator(indexer) {
57-
uint256 tokens = bound(unboundedTokens, 1, minimumProvisionTokens - 1);
58+
uint256 tokens = bound(unboundedTokens, 1, MINIMUM_PROVISION_TOKENS - 1);
5859
mint(indexer, tokens);
5960
resetPrank(indexer);
60-
_createProvision(indexer, tokens, fishermanRewardPercentage, disputePeriod);
61+
_createProvision(indexer, tokens, FISHERMAN_REWARD_PERCENTAGE, DISPUTE_PERIOD);
6162

6263
signedRCA.rca.serviceProvider = indexer;
6364
bytes memory expectedErr = abi.encodeWithSelector(
6465
ProvisionManager.ProvisionManagerInvalidValue.selector,
6566
"tokens",
6667
tokens,
67-
minimumProvisionTokens,
68-
maximumProvisionTokens
68+
MINIMUM_PROVISION_TOKENS,
69+
MAXIMUM_PROVISION_TOKENS
6970
);
7071
vm.expectRevert(expectedErr);
7172
subgraphService.acceptIndexingAgreement(allocationId, signedRCA);
@@ -77,10 +78,10 @@ contract SubgraphServiceIndexingAgreementAcceptTest is SubgraphServiceIndexingAg
7778
address allocationId,
7879
IRecurringCollector.SignedRCA memory signedRCA
7980
) public withSafeIndexerOrOperator(indexer) {
80-
uint256 tokens = bound(unboundedTokens, minimumProvisionTokens, MAX_TOKENS);
81+
uint256 tokens = bound(unboundedTokens, MINIMUM_PROVISION_TOKENS, MAX_TOKENS);
8182
mint(indexer, tokens);
8283
resetPrank(indexer);
83-
_createProvision(indexer, tokens, fishermanRewardPercentage, disputePeriod);
84+
_createProvision(indexer, tokens, FISHERMAN_REWARD_PERCENTAGE, DISPUTE_PERIOD);
8485
signedRCA.rca.serviceProvider = indexer;
8586
bytes memory expectedErr = abi.encodeWithSelector(
8687
ISubgraphService.SubgraphServiceIndexerNotRegistered.selector,
@@ -144,7 +145,7 @@ contract SubgraphServiceIndexingAgreementAcceptTest is SubgraphServiceIndexingAg
144145
IRecurringCollector.SignedRCA memory acceptable = _generateAcceptableSignedRCA(ctx, indexerState.addr);
145146

146147
bytes memory expectedErr = abi.encodeWithSelector(
147-
Allocation.AllocationDoesNotExist.selector,
148+
IAllocation.AllocationDoesNotExist.selector,
148149
invalidAllocationId
149150
);
150151
vm.expectRevert(expectedErr);

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
pragma solidity 0.8.33;
33

44
import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
5-
import { IRecurringCollector } from "@graphprotocol/horizon/contracts/interfaces/IRecurringCollector.sol";
5+
import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol";
6+
import { IIndexingAgreement } from "@graphprotocol/interfaces/contracts/subgraph-service/internal/IIndexingAgreement.sol";
67

78
import { IndexingAgreement } from "../../../../contracts/libraries/IndexingAgreement.sol";
89
import { SubgraphServiceIndexingAgreementSharedTest } from "./shared.t.sol";
@@ -35,7 +36,7 @@ contract SubgraphServiceIndexingAgreementBaseTest is SubgraphServiceIndexingAgre
3536
ctx,
3637
indexerState
3738
);
38-
IndexingAgreement.AgreementWrapper memory agreement = subgraphService.getIndexingAgreement(agreementId);
39+
IIndexingAgreement.AgreementWrapper memory agreement = subgraphService.getIndexingAgreement(agreementId);
3940
_assertEqualAgreement(accepted.rca, agreement);
4041
}
4142

@@ -52,11 +53,11 @@ contract SubgraphServiceIndexingAgreementBaseTest is SubgraphServiceIndexingAgre
5253
address indexer = GRAPH_PROXY_ADMIN_ADDRESS;
5354
assertFalse(_isSafeSubgraphServiceCaller(indexer));
5455

55-
uint256 tokens = bound(unboundedTokens, minimumProvisionTokens, MAX_TOKENS);
56+
uint256 tokens = bound(unboundedTokens, MINIMUM_PROVISION_TOKENS, MAX_TOKENS);
5657
mint(indexer, tokens);
5758
resetPrank(indexer);
5859
vm.expectRevert("Cannot fallback to proxy target");
59-
staking.provision(indexer, address(subgraphService), tokens, maxSlashingPercentage, disputePeriod);
60+
staking.provision(indexer, address(subgraphService), tokens, FISHERMAN_REWARD_PERCENTAGE, DISPUTE_PERIOD);
6061
}
6162

6263
/* solhint-enable graph/func-name-mixedcase */

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity 0.8.33;
33

4-
import { IRecurringCollector } from "@graphprotocol/horizon/contracts/interfaces/IRecurringCollector.sol";
4+
import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol";
55
import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol";
66
import { ProvisionManager } from "@graphprotocol/horizon/contracts/data-service/utilities/ProvisionManager.sol";
77

8-
import { ISubgraphService } from "../../../../contracts/interfaces/ISubgraphService.sol";
8+
import { ISubgraphService } from "@graphprotocol/interfaces/contracts/subgraph-service/ISubgraphService.sol";
99
import { IndexingAgreement } from "../../../../contracts/libraries/IndexingAgreement.sol";
1010

1111
import { SubgraphServiceIndexingAgreementSharedTest } from "./shared.t.sol";
@@ -138,17 +138,17 @@ contract SubgraphServiceIndexingAgreementCancelTest is SubgraphServiceIndexingAg
138138
bytes16 agreementId,
139139
uint256 unboundedTokens
140140
) public withSafeIndexerOrOperator(indexer) {
141-
uint256 tokens = bound(unboundedTokens, 1, minimumProvisionTokens - 1);
141+
uint256 tokens = bound(unboundedTokens, 1, MINIMUM_PROVISION_TOKENS - 1);
142142
mint(indexer, tokens);
143143
resetPrank(indexer);
144-
_createProvision(indexer, tokens, fishermanRewardPercentage, disputePeriod);
144+
_createProvision(indexer, tokens, FISHERMAN_REWARD_PERCENTAGE, DISPUTE_PERIOD);
145145

146146
bytes memory expectedErr = abi.encodeWithSelector(
147147
ProvisionManager.ProvisionManagerInvalidValue.selector,
148148
"tokens",
149149
tokens,
150-
minimumProvisionTokens,
151-
maximumProvisionTokens
150+
MINIMUM_PROVISION_TOKENS,
151+
MAXIMUM_PROVISION_TOKENS
152152
);
153153
vm.expectRevert(expectedErr);
154154
subgraphService.cancelIndexingAgreement(indexer, agreementId);
@@ -159,10 +159,10 @@ contract SubgraphServiceIndexingAgreementCancelTest is SubgraphServiceIndexingAg
159159
bytes16 agreementId,
160160
uint256 unboundedTokens
161161
) public withSafeIndexerOrOperator(indexer) {
162-
uint256 tokens = bound(unboundedTokens, minimumProvisionTokens, MAX_TOKENS);
162+
uint256 tokens = bound(unboundedTokens, MINIMUM_PROVISION_TOKENS, MAX_TOKENS);
163163
mint(indexer, tokens);
164164
resetPrank(indexer);
165-
_createProvision(indexer, tokens, fishermanRewardPercentage, disputePeriod);
165+
_createProvision(indexer, tokens, FISHERMAN_REWARD_PERCENTAGE, DISPUTE_PERIOD);
166166
bytes memory expectedErr = abi.encodeWithSelector(
167167
ISubgraphService.SubgraphServiceIndexerNotRegistered.selector,
168168
indexer

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

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity 0.8.33;
33

4-
import { IGraphPayments } from "@graphprotocol/horizon/contracts/interfaces/IGraphPayments.sol";
5-
import { IRecurringCollector } from "@graphprotocol/horizon/contracts/interfaces/IRecurringCollector.sol";
6-
import { IPaymentsCollector } from "@graphprotocol/horizon/contracts/interfaces/IPaymentsCollector.sol";
4+
import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol";
5+
import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol";
6+
import { IPaymentsCollector } from "@graphprotocol/interfaces/contracts/horizon/IPaymentsCollector.sol";
77
import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol";
88
import { ProvisionManager } from "@graphprotocol/horizon/contracts/data-service/utilities/ProvisionManager.sol";
99

10-
import { ISubgraphService } from "../../../../contracts/interfaces/ISubgraphService.sol";
10+
import { ISubgraphService } from "@graphprotocol/interfaces/contracts/subgraph-service/ISubgraphService.sol";
11+
import { IAllocation } from "@graphprotocol/interfaces/contracts/subgraph-service/internal/IAllocation.sol";
1112
import { Allocation } from "../../../../contracts/libraries/Allocation.sol";
1213
import { AllocationHandler } from "../../../../contracts/libraries/AllocationHandler.sol";
1314
import { IndexingAgreement } from "../../../../contracts/libraries/IndexingAgreement.sol";
@@ -49,7 +50,7 @@ contract SubgraphServiceIndexingAgreementCollectTest is SubgraphServiceIndexingA
4950
maxSlippage: type(uint256).max
5051
})
5152
);
52-
uint256 tokensCollected = bound(unboundedTokensCollected, 1, indexerState.tokens / stakeToFeesRatio);
53+
uint256 tokensCollected = bound(unboundedTokensCollected, 1, indexerState.tokens / STAKE_TO_FEES_RATIO);
5354

5455
vm.mockCall(
5556
address(recurringCollector),
@@ -68,7 +69,7 @@ contract SubgraphServiceIndexingAgreementCollectTest is SubgraphServiceIndexingA
6869

6970
assertEq(
7071
subgraphService.feesProvisionTracker(indexerState.addr),
71-
tokensCollected * stakeToFeesRatio,
72+
tokensCollected * STAKE_TO_FEES_RATIO,
7273
"Should be exactly locked tokens"
7374
);
7475
}
@@ -122,18 +123,18 @@ contract SubgraphServiceIndexingAgreementCollectTest is SubgraphServiceIndexingA
122123
uint256 entities,
123124
bytes32 poi
124125
) public withSafeIndexerOrOperator(indexer) {
125-
uint256 tokens = bound(unboundedTokens, 1, minimumProvisionTokens - 1);
126+
uint256 tokens = bound(unboundedTokens, 1, MINIMUM_PROVISION_TOKENS - 1);
126127
uint256 currentEpochBlock = epochManager.currentEpochBlock();
127128
mint(indexer, tokens);
128129
resetPrank(indexer);
129-
_createProvision(indexer, tokens, fishermanRewardPercentage, disputePeriod);
130+
_createProvision(indexer, tokens, FISHERMAN_REWARD_PERCENTAGE, DISPUTE_PERIOD);
130131

131132
bytes memory expectedErr = abi.encodeWithSelector(
132133
ProvisionManager.ProvisionManagerInvalidValue.selector,
133134
"tokens",
134135
tokens,
135-
minimumProvisionTokens,
136-
maximumProvisionTokens
136+
MINIMUM_PROVISION_TOKENS,
137+
MAXIMUM_PROVISION_TOKENS
137138
);
138139
vm.expectRevert(expectedErr);
139140
subgraphService.collect(
@@ -150,11 +151,11 @@ contract SubgraphServiceIndexingAgreementCollectTest is SubgraphServiceIndexingA
150151
uint256 entities,
151152
bytes32 poi
152153
) public withSafeIndexerOrOperator(indexer) {
153-
uint256 tokens = bound(unboundedTokens, minimumProvisionTokens, MAX_TOKENS);
154+
uint256 tokens = bound(unboundedTokens, MINIMUM_PROVISION_TOKENS, MAX_TOKENS);
154155
uint256 currentEpochBlock = epochManager.currentEpochBlock();
155156
mint(indexer, tokens);
156157
resetPrank(indexer);
157-
_createProvision(indexer, tokens, fishermanRewardPercentage, disputePeriod);
158+
_createProvision(indexer, tokens, FISHERMAN_REWARD_PERCENTAGE, DISPUTE_PERIOD);
158159
bytes memory expectedErr = abi.encodeWithSelector(
159160
ISubgraphService.SubgraphServiceIndexerNotRegistered.selector,
160161
indexer
@@ -192,7 +193,7 @@ contract SubgraphServiceIndexingAgreementCollectTest is SubgraphServiceIndexingA
192193
IndexerState memory indexerState = _withIndexer(ctx);
193194
uint256 currentEpochBlock = epochManager.currentEpochBlock();
194195

195-
bytes memory expectedErr = abi.encodeWithSelector(Allocation.AllocationDoesNotExist.selector, address(0));
196+
bytes memory expectedErr = abi.encodeWithSelector(IAllocation.AllocationDoesNotExist.selector, address(0));
196197
vm.expectRevert(expectedErr);
197198
resetPrank(indexerState.addr);
198199
subgraphService.collect(
@@ -290,7 +291,7 @@ contract SubgraphServiceIndexingAgreementCollectTest is SubgraphServiceIndexingA
290291
IndexerState memory indexerState = _withIndexer(ctx);
291292
(, bytes16 acceptedAgreementId) = _withAcceptedIndexingAgreement(ctx, indexerState);
292293

293-
skip(maxPOIStaleness + 1);
294+
skip(MAX_POI_STALENESS + 1);
294295
resetPrank(indexerState.addr);
295296
subgraphService.closeStaleAllocation(indexerState.allocationId);
296297

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity 0.8.33;
33

4-
import { IRecurringCollector } from "@graphprotocol/horizon/contracts/interfaces/IRecurringCollector.sol";
5-
import { IGraphPayments } from "@graphprotocol/horizon/contracts/interfaces/IGraphPayments.sol";
4+
import { IRecurringCollector } from "@graphprotocol/interfaces/contracts/horizon/IRecurringCollector.sol";
5+
import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol";
6+
import { IIndexingAgreement } from "@graphprotocol/interfaces/contracts/subgraph-service/internal/IIndexingAgreement.sol";
67
import { PPMMath } from "@graphprotocol/horizon/contracts/libraries/PPMMath.sol";
78

89
import { IndexingAgreement } from "../../../../contracts/libraries/IndexingAgreement.sol";
@@ -179,7 +180,7 @@ contract SubgraphServiceIndexingAgreementIntegrationTest is SubgraphServiceIndex
179180

180181
function _newExpectedTokens(uint256 _fuzzyTokensCollected) internal view returns (ExpectedTokens memory) {
181182
uint256 expectedTotalTokensCollected = bound(_fuzzyTokensCollected, 1000, 1_000_000);
182-
uint256 expectedTokensLocked = stakeToFeesRatio * expectedTotalTokensCollected;
183+
uint256 expectedTokensLocked = STAKE_TO_FEES_RATIO * expectedTotalTokensCollected;
183184
uint256 expectedProtocolTokensBurnt = expectedTotalTokensCollected.mulPPMRoundUp(
184185
graphPayments.PROTOCOL_PAYMENT_CUT()
185186
);

0 commit comments

Comments
 (0)