Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
Signed-off-by: 0xsuryansh <suryansh.shrivastava@smartcontract.com>
  • Loading branch information
0xsuryansh committed Oct 4, 2024
1 parent a0cc771 commit 549b19d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
5 changes: 3 additions & 2 deletions contracts/gas-snapshots/ccip.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -750,11 +750,12 @@ OnRamp_applyAllowListUpdates:test_applyAllowListUpdates_Revert() (gas: 67797)
OnRamp_applyAllowListUpdates:test_applyAllowListUpdates_Success() (gas: 325198)
OnRamp_applyDestChainConfigUpdates:test_ApplyDestChainConfigUpdates_Success() (gas: 65878)
OnRamp_applyDestChainConfigUpdates:test_ApplyDestChainConfigUpdates_WithInvalidChainSelector_Revert() (gas: 13631)
OnRamp_constructor:test_Constructor_EnableAllowList_ForwardFromRouter_Reverts() (gas: 2714724)
OnRamp_constructor:test_Constructor_InvalidConfigChainSelectorEqZero_Revert() (gas: 95249)
OnRamp_constructor:test_Constructor_InvalidConfigNonceManagerEqAddressZero_Revert() (gas: 93191)
OnRamp_constructor:test_Constructor_InvalidConfigRMNProxyEqAddressZero_Revert() (gas: 98224)
OnRamp_constructor:test_Constructor_InvalidConfigTokenAdminRegistryEqAddressZero_Revert() (gas: 93225)
OnRamp_constructor:test_Constructor_Success() (gas: 2753264)
OnRamp_constructor:test_Constructor_InvalidConfigTokenAdminRegistryEqAddressZero_Revert() (gas: 93247)
OnRamp_constructor:test_Constructor_Success() (gas: 2753286)
OnRamp_forwardFromRouter:test_ForwardFromRouterExtraArgsV2AllowOutOfOrderTrue_Success() (gas: 115307)
OnRamp_forwardFromRouter:test_ForwardFromRouterExtraArgsV2_Success() (gas: 146108)
OnRamp_forwardFromRouter:test_ForwardFromRouterSuccessCustomExtraArgs() (gas: 145705)
Expand Down
37 changes: 37 additions & 0 deletions contracts/src/v0.8/ccip/test/onRamp/OnRamp.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,43 @@ contract OnRamp_constructor is OnRampSetup {
assertEq(address(s_sourceRouter), address(s_onRamp.getRouter(DEST_CHAIN_SELECTOR)));
}

function test_Constructor_EnableAllowList_ForwardFromRouter_Reverts() public {
OnRamp.StaticConfig memory staticConfig = OnRamp.StaticConfig({
chainSelector: SOURCE_CHAIN_SELECTOR,
rmnRemote: s_mockRMNRemote,
nonceManager: address(s_outboundNonceManager),
tokenAdminRegistry: address(s_tokenAdminRegistry)
});

OnRamp.DynamicConfig memory dynamicConfig = _generateDynamicOnRampConfig(address(s_feeQuoter));

//Creating a DestChainConfig and setting allowListEnabled : true
OnRamp.DestChainConfigArgs[] memory destChainConfigs = new OnRamp.DestChainConfigArgs[](1);
destChainConfigs[0] = OnRamp.DestChainConfigArgs({
destChainSelector: DEST_CHAIN_SELECTOR,
router: s_sourceRouter,
allowListEnabled: true
});

vm.expectEmit();
emit OnRamp.ConfigSet(staticConfig, dynamicConfig);

vm.expectEmit();
emit OnRamp.DestChainConfigSet(DEST_CHAIN_SELECTOR, 0, s_sourceRouter, true);

OnRampHelper tempOnRamp = new OnRampHelper(staticConfig, dynamicConfig, destChainConfigs);

//Sending a message and expecting revert as allowList is enabled with no address in allowlist
Client.EVM2AnyMessage memory message = _generateEmptyMessage();
message.extraArgs = Client._argsToBytes(Client.EVMExtraArgsV1({gasLimit: GAS_LIMIT * 2}));
uint256 feeAmount = 1234567890;
vm.startPrank(address(s_sourceRouter));
IERC20(s_sourceFeeToken).transferFrom(OWNER, address(tempOnRamp), feeAmount);
vm.expectRevert(abi.encodeWithSelector(OnRamp.SenderNotAllowed.selector, OWNER));
tempOnRamp.forwardFromRouter(DEST_CHAIN_SELECTOR, message, feeAmount, OWNER);
vm.stopPrank();
}

function test_Constructor_InvalidConfigChainSelectorEqZero_Revert() public {
vm.expectRevert(OnRamp.InvalidConfig.selector);
new OnRampHelper(
Expand Down

0 comments on commit 549b19d

Please sign in to comment.