Commit 839d3821 authored by smartcontracts's avatar smartcontracts Committed by GitHub

feat: contracts dev build and test commands (#13345)

Adds new dev commands that use the lite profile to execute
everything and ultimately reduce compile time by several minutes.
parent be083a02
...@@ -15,13 +15,20 @@ dep-status: ...@@ -15,13 +15,20 @@ dep-status:
# BUILD # # BUILD #
######################################################## ########################################################
# Core forge build command # Core forge build command.
forge-build: forge-build:
forge build forge build
# Developer build command (faster).
forge-build-dev:
FOUNDRY_PROFILE=lite forge build
# Builds the contracts. # Builds the contracts.
build: lint-fix-no-fail forge-build interfaces-check-no-build build: lint-fix-no-fail forge-build interfaces-check-no-build
# Builds the contracts (developer mode).
build-dev: lint-fix-no-fail forge-build-dev interfaces-check-no-build
# Builds the go-ffi tool for contract tests. # Builds the go-ffi tool for contract tests.
build-go-ffi-default: build-go-ffi-default:
cd ./scripts/go-ffi && go build cd ./scripts/go-ffi && go build
...@@ -45,10 +52,18 @@ clean: ...@@ -45,10 +52,18 @@ clean:
test *ARGS: build-go-ffi test *ARGS: build-go-ffi
forge test {{ARGS}} forge test {{ARGS}}
# Runs standard contract tests (developer mode).
test-dev *ARGS: build-go-ffi
FOUNDRY_PROFILE=lite forge test {{ARGS}}
# Runs standard contract tests with rerun flag. # Runs standard contract tests with rerun flag.
test-rerun: build-go-ffi test-rerun: build-go-ffi
forge test --rerun -vvv forge test --rerun -vvv
# Runs standard contract tests with rerun flag (developer mode).
test-dev-rerun: build-go-ffi
FOUNDRY_PROFILE=lite forge test --rerun -vvv
# Run Kontrol tests and build all dependencies. # Run Kontrol tests and build all dependencies.
test-kontrol: build-go-ffi build kontrol-summary-full test-kontrol-no-build test-kontrol: build-go-ffi build kontrol-summary-full test-kontrol-no-build
......
// SPDX-License-Identifier: UNLICENSED // SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.15; pragma solidity 0.8.15;
// Testing utilities // Forge
import { Test } from "forge-std/Test.sol"; import { Test } from "forge-std/Test.sol";
import { VmSafe } from "forge-std/Vm.sol"; import { VmSafe } from "forge-std/Vm.sol";
// Target contract // Scripts
import { IL1ChugSplashProxy } from "interfaces/legacy/IL1ChugSplashProxy.sol";
import { DeployUtils } from "scripts/libraries/DeployUtils.sol"; import { DeployUtils } from "scripts/libraries/DeployUtils.sol";
// Libraries
import { LibString } from "@solady/utils/LibString.sol";
// Interfaces
import { IL1ChugSplashProxy } from "interfaces/legacy/IL1ChugSplashProxy.sol";
contract Owner { contract Owner {
bool public isUpgrading; bool public isUpgrading;
...@@ -103,7 +108,10 @@ contract L1ChugSplashProxy_Test is Test { ...@@ -103,7 +108,10 @@ contract L1ChugSplashProxy_Test is Test {
// Because forge coverage always runs with the optimizer disabled, // Because forge coverage always runs with the optimizer disabled,
// if forge coverage is run before testing this with forge test or forge snapshot, forge clean should be // if forge coverage is run before testing this with forge test or forge snapshot, forge clean should be
// run first so that it recompiles the contracts using the foundry.toml optimizer settings. // run first so that it recompiles the contracts using the foundry.toml optimizer settings.
if (vm.isContext(VmSafe.ForgeContext.Coverage)) { if (
vm.isContext(VmSafe.ForgeContext.Coverage)
|| LibString.eq(vm.envOr("FOUNDRY_PROFILE", string("default")), "lite")
) {
gasLimit = 95_000; gasLimit = 95_000;
} else if (vm.isContext(VmSafe.ForgeContext.Test) || vm.isContext(VmSafe.ForgeContext.Snapshot)) { } else if (vm.isContext(VmSafe.ForgeContext.Test) || vm.isContext(VmSafe.ForgeContext.Snapshot)) {
gasLimit = 65_000; gasLimit = 65_000;
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity 0.8.15; pragma solidity 0.8.15;
// Testing utilities // Forge
import { Test } from "forge-std/Test.sol"; import { Test } from "forge-std/Test.sol";
import { VmSafe } from "forge-std/Vm.sol"; import { VmSafe } from "forge-std/Vm.sol";
import { StdCheatsSafe } from "forge-std/StdCheats.sol"; import { StdCheatsSafe } from "forge-std/StdCheats.sol";
// Target contract // Libraries
import { LibString } from "@solady/utils/LibString.sol";
import { SafeCall } from "src/libraries/SafeCall.sol"; import { SafeCall } from "src/libraries/SafeCall.sol";
contract SafeCall_Test is Test { contract SafeCall_Test is Test {
...@@ -133,7 +134,10 @@ contract SafeCall_Test is Test { ...@@ -133,7 +134,10 @@ contract SafeCall_Test is Test {
// Because forge coverage always runs with the optimizer disabled, // Because forge coverage always runs with the optimizer disabled,
// if forge coverage is run before testing this with forge test or forge snapshot, forge clean should be // if forge coverage is run before testing this with forge test or forge snapshot, forge clean should be
// run first so that it recompiles the contracts using the foundry.toml optimizer settings. // run first so that it recompiles the contracts using the foundry.toml optimizer settings.
if (vm.isContext(VmSafe.ForgeContext.Coverage)) { if (
vm.isContext(VmSafe.ForgeContext.Coverage)
|| LibString.eq(vm.envOr("FOUNDRY_PROFILE", string("default")), "lite")
) {
// 66_290 is the exact amount of gas required to make the safe call // 66_290 is the exact amount of gas required to make the safe call
// successfully with the optimizer disabled (ran via forge coverage) // successfully with the optimizer disabled (ran via forge coverage)
expected = 66_290; expected = 66_290;
...@@ -173,7 +177,10 @@ contract SafeCall_Test is Test { ...@@ -173,7 +177,10 @@ contract SafeCall_Test is Test {
// Because forge coverage always runs with the optimizer disabled, // Because forge coverage always runs with the optimizer disabled,
// if forge coverage is run before testing this with forge test or forge snapshot, forge clean should be // if forge coverage is run before testing this with forge test or forge snapshot, forge clean should be
// run first so that it recompiles the contracts using the foundry.toml optimizer settings. // run first so that it recompiles the contracts using the foundry.toml optimizer settings.
if (vm.isContext(VmSafe.ForgeContext.Coverage)) { if (
vm.isContext(VmSafe.ForgeContext.Coverage)
|| LibString.eq(vm.envOr("FOUNDRY_PROFILE", string("default")), "lite")
) {
// 15_278_989 is the exact amount of gas required to make the safe call // 15_278_989 is the exact amount of gas required to make the safe call
// successfully with the optimizer disabled (ran via forge coverage) // successfully with the optimizer disabled (ran via forge coverage)
expected = 15_278_989; expected = 15_278_989;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment