Skip to content

Commit db0364f

Browse files
committed
test(ccip-steward): disable rate limit
1 parent fca6888 commit db0364f

File tree

1 file changed

+100
-1
lines changed

1 file changed

+100
-1
lines changed

src/test/TestGhoCcipSteward.t.sol

Lines changed: 100 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ contract TestGhoCcipSteward is TestGhoBase {
240240
rate: 0
241241
});
242242
vm.prank(RISK_COUNCIL);
243-
vm.expectRevert();
243+
vm.expectRevert('INVALID_RATE_LIMIT_UPDATE');
244244
GHO_CCIP_STEWARD.updateRateLimit(
245245
remoteChainSelector,
246246
invalidConfig.isEnabled,
@@ -252,6 +252,105 @@ contract TestGhoCcipSteward is TestGhoBase {
252252
);
253253
}
254254

255+
function testDisableRateLimitFromNonZeroToZero() public {
256+
RateLimiter.TokenBucket memory outboundConfig = MockUpgradeableLockReleaseTokenPool(
257+
GHO_TOKEN_POOL
258+
).getCurrentOutboundRateLimiterState(remoteChainSelector);
259+
RateLimiter.TokenBucket memory inboundConfig = MockUpgradeableLockReleaseTokenPool(
260+
GHO_TOKEN_POOL
261+
).getCurrentInboundRateLimiterState(remoteChainSelector);
262+
263+
assertTrue(outboundConfig.isEnabled);
264+
assertGt(outboundConfig.capacity, 0);
265+
assertGt(outboundConfig.rate, 0);
266+
267+
assertTrue(inboundConfig.isEnabled);
268+
assertGt(inboundConfig.capacity, 0);
269+
assertGt(inboundConfig.rate, 0);
270+
271+
RateLimiter.Config memory disableLimitConfig = RateLimiter.Config({
272+
isEnabled: false,
273+
capacity: 0,
274+
rate: 0
275+
});
276+
277+
// disable both inbound & outbound config
278+
vm.prank(RISK_COUNCIL);
279+
GHO_CCIP_STEWARD.updateRateLimit(
280+
remoteChainSelector,
281+
disableLimitConfig.isEnabled,
282+
disableLimitConfig.capacity,
283+
disableLimitConfig.rate,
284+
disableLimitConfig.isEnabled,
285+
disableLimitConfig.capacity,
286+
disableLimitConfig.rate
287+
);
288+
289+
outboundConfig = MockUpgradeableLockReleaseTokenPool(GHO_TOKEN_POOL)
290+
.getCurrentOutboundRateLimiterState(remoteChainSelector);
291+
inboundConfig = MockUpgradeableLockReleaseTokenPool(GHO_TOKEN_POOL)
292+
.getCurrentInboundRateLimiterState(remoteChainSelector);
293+
294+
assertFalse(outboundConfig.isEnabled);
295+
assertEq(outboundConfig.capacity, 0);
296+
assertEq(outboundConfig.rate, 0);
297+
298+
assertFalse(inboundConfig.isEnabled);
299+
assertEq(inboundConfig.capacity, 0);
300+
assertEq(inboundConfig.rate, 0);
301+
}
302+
303+
function testDisableRateLimitOnlyOutboundConfig() public {
304+
RateLimiter.TokenBucket memory outboundConfig = MockUpgradeableLockReleaseTokenPool(
305+
GHO_TOKEN_POOL
306+
).getCurrentOutboundRateLimiterState(remoteChainSelector);
307+
RateLimiter.TokenBucket memory inboundConfig = MockUpgradeableLockReleaseTokenPool(
308+
GHO_TOKEN_POOL
309+
).getCurrentInboundRateLimiterState(remoteChainSelector);
310+
311+
assertTrue(outboundConfig.isEnabled);
312+
assertGt(outboundConfig.capacity, 0);
313+
assertGt(outboundConfig.rate, 0);
314+
315+
assertTrue(inboundConfig.isEnabled);
316+
assertGt(inboundConfig.capacity, 0);
317+
assertGt(inboundConfig.rate, 0);
318+
319+
RateLimiter.Config memory disableLimitConfig = RateLimiter.Config({
320+
isEnabled: false,
321+
capacity: 0,
322+
rate: 0
323+
});
324+
325+
// disable only outbound config
326+
vm.prank(RISK_COUNCIL);
327+
GHO_CCIP_STEWARD.updateRateLimit(
328+
remoteChainSelector,
329+
disableLimitConfig.isEnabled,
330+
disableLimitConfig.capacity,
331+
disableLimitConfig.rate,
332+
// preserve inboundConfig
333+
inboundConfig.isEnabled,
334+
inboundConfig.capacity,
335+
inboundConfig.rate
336+
);
337+
338+
RateLimiter.TokenBucket memory outboundConfigNew = MockUpgradeableLockReleaseTokenPool(
339+
GHO_TOKEN_POOL
340+
).getCurrentOutboundRateLimiterState(remoteChainSelector);
341+
RateLimiter.TokenBucket memory inboundConfigNew = MockUpgradeableLockReleaseTokenPool(
342+
GHO_TOKEN_POOL
343+
).getCurrentInboundRateLimiterState(remoteChainSelector);
344+
345+
assertFalse(outboundConfigNew.isEnabled);
346+
assertEq(outboundConfigNew.capacity, 0);
347+
assertEq(outboundConfigNew.rate, 0);
348+
349+
assertTrue(inboundConfigNew.isEnabled);
350+
assertEq(inboundConfigNew.capacity, inboundConfig.capacity);
351+
assertEq(inboundConfigNew.rate, inboundConfig.rate);
352+
}
353+
255354
function testRevertUpdateRateLimitRateGreaterThanCapacity() public {
256355
RateLimiter.Config memory invalidConfig = RateLimiter.Config({
257356
isEnabled: true,

0 commit comments

Comments
 (0)