Skip to content

Commit

Permalink
feat: timeout fuzz tests after 10 minutes
Browse files Browse the repository at this point in the history
Uses the new fuzz test timeout feature that we merged into foundry
to limit individual test runs to 10 minutes. Simplifies how we
need to deal with heavy fuzz testing.
  • Loading branch information
smartcontracts committed Dec 4, 2024
1 parent 4ce84f1 commit 63bd680
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2.1
parameters:
ci_builder_image:
type: string
default: us-docker.pkg.dev/oplabs-tools-artifacts/images/ci-builder:v0.54.0
default: us-docker.pkg.dev/oplabs-tools-artifacts/images/ci-builder:v0.55.0
ci_builder_rust_image:
type: string
default: us-docker.pkg.dev/oplabs-tools-artifacts/images/ci-builder-rust:latest
Expand Down
2 changes: 2 additions & 0 deletions packages/contracts-bedrock/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,12 @@ depth = 32

[profile.ciheavy.fuzz]
runs = 20000
timeout = 600

[profile.ciheavy.invariant]
runs = 128
depth = 512
timeout = 600

################################################################
# PROFILE: LITE #
Expand Down
10 changes: 0 additions & 10 deletions packages/contracts-bedrock/test/L1/OptimismPortal.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ contract OptimismPortal_Test is CommonTest {
}

/// @dev Tests that `depositTransaction` succeeds when msg.sender == tx.origin and non-custom gas is used.
/// forge-config: ciheavy.fuzz.runs = 8192
function testFuzz_depositTransaction_senderIsOrigin_succeeds(
address _to,
uint256 _mint,
Expand All @@ -227,7 +226,6 @@ contract OptimismPortal_Test is CommonTest {
}

/// @dev Tests that `depositTransaction` succeeds when msg.sender != tx.origin and non-custom gas is used.
/// forge-config: ciheavy.fuzz.runs = 8192
function testFuzz_depositTransaction_senderNotOrigin_succeeds(
address _to,
uint256 _mint,
Expand Down Expand Up @@ -310,7 +308,6 @@ contract OptimismPortal_Test is CommonTest {
}

/// @dev Tests that `depositTransaction` succeeds for an EOA.
/// forge-config: ciheavy.fuzz.runs = 8192
function testFuzz_depositTransaction_eoa_succeeds(
address _to,
uint64 _gasLimit,
Expand Down Expand Up @@ -355,7 +352,6 @@ contract OptimismPortal_Test is CommonTest {
}

/// @dev Tests that `depositTransaction` succeeds for a contract.
/// forge-config: ciheavy.fuzz.runs = 8192
function testFuzz_depositTransaction_contract_succeeds(
address _to,
uint64 _gasLimit,
Expand Down Expand Up @@ -1214,7 +1210,6 @@ contract OptimismPortal_FinalizeWithdrawal_Test is CommonTest {
}

/// @dev Tests that `finalizeWithdrawalTransaction` succeeds.
/// forge-config: ciheavy.fuzz.runs = 8192
function testDiff_finalizeWithdrawalTransaction_succeeds(
address _sender,
address _target,
Expand Down Expand Up @@ -1337,7 +1332,6 @@ contract OptimismPortalResourceFuzz_Test is CommonTest {
uint256 constant MAX_GAS_LIMIT = 30_000_000;

/// @dev Test that various values of the resource metering config will not break deposits.
/// forge-config: ciheavy.fuzz.runs = 10000
function testFuzz_systemConfigDeposit_succeeds(
uint32 _maxResourceLimit,
uint8 _elasticityMultiplier,
Expand Down Expand Up @@ -1472,7 +1466,6 @@ contract OptimismPortalWithMockERC20_Test is OptimismPortal_FinalizeWithdrawal_T
}

/// @dev Tests that `depositERC20Transaction` succeeds when msg.sender == tx.origin.
/// forge-config: ciheavy.fuzz.runs = 8192
function testFuzz_depositERC20Transaction_senderIsOrigin_succeeds(
address _to,
uint256 _mint,
Expand All @@ -1498,7 +1491,6 @@ contract OptimismPortalWithMockERC20_Test is OptimismPortal_FinalizeWithdrawal_T
}

/// @dev Tests that `depositERC20Transaction` succeeds when msg.sender != tx.origin.
/// forge-config: ciheavy.fuzz.runs = 8192
function testFuzz_depositERC20Transaction_senderNotOrigin_succeeds(
address _to,
uint256 _mint,
Expand Down Expand Up @@ -1697,7 +1689,6 @@ contract OptimismPortalWithMockERC20_Test is OptimismPortal_FinalizeWithdrawal_T
}

/// @dev Tests that `depositTransaction` succeeds when a custom gas token is used but the msg.value is zero.
/// forge-config: ciheavy.fuzz.runs = 8192
function testFuzz_depositTransaction_customGasTokenWithNoValueAndSenderIsOrigin_succeeds(
address _to,
uint256 _value,
Expand All @@ -1721,7 +1712,6 @@ contract OptimismPortalWithMockERC20_Test is OptimismPortal_FinalizeWithdrawal_T
}

/// @dev Tests that `depositTransaction` succeeds when a custom gas token is used but the msg.value is zero.
/// forge-config: ciheavy.fuzz.runs = 8192
function testFuzz_depositTransaction_customGasTokenWithNoValueAndSenderNotOrigin_succeeds(
address _to,
uint256 _value,
Expand Down
8 changes: 0 additions & 8 deletions packages/contracts-bedrock/test/L1/OptimismPortal2.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ contract OptimismPortal2_Test is CommonTest {
}

/// @dev Tests that `depositTransaction` succeeds for an EOA.
/// forge-config: ciheavy.fuzz.runs = 8192
function testFuzz_depositTransaction_eoa_succeeds(
address _to,
uint64 _gasLimit,
Expand Down Expand Up @@ -256,7 +255,6 @@ contract OptimismPortal2_Test is CommonTest {
}

/// @dev Tests that `depositTransaction` succeeds for a contract.
/// forge-config: ciheavy.fuzz.runs = 8192
function testFuzz_depositTransaction_contract_succeeds(
address _to,
uint64 _gasLimit,
Expand Down Expand Up @@ -1326,7 +1324,6 @@ contract OptimismPortal2_FinalizeWithdrawal_Test is CommonTest {
}

/// @dev Tests that `finalizeWithdrawalTransaction` succeeds.
/// forge-config: ciheavy.fuzz.runs = 8192
function testDiff_finalizeWithdrawalTransaction_succeeds(
address _sender,
address _target,
Expand Down Expand Up @@ -1610,7 +1607,6 @@ contract OptimismPortal2_ResourceFuzz_Test is CommonTest {
}

/// @dev Test that various values of the resource metering config will not break deposits.
/// forge-config: ciheavy.fuzz.runs = 10000
function testFuzz_systemConfigDeposit_succeeds(
uint32 _maxResourceLimit,
uint8 _elasticityMultiplier,
Expand Down Expand Up @@ -1746,7 +1742,6 @@ contract OptimismPortal2WithMockERC20_Test is OptimismPortal2_FinalizeWithdrawal
}

/// @dev Tests that `depositERC20Transaction` succeeds when msg.sender == tx.origin.
/// forge-config: ciheavy.fuzz.runs = 8192
function testFuzz_depositERC20Transaction_senderIsOrigin_succeeds(
address _to,
uint256 _mint,
Expand All @@ -1772,7 +1767,6 @@ contract OptimismPortal2WithMockERC20_Test is OptimismPortal2_FinalizeWithdrawal
}

/// @dev Tests that `depositERC20Transaction` succeeds when msg.sender != tx.origin.
/// forge-config: ciheavy.fuzz.runs = 8192
function testFuzz_depositERC20Transaction_senderNotOrigin_succeeds(
address _to,
uint256 _mint,
Expand Down Expand Up @@ -1980,7 +1974,6 @@ contract OptimismPortal2WithMockERC20_Test is OptimismPortal2_FinalizeWithdrawal
}

/// @dev Tests that `depositTransaction` succeeds when a custom gas token is used but the msg.value is zero.
/// forge-config: ciheavy.fuzz.runs = 8192
function testFuzz_depositTransaction_customGasTokenWithNoValueAndSenderIsOrigin_succeeds(
address _to,
uint256 _value,
Expand All @@ -2004,7 +1997,6 @@ contract OptimismPortal2WithMockERC20_Test is OptimismPortal2_FinalizeWithdrawal
}

/// @dev Tests that `depositTransaction` succeeds when a custom gas token is used but the msg.value is zero.
/// forge-config: ciheavy.fuzz.runs = 8192
function testFuzz_depositTransaction_customGasTokenWithNoValueAndSenderNotOrigin_succeeds(
address _to,
uint256 _value,
Expand Down
3 changes: 0 additions & 3 deletions packages/contracts-bedrock/test/cannon/PreimageOracle.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,6 @@ contract PreimageOracle_LargePreimageProposals_Test is Test {

/// @notice Tests that squeezing a large preimage proposal after the challenge period has passed always succeeds and
/// persists the correct data.
/// forge-config: ciheavy.fuzz.runs = 512
function testFuzz_squeezeLPP_succeeds(uint256 _numBlocks, uint32 _partOffset) public {
_numBlocks = bound(_numBlocks, 1, 2 ** 8);
_partOffset = uint32(bound(_partOffset, 0, _numBlocks * LibKeccak.BLOCK_SIZE_BYTES + 8 - 1));
Expand Down Expand Up @@ -1087,7 +1086,6 @@ contract PreimageOracle_LargePreimageProposals_Test is Test {

/// @notice Tests that challenging the first divergence in a large preimage proposal at an arbitrary location
/// in the leaf values always succeeds.
/// forge-config: ciheavy.fuzz.runs = 512
function testFuzz_challenge_arbitraryLocation_succeeds(uint256 _lastCorrectLeafIdx, uint256 _numBlocks) public {
_numBlocks = bound(_numBlocks, 1, 2 ** 8);
_lastCorrectLeafIdx = bound(_lastCorrectLeafIdx, 0, _numBlocks - 1);
Expand Down Expand Up @@ -1140,7 +1138,6 @@ contract PreimageOracle_LargePreimageProposals_Test is Test {
}

/// @notice Tests that challenging the a divergence in a large preimage proposal at the first leaf always succeeds.
/// forge-config: ciheavy.fuzz.runs = 1024
function testFuzz_challengeFirst_succeeds(uint256 _numBlocks) public {
_numBlocks = bound(_numBlocks, 1, 2 ** 8);

Expand Down
1 change: 0 additions & 1 deletion packages/contracts-bedrock/test/safe/LivenessGuard.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ contract LivenessGuard_FuzzOwnerManagement_Test is StdCheats, StdUtils, Liveness
mapping(address => uint256) privateKeys;

/// @dev Tests that the guard correctly manages the lastLive mapping when owners are added, removed, or swapped
/// forge-config: ciheavy.fuzz.runs = 8192
function testFuzz_ownerManagement_works(
uint256 initialOwners,
uint256 threshold,
Expand Down
2 changes: 0 additions & 2 deletions packages/contracts-bedrock/test/setup/DeployVariations.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@ contract DeployVariations_Test is CommonTest {
}
}

/// forge-config: ciheavy.fuzz.runs = 512
/// @dev It should be possible to enable Fault Proofs with any mix of CGT and Alt-DA.
function testFuzz_enableFaultProofs_succeeds(bool _enableCGT, bool _enableAltDa) public virtual {
enableAddOns(_enableCGT, _enableAltDa);

super.setUp();
}

/// forge-config: ciheavy.fuzz.runs = 512
/// @dev It should be possible to enable Fault Proofs and Interop with any mix of CGT and Alt-DA.
function test_enableInteropAndFaultProofs_succeeds(bool _enableCGT, bool _enableAltDa) public virtual {
enableAddOns(_enableCGT, _enableAltDa);
Expand Down

0 comments on commit 63bd680

Please sign in to comment.