Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,37 @@ jobs:
env:
RISC0_DEV_MODE: 1

local-sequencer-integration-tests:
name: Local Sequencer Integration Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: ./.github/actions/install-risc0

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: "1.94.0"

- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
~/.cache/lez-programs/local-sequencer
target
key: ${{ runner.os }}-cargo-local-sequencer-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-local-sequencer-
${{ runner.os }}-cargo-

- name: Local sequencer integration tests
run: cargo run -p local-sequencer -- test
env:
RISC0_DEV_MODE: 1
RUST_TEST_THREADS: 1

check-idl:
name: Check IDL
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ programs/
methods/ # Host-side zkVM method embedding
methods/guest/ # Guest binary (separate workspace)
integration_tests/
tests/ # End-to-end tests through the zkVM (token, amm, ata)
tests/ # End-to-end tests through the zkVM (token, amm, ata, stablecoin)
apps/
amm/ # QML-based UI for the AMM program (Nix flake)
```
Expand Down
146 changes: 146 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ members = [
"programs/stablecoin/methods",
"programs/integration_tests",
"tools/idl-gen",
"tools/local-sequencer",
]
exclude = [
"programs/token/methods/guest",
Expand Down Expand Up @@ -45,6 +46,11 @@ borsh = { version = "1.5", features = ["derive"] }
risc0-zkvm = { version = "=3.0.5" }
serde_json = "1.0"
tokio = { version = "1.28.2", features = ["net", "rt-multi-thread", "sync", "macros"] }
base64 = "0.22"
rocksdb = { version = "0.24.0", default-features = false, features = [
"snappy",
"bindgen-runtime",
] }

[workspace.lints.rust]
rust_2018_idioms = { level = "deny", priority = -1 }
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

clippy:
RISC0_SKIP_BUILD=1 cargo clippy --workspace --all-targets -- -D warnings
RISC0_SKIP_BUILD=1 cargo clippy -p integration_tests --all-targets --features local-sequencer-tests -- -D warnings

clippy-guest:
for manifest in programs/*/methods/guest/Cargo.toml; do \
Expand Down
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,28 @@ RISC0_DEV_MODE=1 cargo test -p token_program -p amm_program -p ata_program -p st
# Run integration tests (dev mode skips ZK proof generation)
RISC0_DEV_MODE=1 cargo test -p integration_tests

# Clone/build the pinned standalone LEZ sequencer, then run integration tests through it
cargo run -p local-sequencer -- test

# Or reuse an existing pinned LEZ checkout with the standalone sequencer already built
LEZ_LOCAL_SEQUENCER_REPO=/path/to/logos-execution-zone RISC0_DEV_MODE=1 RUST_TEST_THREADS=1 cargo test -p integration_tests --features local-sequencer-tests -- --nocapture

# Run all tests
make test
```

Integration tests live in `programs/integration_tests/tests/` and cover `token`, `amm`, and `ata` programs end-to-end through the zkVM using `RISC0_DEV_MODE=1` to skip proof generation. Each test file corresponds to a program:
The local-sequencer feature mirrors every transition through a spawned sequencer: each transition is submitted to the sequencer and its commit-or-reject outcome is asserted to match the in-process result. Account and proof *equality* are additionally checked when tests call `get_account_by_id` or `get_proof_for_commitment`; force-insert-only setup and tests that never read state still mirror their transitions but skip the equality comparison. Each `TestState` spawns its own sequencer process, so `cargo run -p local-sequencer -- test` defaults to `RUST_TEST_THREADS=1` (export a different value to override); when invoking `cargo test` directly, set `RUST_TEST_THREADS=1` on constrained machines or when serial execution is preferred.

`LEZ_LOCAL_SEQUENCER_REPO` may point at any clean LEZ checkout whose `HEAD` matches the pinned ref; its git origin does not need to match this workspace's Cargo source. `LEZ_LOCAL_SEQUENCER_SOURCE` only applies when the helper creates or updates its managed cache checkout. Set `LEZ_LOCAL_SEQUENCER_REF` when using a nonstandard or vendored manifest where the pinned tag cannot be parsed.

Integration tests live in `programs/integration_tests/tests/` and cover `token`, `amm`, `ata`, and `stablecoin` programs end-to-end through the zkVM using `RISC0_DEV_MODE=1` to skip proof generation. Each test file corresponds to a program:

- `programs/integration_tests/tests/token.rs`
- `programs/integration_tests/tests/amm.rs`
- `programs/integration_tests/tests/ata.rs`
- `programs/integration_tests/tests/stablecoin.rs`

`stablecoin` and `twap_oracle` are tested via their own unit tests (`cargo test -p stablecoin_program -p twap_oracle_program`).
`twap_oracle` is tested via its own unit tests (`cargo test -p twap_oracle_program`).

## Compile Guest Binaries

Expand Down
12 changes: 12 additions & 0 deletions programs/integration_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,20 @@ edition = "2021"
[lints]
workspace = true

[features]
local-sequencer-tests = [
"dep:base64",
"dep:borsh",
"dep:rocksdb",
"dep:serde_json",
]

[dependencies]
nssa = { workspace = true }
nssa_core = { workspace = true, features = ["host"] }
base64 = { workspace = true, optional = true }
borsh = { workspace = true, optional = true }
rocksdb = { workspace = true, optional = true }
amm_core = { workspace = true }
token_core = { workspace = true }
ata_core = { workspace = true }
Expand All @@ -17,3 +28,4 @@ token-methods = { path = "../token/methods" }
amm-methods = { path = "../amm/methods" }
ata-methods = { path = "../ata/methods" }
stablecoin-methods = { path = "../stablecoin/methods" }
serde_json = { workspace = true, optional = true }
7 changes: 7 additions & 0 deletions programs/integration_tests/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
#[cfg(feature = "local-sequencer-tests")]
mod local_sequencer;

#[cfg(feature = "local-sequencer-tests")]
pub use local_sequencer::TestState;

#[cfg(not(feature = "local-sequencer-tests"))]
pub type TestState = nssa::V03State;
Loading
Loading