Skip to content

Commit

Permalink
simplify test setups
Browse files Browse the repository at this point in the history
  • Loading branch information
jhweintraub committed Nov 26, 2024
1 parent 9d0fe36 commit 8b1553e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
4 changes: 2 additions & 2 deletions contracts/gas-snapshots/ccip.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -720,8 +720,8 @@ TokenPool_parseRemoteDecimals:test_parseRemoteDecimals_NoDecimalsDefaultsToLocal
TokenPool_removeRemotePool:test_InvalidRemotePoolForChain_Revert() (gas: 17432)
TokenPool_removeRemotePool:test_NonExistentChain_Revert() (gas: 14277)
TokenPool_removeRemotePool:test_removeRemotePool_Success() (gas: 188430)
TokenPool_setChainRateLimiterConfigs:test_MismatchedArrayLengths_Revert() (gas: 25014)
TokenPool_setChainRateLimiterConfigs:test_NonExistentChain_Revert() (gas: 19823)
TokenPool_setChainRateLimiterConfigs:test_MismatchedArrayLengths_Revert() (gas: 23786)
TokenPool_setChainRateLimiterConfigs:test_NonExistentChain_Revert() (gas: 19337)
TokenPool_setChainRateLimiterConfigs:test_OnlyOwnerOrRateLimitAdmin_Revert() (gas: 16424)
TokenPool_setRateLimitAdmin:test_SetRateLimitAdmin_Revert() (gas: 11024)
TokenPool_setRateLimitAdmin:test_SetRateLimitAdmin_Success() (gas: 37672)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,39 +102,27 @@ contract TokenPool_setChainRateLimiterConfigs is TokenPoolSetup {
chainSelectors[0] = wrongChainSelector;

RateLimiter.Config[] memory newOutboundConfigs = new RateLimiter.Config[](1);
newOutboundConfigs[0] = _getOutboundRateLimiterConfig();

RateLimiter.Config[] memory newInboundConfigs = new RateLimiter.Config[](1);
newInboundConfigs[0] = _getInboundRateLimiterConfig();

vm.expectRevert(abi.encodeWithSelector(TokenPool.NonExistentChain.selector, wrongChainSelector));
s_tokenPool.setChainRateLimiterConfigs(chainSelectors, newOutboundConfigs, newInboundConfigs);
}

function test_MismatchedArrayLengths_Revert() public {
uint64[] memory chainSelectors = new uint64[](1);
chainSelectors[0] = DEST_CHAIN_SELECTOR;

RateLimiter.Config[] memory newOutboundConfigs = new RateLimiter.Config[](1);
newOutboundConfigs[0] = _getOutboundRateLimiterConfig();

RateLimiter.Config[] memory newInboundConfigs = new RateLimiter.Config[](2);
newInboundConfigs[0] = _getInboundRateLimiterConfig();
newInboundConfigs[1] = _getInboundRateLimiterConfig();

// test mismatched array lengths between rate limiters
vm.expectRevert(abi.encodeWithSelector(TokenPool.MismatchedArrayLengths.selector));
s_tokenPool.setChainRateLimiterConfigs(chainSelectors, newOutboundConfigs, newInboundConfigs);

newInboundConfigs = new RateLimiter.Config[](1);
newInboundConfigs[0] = _getInboundRateLimiterConfig();

uint64[] memory chainSelectors2 = new uint64[](2);
chainSelectors2[0] = DEST_CHAIN_SELECTOR;
chainSelectors2[1] = DEST_CHAIN_SELECTOR;
chainSelectors = new uint64[](2);

// test mismatched array lengths between chain selectors and rate limiters
vm.expectRevert(abi.encodeWithSelector(TokenPool.MismatchedArrayLengths.selector));
s_tokenPool.setChainRateLimiterConfigs(chainSelectors2, newOutboundConfigs, newInboundConfigs);
s_tokenPool.setChainRateLimiterConfigs(chainSelectors, newOutboundConfigs, newInboundConfigs);
}
}

0 comments on commit 8b1553e

Please sign in to comment.