Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
itsacoyote committed Apr 16, 2024
1 parent 832353d commit 6ff1a5a
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 49 deletions.
90 changes: 61 additions & 29 deletions content/60.test-and-debug/20.in-memory-node.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 \
Expand All @@ -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...
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -318,6 +348,8 @@ Block Number: 8072361
+-------------------------------------------------+
```
::
---
## Test bootloader and system contracts
Expand Down Expand Up @@ -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"
}
Expand Down
8 changes: 4 additions & 4 deletions content/60.test-and-debug/40.hardhat.md
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand Down
1 change: 1 addition & 0 deletions content/60.test-and-debug/50.foundry.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 5 additions & 10 deletions cspell-config/cspell-blockchain.txt
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
blake2s256
BoxUups
ethereum
EVM
evmla
ethereum
Initializable
initializable
Geth
gwei
keccak
merkle
nomicfoundation
nomiclabs
uups
satoshi
Sepolia
nomicfoundation
NVMe
Weth
Geth
gwei
sepolia
solc
Unifra
Upgradability
UUPS
uups
BoxUups
vyper
zkout
Weth
4 changes: 4 additions & 0 deletions cspell-config/cspell-dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Dockerized
dockerized
Diataxis
fontaine
Nuxt
Expand All @@ -7,6 +9,8 @@ nuxtdotjs
nuxtjs
!NuxtUI
!NuxtContent
NVMe
postgres
rocksdb
Vue
!vue
Expand Down
2 changes: 2 additions & 0 deletions cspell-config/cspell-misc.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
Hola
Initializable
initializable
mundo
8 changes: 3 additions & 5 deletions cspell-config/cspell-zksync.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
boojum
MatterLabs
Zeek
MatterLabs
zkcast
ZKEVM
zkevm
zkforge
zksolc
zkvyper
zkout
zksolc
zkSync
zksync
zksync-cli
zksync
zkevm
zkvyper
3 changes: 2 additions & 1 deletion cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"typescript",
"dict-zksync",
"dict-blockchain",
"dict-dev"
"dict-dev",
"dict-misc"
],
"dictionaryDefinitions": [
{
Expand Down

0 comments on commit 6ff1a5a

Please sign in to comment.