1
1
// SPDX-License-Identifier: MIT
2
2
pragma solidity 0.8.27 ;
3
3
4
- import { IGraphPayments } from "../../../../contracts/interfaces/IGraphPayments.sol " ;
5
-
6
4
import { IRecurringCollector } from "../../../../contracts/interfaces/IRecurringCollector.sol " ;
7
5
8
6
import { RecurringCollectorSharedTest } from "./shared.t.sol " ;
@@ -14,32 +12,14 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest {
14
12
15
13
/* solhint-disable graph/func-name-mixedcase */
16
14
17
- function test_Collect_Revert_WhenInvalidPaymentType (uint8 unboundedPaymentType , bytes memory data ) public {
18
- IGraphPayments.PaymentTypes paymentType = IGraphPayments.PaymentTypes (
19
- bound (
20
- unboundedPaymentType,
21
- uint256 (type (IGraphPayments.PaymentTypes).min),
22
- uint256 (type (IGraphPayments.PaymentTypes).max)
23
- )
24
- );
25
- vm.assume (paymentType != IGraphPayments.PaymentTypes.IndexingFee);
26
-
27
- bytes memory expectedErr = abi.encodeWithSelector (
28
- IRecurringCollector.RecurringCollectorInvalidPaymentType.selector ,
29
- paymentType
30
- );
31
- vm.expectRevert (expectedErr);
32
- _recurringCollector.collect (paymentType, data);
33
- }
34
-
35
- function test_Collect_Revert_WhenInvalidData (address caller , bytes memory data ) public {
15
+ function test_Collect_Revert_WhenInvalidData (address caller , uint8 unboundedPaymentType , bytes memory data ) public {
36
16
bytes memory expectedErr = abi.encodeWithSelector (
37
17
IRecurringCollector.RecurringCollectorInvalidCollectData.selector ,
38
18
data
39
19
);
40
20
vm.expectRevert (expectedErr);
41
21
vm.prank (caller);
42
- _recurringCollector.collect (IGraphPayments.PaymentTypes.IndexingFee , data);
22
+ _recurringCollector.collect (_paymentType (unboundedPaymentType) , data);
43
23
}
44
24
45
25
function test_Collect_Revert_WhenCallerNotDataService (
@@ -61,7 +41,7 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest {
61
41
);
62
42
vm.expectRevert (expectedErr);
63
43
vm.prank (notDataService);
64
- _recurringCollector.collect (IGraphPayments.PaymentTypes.IndexingFee , data);
44
+ _recurringCollector.collect (_paymentType (fuzzy.unboundedPaymentType) , data);
65
45
}
66
46
67
47
function test_Collect_Revert_WhenUnknownAgreement (FuzzyTestCollect memory fuzzy , address dataService ) public {
@@ -74,7 +54,7 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest {
74
54
);
75
55
vm.expectRevert (expectedErr);
76
56
vm.prank (dataService);
77
- _recurringCollector.collect (IGraphPayments.PaymentTypes.IndexingFee , data);
57
+ _recurringCollector.collect (_paymentType (fuzzy.unboundedPaymentType) , data);
78
58
}
79
59
80
60
function test_Collect_Revert_WhenCanceledAgreementByServiceProvider (FuzzyTestCollect calldata fuzzy ) public {
@@ -97,7 +77,7 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest {
97
77
);
98
78
vm.expectRevert (expectedErr);
99
79
vm.prank (accepted.rca.dataService);
100
- _recurringCollector.collect (IGraphPayments.PaymentTypes.IndexingFee , data);
80
+ _recurringCollector.collect (_paymentType (fuzzy.unboundedPaymentType) , data);
101
81
}
102
82
103
83
function test_Collect_Revert_WhenCollectingTooSoon (
@@ -116,7 +96,7 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest {
116
96
)
117
97
);
118
98
vm.prank (accepted.rca.dataService);
119
- _recurringCollector.collect (IGraphPayments.PaymentTypes.IndexingFee , data);
99
+ _recurringCollector.collect (_paymentType (fuzzy.unboundedPaymentType) , data);
120
100
121
101
uint256 collectionSeconds = boundSkip (unboundedCollectionSeconds, 1 , accepted.rca.minSecondsPerCollection - 1 );
122
102
skip (collectionSeconds);
@@ -136,7 +116,7 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest {
136
116
);
137
117
vm.expectRevert (expectedErr);
138
118
vm.prank (accepted.rca.dataService);
139
- _recurringCollector.collect (IGraphPayments.PaymentTypes.IndexingFee , data);
119
+ _recurringCollector.collect (_paymentType (fuzzy.unboundedPaymentType) , data);
140
120
}
141
121
142
122
function test_Collect_Revert_WhenCollectingTooLate (
@@ -163,7 +143,7 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest {
163
143
)
164
144
);
165
145
vm.prank (accepted.rca.dataService);
166
- _recurringCollector.collect (IGraphPayments.PaymentTypes.IndexingFee , data);
146
+ _recurringCollector.collect (_paymentType (fuzzy.unboundedPaymentType) , data);
167
147
168
148
// skip beyond collectable time but still within the agreement endsAt
169
149
uint256 collectionSeconds = boundSkip (
@@ -189,7 +169,7 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest {
189
169
);
190
170
vm.expectRevert (expectedErr);
191
171
vm.prank (accepted.rca.dataService);
192
- _recurringCollector.collect (IGraphPayments.PaymentTypes.IndexingFee , data);
172
+ _recurringCollector.collect (_paymentType (fuzzy.unboundedPaymentType) , data);
193
173
}
194
174
195
175
function test_Collect_OK_WhenCollectingTooMuch (
@@ -219,7 +199,7 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest {
219
199
)
220
200
);
221
201
vm.prank (accepted.rca.dataService);
222
- _recurringCollector.collect (IGraphPayments.PaymentTypes.IndexingFee , initialData);
202
+ _recurringCollector.collect (_paymentType (fuzzy.unboundedPaymentType) , initialData);
223
203
}
224
204
225
205
// skip to collectable time
@@ -240,7 +220,7 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest {
240
220
);
241
221
bytes memory data = _generateCollectData (collectParams);
242
222
vm.prank (accepted.rca.dataService);
243
- uint256 collected = _recurringCollector.collect (IGraphPayments.PaymentTypes.IndexingFee , data);
223
+ uint256 collected = _recurringCollector.collect (_paymentType (fuzzy.unboundedPaymentType) , data);
244
224
assertEq (collected, maxTokens);
245
225
}
246
226
@@ -258,9 +238,9 @@ contract RecurringCollectorCollectTest is RecurringCollectorSharedTest {
258
238
unboundedTokens
259
239
);
260
240
skip (collectionSeconds);
261
- _expectCollectCallAndEmit (accepted.rca, fuzzy.collectParams, tokens);
241
+ _expectCollectCallAndEmit (accepted.rca, _paymentType (fuzzy.unboundedPaymentType), fuzzy.collectParams, tokens);
262
242
vm.prank (accepted.rca.dataService);
263
- uint256 collected = _recurringCollector.collect (IGraphPayments.PaymentTypes.IndexingFee , data);
243
+ uint256 collected = _recurringCollector.collect (_paymentType (fuzzy.unboundedPaymentType) , data);
264
244
assertEq (collected, tokens);
265
245
}
266
246
/* solhint-enable graph/func-name-mixedcase */
0 commit comments