Skip to content

Commit

Permalink
test(vm): Deduplicate multivm tests (#3109)
Browse files Browse the repository at this point in the history
## What ❔

Deduplicates unit tests in the `multivm` crate by retaining a single
generic copy parameterized by a VM (with test-specific functionality
encapsulated in a new `TestedVm` trait).

## Why ❔

2 copies of almost every test is difficult to maintain.

## Checklist

- [x] PR title corresponds to the body of PR (we generate changelog
entries from PRs).
- [x] Tests for the changes have been added / updated.
- [x] Documentation comments have been added / updated.
- [x] Code has been formatted via `zkstack dev fmt` and `zkstack dev
lint`.
  • Loading branch information
slowli authored Oct 18, 2024
1 parent 4d283ca commit c488c55
Show file tree
Hide file tree
Showing 93 changed files with 4,652 additions and 8,826 deletions.
12 changes: 12 additions & 0 deletions core/lib/multivm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,15 @@ This crate represents a wrapper over several versions of VM that have been used
glue code that allows switching the VM version based on the externally provided marker while preserving the public
interface. This crate exists to enable the external node to process breaking upgrades and re-execute all the
transactions from the genesis block.

## Developer guidelines

### Adding tests

If you want to add unit tests for the VM wrapper, consider the following:

- Whenever possible, make tests reusable; declare test logic in the [`testonly`](src/versions/testonly/mod.rs) module,
and then instantiate tests using this logic for the supported VM versions. If necessary, extend the tested VM trait so
that test logic can be defined in a generic way. See the `testonly` module docs for more detailed guidelines.
- Do not use an RNG where it can be avoided (e.g., for test contract addresses).
- Avoid using zero / default values in cases they can be treated specially by the tested code.
17 changes: 0 additions & 17 deletions core/lib/multivm/src/versions/README.md

This file was deleted.

2 changes: 0 additions & 2 deletions core/lib/multivm/src/versions/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
mod shared;
#[cfg(test)]
mod testonly;
#[cfg(test)]
mod tests;
pub mod vm_1_3_2;
pub mod vm_1_4_1;
pub mod vm_1_4_2;
Expand Down
93 changes: 0 additions & 93 deletions core/lib/multivm/src/versions/testonly.rs

This file was deleted.

Loading

0 comments on commit c488c55

Please sign in to comment.