5/5
_Follow along with the video_ --- ### Introduction There are notable differences between the EVM and ZKsync Era VM, as detailed in the [ZKsync documentation](https://docs.zksync.io/build/developer-reference/ethereum-differences/evm-instructions). In this lesson, we will explore some DevOps tools designed to help run tests and functions on both VMs. ### `foundry-devops` Tools In the `FundMeTest.t.sol` file, certain tests that run on Vanilla Foundry may not work on ZKsync Foundry, and vice versa. To address these differences, we will explore two packages from the [foundry-devops](https://github.com/Cyfrin/foundry-devops) repository: `ZkSyncChainChecker` and `FoundryZkSyncChecker`. This lesson will cover how to use these packages effectively. ```js import { ZkSyncChainChecker } from "lib/foundry-devops/src/ZkSyncChainChecker.sol"; import { FoundryZkSyncChecker } from "lib/foundry-devops/src/FoundryZkSyncChecker.sol"; ``` ### Setting Up ZkSyncDevOps The file [`test/unit/ZkSyncDevOps.t.sol`](https://github.com/Cyfrin/foundry-fund-me-cu/blob/main/test/unit/ZkSyncDevOps.t.sol) is a minimal test file that shows how tests may fail on the ZKsync VM but pass on an EVM, or vice versa. You can follow these steps to set it up: 1. Copy the content from the GitHub repo into your project's `test/unit` directory, and create a new file named `ZkSyncDevOps.t.sol`. 2. Install any missing dependencies using the command: ```bash forge install cyfrin/foundry-devops@0.2.2 --no-commit ``` 3. Reset your modules with: ```bash rm -rf .gitmodules && rm -rf .git/modules/* && rm -rf lib && touch .gitmodules && git add . && git commit -m "modules" ``` or ```bash make rm ``` 4. Update your `.gitignore` file by adding `.DS_store` and `zkout/`. ### VM environments modifiers You can switch environments between `fundryup` and `fundryup-zksync` to observe different behaviors of the `ZkSyncDevOps.t.sol` tests. For instance, the following command ```bash forge test --mt testZkSyncChainFails -vvv ``` will pass in both Foundry environments. However, if you remove the `skipZkSync` modifier, the test will fail on ZKsync because the content of the function is not supported on this chain. For more details on these modifiers, refer to the [foundry-devops repo](https://github.com/Cyfrin/foundry-devops?tab=readme-ov-file#usage---zksync-checker). The `skipzksync` modifier skips tests on the ZKsync chain, while `onlyzksync` runs tests only on a ZKsync-based chain. ### Foundry version modifiers Some tests may fail depending on the Foundry version. The `FoundryZkSyncChecker` package assists in executing functions based on the Foundry version. The `onlyFoundryZkSync` modifier allows tests to run only if `foundryup--zksync` is active, while `onlyVanillaFoundry` works only if `foundryup` is active. > 🗒️ **Note**:br > Ensure `ffi = true` is enabled in the `foundry.toml` file.
Follow along with the video
There are notable differences between the EVM and ZKsync Era VM, as detailed in the ZKsync documentation. In this lesson, we will explore some DevOps tools designed to help run tests and functions on both VMs.
foundry-devops
ToolsIn the FundMeTest.t.sol
file, certain tests that run on Vanilla Foundry may not work on ZKsync Foundry, and vice versa. To address these differences, we will explore two packages from the foundry-devops repository: ZkSyncChainChecker
and FoundryZkSyncChecker
. This lesson will cover how to use these packages effectively.
The file test/unit/ZkSyncDevOps.t.sol
is a minimal test file that shows how tests may fail on the ZKsync VM but pass on an EVM, or vice versa. You can follow these steps to set it up:
Copy the content from the GitHub repo into your project's test/unit
directory, and create a new file named ZkSyncDevOps.t.sol
.
Install any missing dependencies using the command:
Reset your modules with:
or
Update your .gitignore
file by adding .DS_store
and zkout/
.
You can switch environments between fundryup
and fundryup-zksync
to observe different behaviors of the ZkSyncDevOps.t.sol
tests. For instance, the following command
will pass in both Foundry environments. However, if you remove the skipZkSync
modifier, the test will fail on ZKsync because the content of the function is not supported on this chain.
For more details on these modifiers, refer to the foundry-devops repo. The skipzksync
modifier skips tests on the ZKsync chain, while onlyzksync
runs tests only on a ZKsync-based chain.
Some tests may fail depending on the Foundry version. The FoundryZkSyncChecker
package assists in executing functions based on the Foundry version. The onlyFoundryZkSync
modifier allows tests to run only if foundryup--zksync
is active, while onlyVanillaFoundry
works only if foundryup
is active.
🗒️ Note:br
Ensureffi = true
is enabled in thefoundry.toml
file.
An essential guide to Robust Foundry Testing for EVM and zkSync - Master conditional testing techniques for contracts targeting both EVM and zkSync environments using Foundry. Leverage `cyfrin/foundry-devops` helpers like `skipZkSync` and `onlyZkSync` to ensure tests run appropriately based on the execution context.
Previous lesson
Previous
Next lesson
Next
Give us feedback
Course Overview
About the course
Foundryup, Foundry Forge, and Anvil
Blockchain Oracles
How to create local Blockchain testnets
How to verify a smart contract
How to write and run smart contract tests
Security researcher
$49,999 - $120,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Guest lecturers:
Last updated on June 10, 2025
Duration: 2h 55min
Duration: 2h 56min
Duration: 26min
Duration: 5h 22min
Course Overview
About the course
Foundryup, Foundry Forge, and Anvil
Blockchain Oracles
How to create local Blockchain testnets
How to verify a smart contract
How to write and run smart contract tests
Security researcher
$49,999 - $120,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Guest lecturers:
Last updated on June 10, 2025