@@ -134,7 +134,7 @@ contract BasicDataConsumerV3Test is Test {
134
134
currentProposedAggregator = mockAggregator.proposedAggregator ();
135
135
assertEq (currentProposedAggregator, address (newMockOffchainAggregator));
136
136
137
- mockAggregator.confirmAggregator ();
137
+ mockAggregator.confirmAggregator (address (newMockOffchainAggregator) );
138
138
139
139
currentAggregator = mockAggregator.aggregator ();
140
140
currentProposedAggregator = mockAggregator.proposedAggregator ();
@@ -148,7 +148,7 @@ contract BasicDataConsumerV3Test is Test {
148
148
149
149
function test_shouldReturnMinAndMaxAnswers () public {
150
150
int192 minAnswer = 1 ;
151
- int192 maxAnswer = type (int192 ).max;
151
+ int192 maxAnswer = 95780971304118053647396689196894323976171195136475135 ; // type(uint176 ).max
152
152
153
153
int192 resultMinAnswer = mockOffchainAggregator.minAnswer ();
154
154
int192 resultMaxAnswer = mockOffchainAggregator.maxAnswer ();
@@ -169,4 +169,60 @@ contract BasicDataConsumerV3Test is Test {
169
169
assertEq (resultMinAnswer, newMinAnswer);
170
170
assertEq (resultMaxAnswer, newMaxAnswer);
171
171
}
172
+
173
+ function test_shouldRevertIfProposedAggregatorIsZero () public {
174
+ vm.expectRevert ("Proposed aggregator cannot be zero address " );
175
+ mockAggregator.proposeAggregator (AggregatorV2V3Interface (address (0 )));
176
+ }
177
+
178
+ function test_shouldRevertIfProposedAggregatorIsCurrentAggregator () public {
179
+ vm.expectRevert ("Proposed aggregator cannot be current aggregator " );
180
+ mockAggregator.proposeAggregator (AggregatorV2V3Interface (address (mockOffchainAggregator)));
181
+ }
182
+
183
+ function test_shouldRevertIfProposedAggregatorIsNotSet () public {
184
+ vm.expectRevert ("Invalid proposed aggregator " );
185
+ mockAggregator.confirmAggregator (address (1 ));
186
+ }
187
+
188
+ function test_shouldRevertIfProposedAggregatorIsNotCorrect () public {
189
+ int256 newAnswer = 200000000000 ;
190
+ MockOffchainAggregator newMockOffchainAggregator = new MockOffchainAggregator (decimals, newAnswer);
191
+
192
+ mockAggregator.proposeAggregator (AggregatorV2V3Interface (address (newMockOffchainAggregator)));
193
+ vm.expectRevert ("Invalid proposed aggregator " );
194
+ mockAggregator.confirmAggregator (address (1 ));
195
+ }
196
+
197
+ function test_shouldRevertIfMinAnswerIsGreaterThanMaxAnswer () public {
198
+ int192 newMinAnswer = 1.5 ether ;
199
+ int192 newMaxAnswer = 0.5 ether ;
200
+
201
+ vm.expectRevert ("minAnswer must be less than maxAnswer " );
202
+ mockOffchainAggregator.updateMinAndMaxAnswers (newMinAnswer, newMaxAnswer);
203
+ }
204
+
205
+ function test_shouldRevertIfMinAnswerIsEqualToMaxAnswer () public {
206
+ int192 newMinAnswer = 1.5 ether ;
207
+ int192 newMaxAnswer = 1.5 ether ;
208
+
209
+ vm.expectRevert ("minAnswer must be less than maxAnswer " );
210
+ mockOffchainAggregator.updateMinAndMaxAnswers (newMinAnswer, newMaxAnswer);
211
+ }
212
+
213
+ function test_shouldRevertIfMinAnswerIsLessMinAnswerPossible () public {
214
+ int192 newMinAnswer = 0 ;
215
+ int192 newMaxAnswer = 1.5 ether ;
216
+
217
+ vm.expectRevert ("minAnswer is too low " );
218
+ mockOffchainAggregator.updateMinAndMaxAnswers (newMinAnswer, newMaxAnswer);
219
+ }
220
+
221
+ function test_shouldRevertIfMaxAnswerIsGreaterThanMaxAnswerPossible () public {
222
+ int192 newMinAnswer = 0.5 ether ;
223
+ int192 newMaxAnswer = type (int192 ).max;
224
+
225
+ vm.expectRevert ("maxAnswer is too high " );
226
+ mockOffchainAggregator.updateMinAndMaxAnswers (newMinAnswer, newMaxAnswer);
227
+ }
172
228
}
0 commit comments