@@ -3,38 +3,30 @@ pragma solidity 0.8.27;
3
3
4
4
import "forge-std/Test.sol " ;
5
5
6
- import { IDataService } from "@graphprotocol/horizon/contracts/data-service/interfaces/IDataService.sol " ;
7
6
import { IGraphPayments } from "@graphprotocol/horizon/contracts/interfaces/IGraphPayments.sol " ;
8
- import { ProvisionManager } from "@graphprotocol/horizon/contracts/data-service/utilities/ProvisionManager.sol " ;
9
- import { ProvisionTracker } from "@graphprotocol/horizon/contracts/data-service/libraries/ProvisionTracker.sol " ;
10
7
11
8
import { Allocation } from "../../../contracts/libraries/Allocation.sol " ;
12
- import { AllocationManager } from "../../../contracts/utilities/AllocationManager.sol " ;
13
9
import { ISubgraphService } from "../../../contracts/interfaces/ISubgraphService.sol " ;
14
- import { LegacyAllocation } from "../../../contracts/libraries/LegacyAllocation.sol " ;
15
10
import { SubgraphServiceTest } from "../SubgraphService.t.sol " ;
16
11
17
12
contract SubgraphServiceAllocationForceCloseTest is SubgraphServiceTest {
18
-
19
13
address private permissionlessBob = makeAddr ("permissionlessBob " );
20
14
21
15
/*
22
16
* TESTS
23
17
*/
24
18
25
- function test_SubgraphService_Allocation_ForceClose_Stale (
26
- uint256 tokens
27
- ) public useIndexer useAllocation (tokens) {
19
+ function test_SubgraphService_Allocation_ForceClose_Stale (uint256 tokens ) public useIndexer useAllocation (tokens) {
28
20
// Skip forward
29
21
skip (maxPOIStaleness + 1 );
30
22
31
23
resetPrank (permissionlessBob);
32
- _forceCloseAllocation (allocationID);
24
+ _closeStaleAllocation (allocationID);
33
25
}
34
26
35
27
function test_SubgraphService_Allocation_ForceClose_Stale_AfterCollecting (
36
28
uint256 tokens
37
- ) public useIndexer useAllocation (tokens) {
29
+ ) public useIndexer useAllocation (tokens) {
38
30
// Simulate POIs being submitted
39
31
uint8 numberOfPOIs = 5 ;
40
32
uint256 timeBetweenPOIs = 5 days ;
@@ -52,43 +44,10 @@ contract SubgraphServiceAllocationForceCloseTest is SubgraphServiceTest {
52
44
53
45
// Close the stale allocation
54
46
resetPrank (permissionlessBob);
55
- _forceCloseAllocation (allocationID);
56
- }
57
-
58
- function test_SubgraphService_Allocation_ForceClose_OverAllocated (
59
- uint256 tokens
60
- ) public useIndexer useAllocation (tokens) {
61
- // thaw some tokens to become over allocated
62
- staking.thaw (users.indexer, address (subgraphService), tokens / 2 );
63
-
64
- resetPrank (permissionlessBob);
65
- _forceCloseAllocation (allocationID);
66
- }
67
-
68
- function test_SubgraphService_Allocation_ForceClose_OverAllocated_AfterCollecting (
69
- uint256 tokens
70
- ) public useIndexer useAllocation (tokens) {
71
- // Simulate POIs being submitted
72
- uint8 numberOfPOIs = 5 ;
73
- uint256 timeBetweenPOIs = 5 days ;
74
-
75
- for (uint8 i = 0 ; i < numberOfPOIs; i++ ) {
76
- // Skip forward
77
- skip (timeBetweenPOIs);
78
-
79
- bytes memory data = abi.encode (allocationID, bytes32 ("POI1 " ));
80
- _collect (users.indexer, IGraphPayments.PaymentTypes.IndexingRewards, data);
81
- }
82
-
83
- // thaw some tokens to become over allocated
84
- staking.thaw (users.indexer, address (subgraphService), tokens / 2 );
85
-
86
- // Close the over allocated allocation
87
- resetPrank (permissionlessBob);
88
- _forceCloseAllocation (allocationID);
47
+ _closeStaleAllocation (allocationID);
89
48
}
90
49
91
- function test_SubgraphService_Allocation_ForceClose_RevertIf_NotStaleOrOverAllocated (
50
+ function test_SubgraphService_Allocation_ForceClose_RevertIf_NotStale (
92
51
uint256 tokens
93
52
) public useIndexer useAllocation (tokens) {
94
53
// Simulate POIs being submitted
@@ -98,26 +57,24 @@ contract SubgraphServiceAllocationForceCloseTest is SubgraphServiceTest {
98
57
for (uint8 i = 0 ; i < numberOfPOIs; i++ ) {
99
58
// Skip forward
100
59
skip (timeBetweenPOIs);
101
-
60
+
102
61
resetPrank (users.indexer);
103
62
104
63
bytes memory data = abi.encode (allocationID, bytes32 ("POI1 " ));
105
64
_collect (users.indexer, IGraphPayments.PaymentTypes.IndexingRewards, data);
106
-
65
+
107
66
resetPrank (permissionlessBob);
108
67
vm.expectRevert (
109
68
abi.encodeWithSelector (
110
69
ISubgraphService.SubgraphServiceCannotForceCloseAllocation.selector ,
111
70
allocationID
112
71
)
113
72
);
114
- subgraphService.forceCloseAllocation (allocationID);
73
+ subgraphService.closeStaleAllocation (allocationID);
115
74
}
116
75
}
117
76
118
- function test_SubgraphService_Allocation_ForceClose_RevertIf_Altruistic (
119
- uint256 tokens
120
- ) public useIndexer {
77
+ function test_SubgraphService_Allocation_ForceClose_RevertIf_Altruistic (uint256 tokens ) public useIndexer {
121
78
tokens = bound (tokens, minimumProvisionTokens, MAX_TOKENS);
122
79
123
80
_createProvision (users.indexer, tokens, maxSlashingPercentage, disputePeriod);
@@ -130,11 +87,8 @@ contract SubgraphServiceAllocationForceCloseTest is SubgraphServiceTest {
130
87
131
88
resetPrank (permissionlessBob);
132
89
vm.expectRevert (
133
- abi.encodeWithSelector (
134
- ISubgraphService.SubgraphServiceAllocationIsAltruistic.selector ,
135
- allocationID
136
- )
90
+ abi.encodeWithSelector (ISubgraphService.SubgraphServiceAllocationIsAltruistic.selector , allocationID)
137
91
);
138
- subgraphService.forceCloseAllocation (allocationID);
92
+ subgraphService.closeStaleAllocation (allocationID);
139
93
}
140
94
}
0 commit comments