@@ -80,19 +80,6 @@ contract HorizonStakingProvisionTest is HorizonStakingTest {
80
80
staking.provision (users.indexer, subgraphDataServiceAddress, amount / 2 , maxVerifierCut, thawingPeriod);
81
81
}
82
82
83
- function testProvision_OperatorAddTokensToProvision (
84
- uint256 amount ,
85
- uint32 maxVerifierCut ,
86
- uint64 thawingPeriod ,
87
- uint256 tokensToAdd
88
- ) public useIndexer useProvision (amount, maxVerifierCut, thawingPeriod) useOperator {
89
- tokensToAdd = bound (tokensToAdd, 1 , MAX_STAKING_TOKENS);
90
-
91
- // Add more tokens to the provision
92
- _stakeTo (users.indexer, tokensToAdd);
93
- _addToProvision (users.indexer, subgraphDataServiceAddress, tokensToAdd);
94
- }
95
-
96
83
function testProvision_RevertWhen_OperatorNotAuthorized (
97
84
uint256 amount ,
98
85
uint32 maxVerifierCut ,
@@ -124,4 +111,113 @@ contract HorizonStakingProvisionTest is HorizonStakingTest {
124
111
vm.expectRevert (expectedError);
125
112
staking.provision (users.indexer, subgraphDataServiceAddress, amount, 0 , 0 );
126
113
}
114
+
115
+ function testProvision_AddTokensToProvision (
116
+ uint256 amount ,
117
+ uint32 maxVerifierCut ,
118
+ uint64 thawingPeriod ,
119
+ uint256 tokensToAdd
120
+ ) public useIndexer useProvision (amount, maxVerifierCut, thawingPeriod) {
121
+ tokensToAdd = bound (tokensToAdd, 1 , MAX_STAKING_TOKENS);
122
+
123
+ // Add more tokens to the provision
124
+ _stakeTo (users.indexer, tokensToAdd);
125
+ _addToProvision (users.indexer, subgraphDataServiceAddress, tokensToAdd);
126
+ }
127
+
128
+ function testProvision_OperatorAddTokensToProvision (
129
+ uint256 amount ,
130
+ uint32 maxVerifierCut ,
131
+ uint64 thawingPeriod ,
132
+ uint256 tokensToAdd
133
+ ) public useIndexer useProvision (amount, maxVerifierCut, thawingPeriod) useOperator {
134
+ tokensToAdd = bound (tokensToAdd, 1 , MAX_STAKING_TOKENS);
135
+
136
+ // Add more tokens to the provision
137
+ _stakeTo (users.indexer, tokensToAdd);
138
+ _addToProvision (users.indexer, subgraphDataServiceAddress, tokensToAdd);
139
+ }
140
+
141
+ function testProvision_AddTokensToProvision_RevertWhen_NotAuthorized (
142
+ uint256 amount ,
143
+ uint32 maxVerifierCut ,
144
+ uint64 thawingPeriod ,
145
+ uint256 tokensToAdd
146
+ ) public useIndexer useProvision (amount, maxVerifierCut, thawingPeriod) {
147
+ tokensToAdd = bound (tokensToAdd, 1 , MAX_STAKING_TOKENS);
148
+
149
+ // Add more tokens to the provision
150
+ _stakeTo (users.indexer, tokensToAdd);
151
+
152
+ // use delegator as a non authorized operator
153
+ vm.startPrank (users.delegator);
154
+ bytes memory expectedError = abi.encodeWithSignature (
155
+ "HorizonStakingNotAuthorized(address,address,address) " ,
156
+ users.indexer,
157
+ subgraphDataServiceAddress,
158
+ users.delegator
159
+ );
160
+ vm.expectRevert (expectedError);
161
+ staking.addToProvision (users.indexer, subgraphDataServiceAddress, amount);
162
+ }
163
+
164
+ function testProvision_StakeToProvision (
165
+ uint256 amount ,
166
+ uint32 maxVerifierCut ,
167
+ uint64 thawingPeriod ,
168
+ uint256 tokensToAdd
169
+ ) public useIndexer useProvision (amount, maxVerifierCut, thawingPeriod) {
170
+ tokensToAdd = bound (tokensToAdd, 1 , MAX_STAKING_TOKENS);
171
+
172
+ // Add more tokens to the provision
173
+ _stakeToProvision (users.indexer, subgraphDataServiceAddress, tokensToAdd);
174
+ }
175
+
176
+ function testProvision_Operator_StakeToProvision (
177
+ uint256 amount ,
178
+ uint32 maxVerifierCut ,
179
+ uint64 thawingPeriod ,
180
+ uint256 tokensToAdd
181
+ ) public useIndexer useProvision (amount, maxVerifierCut, thawingPeriod) useOperator {
182
+ tokensToAdd = bound (tokensToAdd, 1 , MAX_STAKING_TOKENS);
183
+
184
+ // Add more tokens to the provision
185
+ _stakeToProvision (users.indexer, subgraphDataServiceAddress, tokensToAdd);
186
+ }
187
+
188
+ function testProvision_Verifier_StakeToProvision (
189
+ uint256 amount ,
190
+ uint32 maxVerifierCut ,
191
+ uint64 thawingPeriod ,
192
+ uint256 tokensToAdd
193
+ ) public useIndexer useProvision (amount, maxVerifierCut, thawingPeriod) {
194
+ tokensToAdd = bound (tokensToAdd, 1 , MAX_STAKING_TOKENS);
195
+
196
+ // Ensure the verifier has enough tokens to then stake to the provision
197
+ token.transfer (subgraphDataServiceAddress, tokensToAdd);
198
+
199
+ // Add more tokens to the provision
200
+ resetPrank (subgraphDataServiceAddress);
201
+ _stakeToProvision (users.indexer, subgraphDataServiceAddress, tokensToAdd);
202
+ }
203
+
204
+ function testProvision_StakeToProvision_RevertWhen_NotAuthorized (
205
+ uint256 amount ,
206
+ uint32 maxVerifierCut ,
207
+ uint64 thawingPeriod ,
208
+ uint256 tokensToAdd
209
+ ) public useIndexer useProvision (amount, maxVerifierCut, thawingPeriod) {
210
+ tokensToAdd = bound (tokensToAdd, 1 , MAX_STAKING_TOKENS);
211
+
212
+ // Add more tokens to the provision
213
+ vm.startPrank (users.delegator);
214
+ bytes memory expectedError = abi.encodeWithSignature (
215
+ "HorizonStakingNotAuthorized(address,address,address) " ,
216
+ users.indexer,
217
+ subgraphDataServiceAddress,
218
+ users.delegator
219
+ );
220
+ vm.expectRevert (expectedError);
221
+ staking.stakeToProvision (users.indexer, subgraphDataServiceAddress, tokensToAdd);
222
+ }
127
223
}
0 commit comments