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
23 changes: 2 additions & 21 deletions contracts/src/v0.8/ccip/test/BaseTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ contract BaseTest is Test {
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;

function setUp() public virtual {
// BaseTest.setUp is often called multiple times from tests' setUp due to inheritance.
if (s_baseTestInitialized) return;
Expand All @@ -69,16 +66,10 @@ contract BaseTest is Test {
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));
}

function _setMockRMNChainCurse(uint64 chainSelector, bool isCursed) internal {
vm.mockCall(
address(s_mockRMNRemote),
Expand Down Expand Up @@ -110,16 +101,6 @@ contract BaseTest is Test {

/// @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()));
return bytes32(vm.randomUint());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ import {MultiAggregateRateLimiter} from "../../../MultiAggregateRateLimiter.sol"
import {Client} from "../../../libraries/Client.sol";
import {Internal} from "../../../libraries/Internal.sol";
import {RateLimiter} from "../../../libraries/RateLimiter.sol";
import {BaseTest} from "../../BaseTest.t.sol";

import {FeeQuoterSetup} from "../../feeQuoter/FeeQuoterSetup.t.sol";
import {MultiAggregateRateLimiterHelper} from "../../helpers/MultiAggregateRateLimiterHelper.sol";

contract MultiAggregateRateLimiterSetup is BaseTest, FeeQuoterSetup {
contract MultiAggregateRateLimiterSetup is FeeQuoterSetup {
MultiAggregateRateLimiterHelper internal s_rateLimiter;

address internal constant TOKEN = 0x21118E64E1fB0c487F25Dd6d3601FF6af8D32E4e;
Expand All @@ -27,8 +25,7 @@ contract MultiAggregateRateLimiterSetup is BaseTest, FeeQuoterSetup {

address[] internal s_authorizedCallers;

function setUp() public virtual override(BaseTest, FeeQuoterSetup) {
BaseTest.setUp();
function setUp() public virtual override {
FeeQuoterSetup.setUp();

Internal.PriceUpdates memory priceUpdates = _getSingleTokenPriceUpdateStruct(TOKEN, TOKEN_PRICE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ contract RMNRemoteSetup is BaseTest {
}

for (uint256 i = 0; i < numSigners; ++i) {
s_signerWallets.push(vm.createWallet(_randomNum()));
s_signerWallets.push(vm.createWallet(vm.randomUint()));
}

_sort(s_signerWallets);
Expand Down Expand Up @@ -84,11 +84,11 @@ contract RMNRemoteSetup is BaseTest {

/// @notice generates a random dest lane update
function _generateRandomDestLaneUpdate() private returns (Internal.MerkleRoot memory) {
uint64 minSeqNum = uint32(_randomNum());
uint64 minSeqNum = uint32(vm.randomUint());
uint64 maxSeqNum = minSeqNum + 100;
return Internal.MerkleRoot({
sourceChainSelector: uint64(_randomNum()),
onRampAddress: abi.encode(_randomAddress()),
sourceChainSelector: uint64(vm.randomUint()),
onRampAddress: abi.encode(vm.randomAddress()),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

minSeqNr: minSeqNum,
maxSeqNr: maxSeqNum,
merkleRoot: _randomBytes32()
Expand Down