@@ -239,12 +239,27 @@ contract TestGhoCcipSteward is TestGhoBase {
239239 capacity: 0 ,
240240 rate: 0
241241 });
242+
243+ // reverts because capacity or rate cannot be set to 0 when rate limit is enabled
244+ // this check is enforced on the token pool (see RateLimiter._validateTokenBucketConfig)
245+ vm.prank (RISK_COUNCIL);
246+ vm.expectRevert (
247+ abi.encodeWithSelector (RateLimiter.InvalidRatelimitRate.selector , invalidConfig)
248+ );
249+ GHO_CCIP_STEWARD.updateRateLimit (
250+ remoteChainSelector,
251+ invalidConfig.isEnabled,
252+ invalidConfig.capacity,
253+ invalidConfig.rate,
254+ invalidConfig.isEnabled,
255+ invalidConfig.capacity,
256+ invalidConfig.rate
257+ );
258+
259+ invalidConfig.rate = 10 ;
242260 vm.prank (RISK_COUNCIL);
243261 vm.expectRevert (
244- abi.encodeWithSelector (
245- RateLimiter.InvalidRatelimitRate.selector ,
246- RateLimiter.Config ({isEnabled: true , capacity: 0 , rate: 0 })
247- )
262+ abi.encodeWithSelector (RateLimiter.InvalidRatelimitRate.selector , invalidConfig)
248263 );
249264 GHO_CCIP_STEWARD.updateRateLimit (
250265 remoteChainSelector,
@@ -257,7 +272,31 @@ contract TestGhoCcipSteward is TestGhoBase {
257272 );
258273 }
259274
260- function testChangeEnabledRateLimit () public {
275+ function testRevertUpdateRateLimitToZeroWhenDisabled () public {
276+ RateLimiter.Config memory invalidConfig = RateLimiter.Config ({
277+ isEnabled: false ,
278+ capacity: 10 ,
279+ rate: 0
280+ });
281+
282+ // reverts because capacity and rate both have be set to 0 when rate limit is disabled
283+ // this check is enforced on the token pool (see RateLimiter._validateTokenBucketConfig)
284+ vm.prank (RISK_COUNCIL);
285+ vm.expectRevert (
286+ abi.encodeWithSelector (RateLimiter.DisabledNonZeroRateLimit.selector , invalidConfig)
287+ );
288+ GHO_CCIP_STEWARD.updateRateLimit (
289+ remoteChainSelector,
290+ invalidConfig.isEnabled,
291+ invalidConfig.capacity,
292+ invalidConfig.rate,
293+ invalidConfig.isEnabled,
294+ invalidConfig.capacity,
295+ invalidConfig.rate
296+ );
297+ }
298+
299+ function testDisableRateLimit () public {
261300 RateLimiter.TokenBucket memory outboundConfig = MockUpgradeableLockReleaseTokenPool (
262301 GHO_TOKEN_POOL
263302 ).getCurrentOutboundRateLimiterState (remoteChainSelector);
@@ -274,6 +313,7 @@ contract TestGhoCcipSteward is TestGhoBase {
274313 assertGt (inboundConfig.capacity, 0 );
275314 assertGt (inboundConfig.rate, 0 );
276315
316+ // capacity and rate both have be set to 0 when rate limit is disabled, enforced by token pool
277317 RateLimiter.Config memory disableLimitConfig = RateLimiter.Config ({
278318 isEnabled: false ,
279319 capacity: 0 ,
@@ -306,7 +346,7 @@ contract TestGhoCcipSteward is TestGhoBase {
306346 assertEq (inboundConfig.rate, 0 );
307347 }
308348
309- function testRevertChangeDisabledRateLimit () public {
349+ function testChangeEnabledRateLimit () public {
310350 RateLimiter.TokenBucket memory outboundConfig = MockUpgradeableLockReleaseTokenPool (
311351 GHO_TOKEN_POOL
312352 ).getCurrentOutboundRateLimiterState (remoteChainSelector);
0 commit comments