Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test snapshot exclusion #15727

Merged
merged 11 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions contracts/.changeset/new-elephants-behave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chainlink/contracts': patch
---

fix test naming
1,085 changes: 367 additions & 718 deletions contracts/gas-snapshots/ccip.gas-snapshot

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions contracts/src/v0.8/ccip/rmn/RMNRemote.sol
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ contract RMNRemote is Ownable2StepMsgSender, ITypeAndVersion, IRMNRemote, IRMN {

/// @inheritdoc IRMNRemote
function verify(
address offrampAddress,
address offRampAddress,
Internal.MerkleRoot[] calldata merkleRoots,
Signature[] calldata signatures
) external view {
Expand All @@ -110,7 +110,7 @@ contract RMNRemote is Ownable2StepMsgSender, ITypeAndVersion, IRMNRemote, IRMN {
destChainId: block.chainid,
destChainSelector: i_localChainSelector,
rmnRemoteContractAddress: address(this),
offrampAddress: offrampAddress,
offrampAddress: offRampAddress,
rmnHomeContractConfigDigest: s_config.rmnHomeContractConfigDigest,
merkleRoots: merkleRoots
})
Expand Down
70 changes: 24 additions & 46 deletions contracts/src/v0.8/ccip/test/BaseTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,37 @@ pragma solidity 0.8.24;

// Imports to any non-library are not allowed due to the significant cascading
// compile time increase they cause when imported into this base test.

import {IRMNRemote} from "../interfaces/IRMNRemote.sol";

import {Router} from "../Router.sol";
import {Internal} from "../libraries/Internal.sol";
import {RateLimiter} from "../libraries/RateLimiter.sol";
import {MockRMN} from "./mocks/MockRMN.sol";
import {WETH9} from "./WETH9.sol";

import {Test} from "forge-std/Test.sol";

contract BaseTest is Test {
// Addresses
address internal constant OWNER = 0x00007e64E1fB0C487F25dd6D3601ff6aF8d32e4e;
address internal constant STRANGER = address(999999);

address internal constant USER_1 = address(1);
// Timing
uint256 internal constant BLOCK_TIME = 1234567890;
uint32 internal constant TWELVE_HOURS = 60 * 60 * 12;

// Message info
uint64 internal constant SOURCE_CHAIN_SELECTOR = 1;
uint64 internal constant DEST_CHAIN_SELECTOR = 2;
uint32 internal constant GAS_LIMIT = 200_000;

// Timing
uint256 internal constant BLOCK_TIME = 1234567890;
uint32 internal constant TWELVE_HOURS = 60 * 60 * 12;

// Onramp
uint96 internal constant MAX_MSG_FEES_JUELS = 1_000e18;
uint32 internal constant DEST_GAS_OVERHEAD = 300_000;
uint16 internal constant DEST_GAS_PER_PAYLOAD_BYTE = 16;

uint16 internal constant DEFAULT_TOKEN_FEE_USD_CENTS = 50;
uint32 internal constant DEFAULT_TOKEN_DEST_GAS_OVERHEAD = 90_000;
uint32 internal constant DEFAULT_TOKEN_BYTES_OVERHEAD = 32;
uint8 internal constant DEFAULT_TOKEN_DECIMALS = 18;
uint16 internal constant GAS_FOR_CALL_EXACT_CHECK = 5_000;

bool private s_baseTestInitialized;

// OffRamp
uint32 internal constant MAX_DATA_SIZE = 30_000;
uint16 internal constant MAX_TOKENS_LENGTH = 5;
uint16 internal constant GAS_FOR_CALL_EXACT_CHECK = 5_000;
uint32 internal constant MAX_GAS_LIMIT = 4_000_000;

MockRMN internal s_mockRMN;
IRMNRemote internal s_mockRMNRemote;

// nonce for pseudo-random number generation, not to be exposed to test suites
uint256 private s_randNonce;
Router internal s_sourceRouter;
Router internal s_destRouter;

function setUp() public virtual {
// BaseTest.setUp is often called multiple times from tests' setUp due to inheritance.
Expand All @@ -64,19 +49,18 @@ contract BaseTest is Test {
// Set the block time to a constant known value
vm.warp(BLOCK_TIME);

// setup mock RMN & RMNRemote
s_mockRMN = new MockRMN();
// setup RMNRemote
s_mockRMNRemote = IRMNRemote(makeAddr("MOCK RMN REMOTE"));
vm.etch(address(s_mockRMNRemote), bytes("fake bytecode"));
vm.mockCall(address(s_mockRMNRemote), abi.encodeWithSelector(IRMNRemote.verify.selector), bytes(""));
_setMockRMNGlobalCurse(false);
vm.mockCall(address(s_mockRMNRemote), abi.encodeWithSignature("isCursed()"), abi.encode(false));
vm.mockCall(address(s_mockRMNRemote), abi.encodeWithSignature("isCursed(bytes16)"), abi.encode(false)); // no curses by defaule
}

function _setMockRMNGlobalCurse(
bool isCursed
) internal {
vm.mockCall(address(s_mockRMNRemote), abi.encodeWithSignature("isCursed()"), abi.encode(isCursed));
s_sourceRouter = new Router(address(new WETH9()), address(s_mockRMNRemote));
vm.label(address(s_sourceRouter), "sourceRouter");
// Deploy a destination router
s_destRouter = new Router(address(new WETH9()), address(s_mockRMNRemote));
vm.label(address(s_destRouter), "destRouter");
}

function _setMockRMNChainCurse(uint64 chainSelector, bool isCursed) internal {
Expand Down Expand Up @@ -108,18 +92,12 @@ contract BaseTest is Test {
return priceUpdates;
}

/// @dev returns a pseudo-random bytes32
function _randomBytes32() internal returns (bytes32) {
return keccak256(abi.encodePacked(++s_randNonce));
}

/// @dev returns a pseudo-random number
function _randomNum() internal returns (uint256) {
return uint256(_randomBytes32());
}

/// @dev returns a pseudo-random address
function _randomAddress() internal returns (address) {
return address(uint160(_randomNum()));
function _generateSourceTokenData() internal pure returns (Internal.SourceTokenData memory) {
return Internal.SourceTokenData({
sourcePoolAddress: abi.encode(address(12312412312)),
destTokenAddress: abi.encode(address(9809808909)),
extraData: "",
destGasAmount: DEFAULT_TOKEN_DEST_GAS_OVERHEAD
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {NonceManager} from "../../NonceManager.sol";
import {OnRampSetup} from "../onRamp/OnRamp/OnRampSetup.t.sol";

contract NonceManager_applyPreviousRampsUpdates is OnRampSetup {
function test_SingleRampUpdate_success() public {
function test_SingleRampUpdate() public {
address prevOnRamp = makeAddr("prevOnRamp");
address prevOffRamp = makeAddr("prevOffRamp");
NonceManager.PreviousRampsArgs[] memory previousRamps = new NonceManager.PreviousRampsArgs[](1);
Expand Down Expand Up @@ -80,7 +80,7 @@ contract NonceManager_applyPreviousRampsUpdates is OnRampSetup {
assertEq(vm.getRecordedLogs().length, 0);
}

function test_applyPreviousRampsUpdates_RevertWhen_PreviousRampAlreadySetOnRamp() public {
function test_RevertWhen_applyPreviousRampsUpdatesWhen_PreviousRampAlreadySetOnRamp() public {
NonceManager.PreviousRampsArgs[] memory previousRamps = new NonceManager.PreviousRampsArgs[](1);
address prevOnRamp = makeAddr("prevOnRamp");
previousRamps[0] = NonceManager.PreviousRampsArgs({
Expand All @@ -101,7 +101,7 @@ contract NonceManager_applyPreviousRampsUpdates is OnRampSetup {
s_outboundNonceManager.applyPreviousRampsUpdates(previousRamps);
}

function test_applyPreviousRampsUpdates_RevertWhen_PreviousRampAlreadySetOffRamp() public {
function test_RevertWhen_applyPreviousRampsUpdatesWhen_PreviousRampAlreadySetOffRamp() public {
NonceManager.PreviousRampsArgs[] memory previousRamps = new NonceManager.PreviousRampsArgs[](1);
address prevOffRamp = makeAddr("prevOffRamp");
previousRamps[0] = NonceManager.PreviousRampsArgs({
Expand All @@ -122,7 +122,7 @@ contract NonceManager_applyPreviousRampsUpdates is OnRampSetup {
s_outboundNonceManager.applyPreviousRampsUpdates(previousRamps);
}

function test_applyPreviousRampsUpdates_RevertWhen_PreviousRampAlreadySetOnRampAndOffRamp_Revert() public {
function test_RevertWhen_applyPreviousRampsUpdatesWhen_PreviousRampAlreadySetOnRampAndOffRamp_Revert() public {
NonceManager.PreviousRampsArgs[] memory previousRamps = new NonceManager.PreviousRampsArgs[](1);
address prevOnRamp = makeAddr("prevOnRamp");
address prevOffRamp = makeAddr("prevOffRamp");
Expand Down
10 changes: 5 additions & 5 deletions contracts/src/v0.8/ccip/test/TokenSetup.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import {BurnMintTokenPool} from "../pools/BurnMintTokenPool.sol";
import {LockReleaseTokenPool} from "../pools/LockReleaseTokenPool.sol";
import {TokenPool} from "../pools/TokenPool.sol";
import {TokenAdminRegistry} from "../tokenAdminRegistry/TokenAdminRegistry.sol";
import {BaseTest} from "./BaseTest.t.sol";
import {MaybeRevertingBurnMintTokenPool} from "./helpers/MaybeRevertingBurnMintTokenPool.sol";
import {RouterSetup} from "./router/Router/RouterSetup.t.sol";

import {IERC20} from "../../vendor/openzeppelin-solidity/v4.8.3/contracts/token/ERC20/IERC20.sol";

contract TokenSetup is RouterSetup {
contract TokenSetup is BaseTest {
address[] internal s_sourceTokens;
address[] internal s_destTokens;

Expand Down Expand Up @@ -46,7 +46,7 @@ contract TokenSetup is RouterSetup {
}

LockReleaseTokenPool pool = new LockReleaseTokenPool(
IERC20(token), DEFAULT_TOKEN_DECIMALS, new address[](0), address(s_mockRMN), true, router
IERC20(token), DEFAULT_TOKEN_DECIMALS, new address[](0), address(s_mockRMNRemote), true, router
);

if (isSourcePool) {
Expand All @@ -64,7 +64,7 @@ contract TokenSetup is RouterSetup {
}

BurnMintTokenPool pool = new MaybeRevertingBurnMintTokenPool(
BurnMintERC20(token), DEFAULT_TOKEN_DECIMALS, new address[](0), address(s_mockRMN), router
BurnMintERC20(token), DEFAULT_TOKEN_DECIMALS, new address[](0), address(s_mockRMNRemote), router
);
BurnMintERC20(token).grantMintAndBurnRoles(address(pool));

Expand All @@ -77,7 +77,7 @@ contract TokenSetup is RouterSetup {
}

function setUp() public virtual override {
RouterSetup.setUp();
super.setUp();

bool isSetup = s_sourceTokens.length != 0;
if (isSetup) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ contract DefensiveExampleTest is OnRampSetup {
assertEq(IERC20(token).balanceOf(address(s_receiver)), receiverBalancePre - amount);
}

function test_HappyPath_Success() public {
function test_HappyPath() public {
bytes32 messageId = keccak256("messageId");
address token = address(s_destFeeToken);
uint256 amount = 111333333777;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ contract EtherSenderReceiverTest_ccipSend is EtherSenderReceiverTestSetup {
}
}

function test_ccipSend_reverts_insufficientFee_weth() public {
function test_RevertWhen_ccipSends_insufficientFee_weth() public {
Client.EVMTokenAmount[] memory tokenAmounts = new Client.EVMTokenAmount[](1);
tokenAmounts[0] = Client.EVMTokenAmount({
token: address(0), // callers may not specify this.
Expand Down Expand Up @@ -127,7 +127,7 @@ contract EtherSenderReceiverTest_ccipSend is EtherSenderReceiverTestSetup {
s_etherSenderReceiver.ccipSend{value: AMOUNT}(DESTINATION_CHAIN_SELECTOR, message);
}

function test_ccipSend_reverts_insufficientFee_feeToken() public {
function test_RevertWhen_ccipSends_insufficientFee_feeToken() public {
Client.EVMTokenAmount[] memory tokenAmounts = new Client.EVMTokenAmount[](1);
tokenAmounts[0] = Client.EVMTokenAmount({
token: address(0), // callers may not specify this.
Expand Down Expand Up @@ -155,7 +155,7 @@ contract EtherSenderReceiverTest_ccipSend is EtherSenderReceiverTestSetup {
s_etherSenderReceiver.ccipSend{value: AMOUNT}(DESTINATION_CHAIN_SELECTOR, message);
}

function test_ccipSend_reverts_insufficientFee_native() public {
function test_RevertWhen_ccipSends_insufficientFee_native() public {
Client.EVMTokenAmount[] memory tokenAmounts = new Client.EVMTokenAmount[](1);
tokenAmounts[0] = Client.EVMTokenAmount({
token: address(0), // callers may not specify this.
Expand All @@ -181,7 +181,7 @@ contract EtherSenderReceiverTest_ccipSend is EtherSenderReceiverTestSetup {
s_etherSenderReceiver.ccipSend{value: AMOUNT + FEE_WEI - 1}(DESTINATION_CHAIN_SELECTOR, message);
}

function test_ccipSend_success_nativeExcess() public {
function test_ccipSend_nativeExcess() public {
Client.EVMTokenAmount[] memory tokenAmounts = new Client.EVMTokenAmount[](1);
tokenAmounts[0] = Client.EVMTokenAmount({
token: address(0), // callers may not specify this.
Expand Down Expand Up @@ -218,7 +218,7 @@ contract EtherSenderReceiverTest_ccipSend is EtherSenderReceiverTestSetup {
assertEq(actualMsgId, expectedMsgId, "message id must be correct");
}

function test_ccipSend_success_native() public {
function test_ccipSend_native() public {
Client.EVMTokenAmount[] memory tokenAmounts = new Client.EVMTokenAmount[](1);
tokenAmounts[0] = Client.EVMTokenAmount({
token: address(0), // callers may not specify this.
Expand Down Expand Up @@ -251,7 +251,7 @@ contract EtherSenderReceiverTest_ccipSend is EtherSenderReceiverTestSetup {
assertEq(actualMsgId, expectedMsgId, "message id must be correct");
}

function test_ccipSend_success_feeToken() public {
function test_ccipSend_feeToken() public {
Client.EVMTokenAmount[] memory tokenAmounts = new Client.EVMTokenAmount[](1);
tokenAmounts[0] = Client.EVMTokenAmount({
token: address(0), // callers may not specify this.
Expand Down Expand Up @@ -287,7 +287,7 @@ contract EtherSenderReceiverTest_ccipSend is EtherSenderReceiverTestSetup {
assertEq(routerAllowance, FEE_JUELS, "router allowance must be feeJuels");
}

function test_ccipSend_success_weth() public {
function test_ccipSend_weth() public {
Client.EVMTokenAmount[] memory tokenAmounts = new Client.EVMTokenAmount[](1);
tokenAmounts[0] = Client.EVMTokenAmount({
token: address(0), // callers may not specify this.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ contract EtherSenderReceiverTest_validateFeeToken is EtherSenderReceiverTestSetu
s_etherSenderReceiver.validateFeeToken{value: AMOUNT}(message);
}

function test_validateFeeToken_reverts_feeToken_tokenAmountNotEqualToMsgValue() public {
function test_RevertWhen_validateFeeTokens_feeToken_tokenAmountNotEqualToMsgValue() public {
Client.EVMTokenAmount[] memory tokenAmount = new Client.EVMTokenAmount[](1);
tokenAmount[0] = Client.EVMTokenAmount({token: address(s_weth), amount: AMOUNT});
Client.EVM2AnyMessage memory message = Client.EVM2AnyMessage({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {ERC165Checker} from
"../../../../vendor/openzeppelin-solidity/v5.0.2/contracts/utils/introspection/ERC165Checker.sol";

contract CCIPClientExample_sanity is OnRampSetup {
function test_ImmutableExamples_Success() public {
function test_ImmutableExamples() public {
CCIPClientExample exampleContract = new CCIPClientExample(s_sourceRouter, IERC20(s_sourceFeeToken));
deal(address(exampleContract), 100 ether);
deal(s_sourceFeeToken, address(exampleContract), 100 ether);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {Client} from "../../../libraries/Client.sol";
import {PingPongDappSetup} from "./PingPongDappSetup.t.sol";

contract PingPong_ccipReceive is PingPongDappSetup {
function test_CcipReceive_Success() public {
function test_CcipReceive() public {
Client.EVMTokenAmount[] memory tokenAmounts = new Client.EVMTokenAmount[](0);

uint256 pingPongNumber = 5;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {PingPongDemo} from "../../../applications/PingPongDemo.sol";
import {PingPongDappSetup} from "./PingPongDappSetup.t.sol";

contract PingPong_setOutOfOrderExecution is PingPongDappSetup {
function test_OutOfOrderExecution_Success() public {
function test_OutOfOrderExecution() public {
assertFalse(s_pingPong.getOutOfOrderExecution());

vm.expectEmit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity 0.8.24;
import {PingPongDappSetup} from "./PingPongDappSetup.t.sol";

contract PingPong_setPaused is PingPongDappSetup {
function test_Pausing_Success() public {
function test_Pausing() public {
assertFalse(s_pingPong.isPaused());

s_pingPong.setPaused(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import {PingPongDappSetup} from "./PingPongDappSetup.t.sol";
contract PingPong_startPingPong is PingPongDappSetup {
uint256 internal s_pingPongNumber = 1;

function test_StartPingPong_With_Sequenced_Ordered_Success() public {
function test_StartPingPong_With_Sequenced_Ordered() public {
_assertPingPongSuccess();
}

function test_StartPingPong_With_OOO_Success() public {
function test_StartPingPong_With_OOO() public {
s_pingPong.setOutOfOrderExecution(true);

_assertPingPongSuccess();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ contract OnRampTokenPoolReentrancy is OnRampSetup {
new FacadeClient(address(s_sourceRouter), DEST_CHAIN_SELECTOR, s_sourceToken, s_feeToken, i_receiver);

s_maliciousTokenPool = new ReentrantMaliciousTokenPool(
address(s_facadeClient), s_sourceToken, address(s_mockRMN), address(s_sourceRouter)
address(s_facadeClient), s_sourceToken, address(s_mockRMNRemote), address(s_sourceRouter)
);

bytes[] memory remotePoolAddresses = new bytes[](1);
Expand Down Expand Up @@ -59,7 +59,7 @@ contract OnRampTokenPoolReentrancy is OnRampSetup {
/// (reenter)-> Facade -> 2nd call to ccipSend
/// In this case, Facade's second call would produce an EVM2Any msg with a lower sequence number.
/// The issue was fixed by implementing a reentrancy guard in OnRamp.
function test_OnRampTokenPoolReentrancy_Success() public {
function test_OnRampTokenPoolReentrancy() public {
uint256 amount = 1;

Client.EVMTokenAmount[] memory tokenAmounts = new Client.EVMTokenAmount[](1);
Expand Down
Loading
Loading