diff --git a/content/60.test-and-debug/20.in-memory-node.md b/content/60.test-and-debug/20.in-memory-node.md index e6ee91a2..54db1524 100644 --- a/content/60.test-and-debug/20.in-memory-node.md +++ b/content/60.test-and-debug/20.in-memory-node.md @@ -130,7 +130,7 @@ era_test_node fork [network] This command starts the node, forked at the current head of the selected network. -You also have the option to specify a custom http endpoint and a custom forking height, like so: +You also have the option to specify a custom http endpoint and a custom forking height: ```bash era_test_node fork --fork-at 7000000 mainnet http://172.17.0.3:3060 @@ -146,8 +146,7 @@ era_test_node replay_tx sepolia-testnet 0x7119045573862797257e4441ff48bf5a3bc4d1 ``` For more detailed transaction information, such as call traces, add the `--show-calls` flag. -If you want to see ABI names, add the `--resolve-hashes` flag. -Here's an example: +If you want to see ABI names, add the `--resolve-hashes` flag: ```bash era_test_node --show-calls=user \ @@ -156,7 +155,7 @@ era_test_node --show-calls=user \ ``` Alternatively (if your node is already running) you can use `config_setShowCalls` and `config_setResolveHashes` RPC endpoints -to configure these values. Here's an example: +to configure these values: ```bash # era_test_node already running... @@ -253,42 +252,69 @@ Launch the local in-memory node: - Use curl to send a network call: - ```bash - curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_call","params":[{"to":"0xe1134444211593Cfda9fc9eCc7B43208615556E2", "data":"0x313ce567"}, "latest"],"id":1}' http://localhost:8011 - ``` - - Here's an example of what you should expect to see: - - ```bash - {"jsonrpc":"2.0","result":"0x0000000000000000000000000000000000000000000000000000000000000012","id":1} - ``` + ::code-group + ```bash [curl] + curl --request POST \ + --url http://localhost:8011 \ + --header 'Content-Type: application/json' \ + --data '{ + "jsonrpc": "2.0", + "id": 1, + "method": "eth_call", + "params": [ + { + "to":"0xe1134444211593Cfda9fc9eCc7B43208615556E2", + "data":"0x313ce567" + }, + "latest" + ] + }' + ``` + + ```bash [expected output] + { + "jsonrpc":"2.0", + "result":"0x0000000000000000000000000000000000000000000000000000000000000012", + "id":1 + } + ``` + :: - Use :external-link{text="foundry-zksync" href="https://github.com/matter-labs/foundry-zksync"}. Make sure to install and configure `foundry-zksync` before proceeding (for installation instructions, please see :external-link{text="Foundry with zkSync Era" href="https://github.com/matter-labs/foundry-zksync/tree/main#foundry-with-zksync-era-v01"}): - ```bash - zkcast call 0xe1134444211593Cfda9fc9eCc7B43208615556E2 "name()(string)" --rpc-url http://localhost:8011 - ``` + ::code-group - Here's an example of what you should expect to see: + ```bash [foundry-zksync] + zkcast call 0xe1134444211593Cfda9fc9eCc7B43208615556E2 \ + "name()(string)" \ + --rpc-url http://localhost:8011 + ``` - ```bash + ```bash [expected output] Uniswap ``` + :: + Retrieve the balance of a particular contract: - ```bash - zkcast call 0x40609141Db628BeEE3BfAB8034Fc2D8278D0Cc78 "balanceOf(address)(uint256)" 0x40609141Db628BeEE3BfAB8034Fc2D8278D0Cc78 --rpc-url http://localhost:8011 - ``` + ::code-group - Here's an example of what you should expect to see: + ```bash [foundry-zksync] + zkcast call 0x40609141Db628BeEE3BfAB8034Fc2D8278D0Cc78 \ + "balanceOf(address)(uint256)" \ + 0x40609141Db628BeEE3BfAB8034Fc2D8278D0Cc78 \ + --rpc-url http://localhost:8011 + ``` - ```bash + ```bash [expected output] 28762283719941475444443116625665 ``` + :: + --- ## Deploy contracts @@ -301,13 +327,17 @@ The following example will detail the process using `foundry-zksync`. Before proceeding, ensure that you've compiled your contracts using `zkforge zk-build`. For instructions on how to do this, please refer to :external-link{text="Compile with zkforge-zk-build" href="https://github.com/matter-labs/foundry-zksync?tab=readme-ov-file#compiling-contracts"}. -```bash -zkforge zkc contracts/Greeter.sol:Greeter --constructor-args "ZkSync and Foundry" --private-key 7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110 --rpc-url http://localhost:8011 --chain 260 -``` +::code-group -Here's an example of what you should expect to see: +```bash [foundry-zksync] +zkforge zkc contracts/Greeter.sol:Greeter \ + --constructor-args "ZkSync and Foundry" \ + --private-key 7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110 \ + --rpc-url http://localhost:8011 \ + --chain 260 +``` -```bash +```bash [expected output] Deploying contract... +-------------------------------------------------+ Contract successfully deployed to address: 0x0a40ecde17dc16c4001bf0e4f5d5ff1818219b3b @@ -318,6 +348,8 @@ Block Number: 8072361 +-------------------------------------------------+ ``` +:: + --- ## Test bootloader and system contracts @@ -377,7 +409,7 @@ This section demonstrates how to author and execute tests locally against `era_t 1. Add the following lines to your `package.json` in the root folder: - ```json + ```json [package.json] "scripts": { "test": "NODE_ENV=test hardhat test" } diff --git a/content/60.test-and-debug/40.hardhat.md b/content/60.test-and-debug/40.hardhat.md index ceb9577a..f7597cff 100644 --- a/content/60.test-and-debug/40.hardhat.md +++ b/content/60.test-and-debug/40.hardhat.md @@ -127,8 +127,8 @@ and deploying the `Greeter` contract. Let's refactor our test file with the provided script: ::drop-panel - ::panel{label="main.test.ts"} - ```typescript + ::panel{label="test/main.test.ts"} + ```typescript [main.test.ts] import { expect } from "chai"; import { Wallet, Provider, Contract } from "zksync-ethers"; import * as hre from "hardhat"; @@ -226,9 +226,9 @@ You should see the following output: ## Understanding the test file -Have a look at the `/test/main.test.ts` file's imports: +Have a look at the `test/main.test.ts` file's imports: -```typescript [/test/main.test.ts] +```typescript [test/main.test.ts] import { expect } from "chai"; import { Wallet, Provider, Contract } from "zksync-ethers"; import * as hre from "hardhat"; diff --git a/content/60.test-and-debug/50.foundry.md b/content/60.test-and-debug/50.foundry.md index bf4aa8b3..3515ce81 100644 --- a/content/60.test-and-debug/50.foundry.md +++ b/content/60.test-and-debug/50.foundry.md @@ -62,6 +62,7 @@ contract ContractBTest is Test { To initiate your tests, use the `forge test --zksync` command with the `--zksync` flag, or incorporate `vm.zkVm(true)` within your tests. This command automatically locates and executes tests across your source directory. + Here's an example of executing tests in a standard project setup: ```bash diff --git a/cspell-config/cspell-blockchain.txt b/cspell-config/cspell-blockchain.txt index 51bdc2a9..e2088ca0 100644 --- a/cspell-config/cspell-blockchain.txt +++ b/cspell-config/cspell-blockchain.txt @@ -1,9 +1,10 @@ blake2s256 +BoxUups +ethereum EVM evmla -ethereum -Initializable -initializable +Geth +gwei keccak merkle nomicfoundation @@ -11,17 +12,11 @@ nomiclabs uups satoshi Sepolia -nomicfoundation -NVMe -Weth -Geth -gwei sepolia solc Unifra Upgradability UUPS uups -BoxUups vyper -zkout +Weth diff --git a/cspell-config/cspell-dev.txt b/cspell-config/cspell-dev.txt index 9dcc3f5c..34f9493e 100644 --- a/cspell-config/cspell-dev.txt +++ b/cspell-config/cspell-dev.txt @@ -1,3 +1,5 @@ +Dockerized +dockerized Diataxis fontaine Nuxt @@ -7,6 +9,8 @@ nuxtdotjs nuxtjs !NuxtUI !NuxtContent +NVMe +postgres rocksdb Vue !vue diff --git a/cspell-config/cspell-misc.txt b/cspell-config/cspell-misc.txt index d13420cc..9d58c689 100644 --- a/cspell-config/cspell-misc.txt +++ b/cspell-config/cspell-misc.txt @@ -1,2 +1,4 @@ Hola +Initializable +initializable mundo diff --git a/cspell-config/cspell-zksync.txt b/cspell-config/cspell-zksync.txt index 52735d9a..53fcf0c7 100644 --- a/cspell-config/cspell-zksync.txt +++ b/cspell-config/cspell-zksync.txt @@ -2,15 +2,13 @@ boojum MatterLabs Zeek -MatterLabs zkcast ZKEVM +zkevm zkforge -zksolc -zkvyper zkout +zksolc zkSync zksync zksync-cli -zksync -zkevm +zkvyper diff --git a/cspell.json b/cspell.json index 64b962f8..f68c98e7 100644 --- a/cspell.json +++ b/cspell.json @@ -38,7 +38,8 @@ "typescript", "dict-zksync", "dict-blockchain", - "dict-dev" + "dict-dev", + "dict-misc" ], "dictionaryDefinitions": [ {