Skip to content

Commit d2184d0

Browse files
authored
test: Introduce TestingFramework struct (#532)
## What ❔ Additional layer of abstraction between tests and `Chain`. This is an intermediate step - in following PRs I will better separate concerns between `Chain` and `TestingFramework`. Additionally this separation will make RevmRunner integration easier and more effective. Note that in this PR we'll change how testing works in general - by default locally RISC-V simulation will be disabled, it will be enabled in CI. This change makes testing setup a bit more friendly for AI agents. ## Why ❔ <!-- Why are these changes done? What goal do they contribute to? What are the principles behind them? --> <!-- The `Why` has to be clear to non-Matter Labs entities running their own ZK Chain --> <!-- Example: PR templates ensure PR reviewers, observers, and future iterators are in context about the evolution of repos. --> ## Is this a breaking change? - [ ] Yes - [X] No ## Checklist <!-- Check your PR fulfills the following items. --> <!-- For draft PRs check the boxes as you complete them. --> - [X] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [ ] Tests for the changes have been added / updated. - [X] Documentation comments have been added / updated. - [X] Code has been formatted.
1 parent b722dbb commit d2184d0

File tree

38 files changed

+3038
-6891
lines changed

38 files changed

+3038
-6891
lines changed

.github/workflows/bench.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55

66
permissions: read-all
77

8+
env:
9+
ZKSYNC_RISC_V_RUN: true
10+
CI: true
11+
812
# Cancel previous runs that might be caused by appbin update
913
concurrency:
1014
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}

.github/workflows/ci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ permissions: read-all
88

99
env:
1010
CARGO_INCREMENTAL: 0
11+
ZKSYNC_RISC_V_RUN: true
12+
CI: true
1113

1214
# Cancel previous runs that might be caused by appbin update
1315
concurrency:
@@ -41,7 +43,7 @@ jobs:
4143
- name: Compile
4244
run: cargo test --release --no-run
4345
- name: Run rust tests
44-
run: cargo test --release -j 3 -- --skip verify_default_binaries
46+
run: cargo test --release -j 3
4547
crypto_test:
4648
name: crypto crate tests
4749
runs-on: [matterlabs-ci-runner]
@@ -101,7 +103,7 @@ jobs:
101103
./dump_bin.sh --type singleblock-batch
102104
./dump_bin.sh --type multiblock-batch
103105
- name: Run binary checker
104-
run: cargo test -p binary_checker -- --nocapture
106+
run: cargo test -p binary_checker -- --nocapture --ignored
105107

106108
e2e_prove:
107109
name: e2e_prove

.github/workflows/evm_terster_proof_run.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77

88
permissions: read-all
99

10+
env:
11+
ZKSYNC_RISC_V_RUN: true
12+
CI: true
13+
1014
jobs:
1115
evm_state_tests:
1216
name: EF EVM state tests with proof run

.github/workflows/fuzz.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77

88
permissions: read-all
99

10+
env:
11+
ZKSYNC_RISC_V_RUN: true
12+
CI: true
13+
1014
jobs:
1115
build-fuzz-targets:
1216
name: Build fuzz targets

AGENTS.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,22 @@ cd zksync_os && ./dump_bin.sh --type for-tests
7272
### Testing Infrastructure
7373

7474
#### Integration tests
75-
The project uses a custom testing rig located in `tests/rig/` with the main abstraction being the `Chain` struct for in-memory chain state testing. Tests are organized in `tests/instances/` and follow this pattern:
75+
The project uses a custom testing rig located in `tests/rig/` with the main abstraction being the `TestingFramework` struct. Tests are organized in `tests/instances/` and follow this pattern:
7676
1. Set up initial chain state (predeployed contracts, balances)
7777
2. Define transactions to execute
78-
3. Call `run_block` to execute (typically runs both forward and proof systems, unless configured otherwise)
78+
3. Call `execute_block` to execute (typically runs both forward and proof systems, unless configured otherwise)
79+
80+
Avoid direct `Chain` usage in test instances unless a low-level path is explicitly needed.
81+
82+
To run rig-based tests without detailed executions logs use:
83+
```bash
84+
cargo test -p <crate-name> --features rig/no_print
85+
```
86+
87+
By default, local rig runs skip RISC-V simulation unless `ZKSYNC_RISC_V_RUN` or `CI` is set. To force proving-mode simulation locally use:
88+
```bash
89+
ZKSYNC_RISC_V_RUN=true cargo test -p <crate-name>
90+
```
7991

8092
#### EVM tester
8193
The EVM tester is used to run the Ethereum execution spec tests to check the EVM compatibility of ZKsync OS.

tests/binary_checker/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ mod tests {
3939
}
4040

4141
#[test]
42+
#[ignore = "runs only on CI / explicit opt-in"]
4243
fn verify_default_binaries() {
4344
verify_binary("singleblock_batch.text");
4445
verify_binary("multiblock_batch.text")

tests/common/src/zksync_tx/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub mod service_tx;
1717
pub mod upgrade_tx;
1818

1919
/// Wrapper over all tx envelope kinds we feed into ZKsync OS.
20+
#[derive(Clone)]
2021
pub enum ZKsyncTxEnvelope {
2122
/// Standard Ethereum typed envelope signed by the corresponding address.
2223
Ethereum(TxEnvelope, Address),
@@ -114,6 +115,7 @@ impl From<ZKsyncServiceTx> for ZKsyncTxEnvelope {
114115
}
115116

116117
/// ZKsync OS specific transactions wrapper.
118+
#[derive(Clone)]
117119
pub enum ZKsyncSpecificTxEnvelope {
118120
L1(ZKsyncL1Tx),
119121
Upgrade(ZKsyncUpgradeTx),

0 commit comments

Comments
 (0)