1/5
## zkSync Testing We have learned about using a mock network to test our code. This is useful because it allows us to test our code without having to deploy it to a live network. We can also test our code against zkSync if we have the zkSync prerequisites installed. First, we need to check the version of the zkSync node and zkVyper: ```bash era test node --version ``` ```bash zkVyper --version ``` Once we have those installed, we can run the following command to test our code against the zkSync network: ```bash mox test --network eravm ``` This will spin up a fake zkSync network, allowing us to test our code against zkSync without deploying it to a live network. To further test our code, we also need to ensure we are correctly handling the `not enough balance` error. We can fix this by adding some code to our tests. For example, in the `conftest.py` file, we can add a line of code to set the balance of an account to 10 times the `SEND_VALUE`: ```python boa.env.set_balance(account.address, SEND_VALUE * 10) ``` Then, in the `test_unit_coffee.py` file, we can add a line of code to set the balance of an account to 3 times the `SEND_VALUE`: ```python boa.env.set_balance(account.address, SEND_VALUE * 3) ``` Running our tests again, we can see that all our tests pass. We have now tested our code against the zkSync network and ensured that it handles the `not enough balance` error correctly. We can also see that our tests run on zkSync as they now display the expected information in the terminal. We are now confident that our code is working correctly on zkSync!
A comprehensive guide to testing your smart contract against zkSync. This video covers deploying and testing smart contracts using a mocked zkSync network with different test scenarios including funding the contract and withdrawing funds from the contract.
Previous lesson
Previous
Next lesson
Next
Give us feedback
Course Overview
About the course
Python basics
Introduction to Web3.py
Introduction to Titanoboa
Introduction to Moccasin
How to create an ERC-20
How to test Python code and Vyper smart contract
How to deploy Vyper smart contracts on ZKsync using Moccasin
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
On-chain Data Analyst
$59,000 - $139,000 (avg. salary)
DeFi Developer
$75,000 - $200,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)
Last updated on April 21, 2025
Duration: 2h 20min
Duration: 1h 51min
Duration: 58min
Duration: 2h 23min
Duration: 53min
Duration: 2h 24min
Duration: 28min
Duration: 1h 54min
Duration: 11min
Course Overview
About the course
Python basics
Introduction to Web3.py
Introduction to Titanoboa
Introduction to Moccasin
How to create an ERC-20
How to test Python code and Vyper smart contract
How to deploy Vyper smart contracts on ZKsync using Moccasin
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
On-chain Data Analyst
$59,000 - $139,000 (avg. salary)
DeFi Developer
$75,000 - $200,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)
Last updated on April 21, 2025
Testimonials
Read what our students have to say about this course.
Chainlink
Chainlink
Gustavo Gonzalez
Solutions Engineer at OpenZeppelin
Francesco Andreoli
Lead Devrel at Metamask
Albert Hu
DeForm Founding Engineer
Radek
Senior Developer Advocate at Ceramic
Boidushya
WalletConnect
Idris
Developer Relations Engineer at Axelar