Skip to content

Commit

Permalink
use executor in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nategraf committed Feb 16, 2024
1 parent 7c60d53 commit 39ec285
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Your new project consists of:

### Run the Tests

- Use `RISC0_DEV_MODE=true cargo test` to run the tests in your zkVM program.
- Use `cargo test` to run the tests in your zkVM program.
- Use `RISC0_DEV_MODE=true forge test -vvv` to test your Solidity contracts and their interaction with your zkVM program.

## Develop Your Application
Expand Down Expand Up @@ -148,4 +148,4 @@ Below are the primary files in the project directory
[deployment guide]: /deployment-guide.md
[Sepolia]: https://www.alchemy.com/overviews/sepolia-testnet
[RISC Zero installation]: https://dev.risczero.com/api/zkvm/install
[Publisher]: ./apps/README.md
[Publisher]: ./apps/README.md
10 changes: 6 additions & 4 deletions methods/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ include!(concat!(env!("OUT_DIR"), "/methods.rs"));
mod tests {
use alloy_primitives::U256;
use alloy_sol_types::SolValue;
use risc0_zkvm::{default_prover, ExecutorEnv};
use risc0_zkvm::{default_executor, ExecutorEnv};

#[test]
fn proves_even_number() {
Expand All @@ -30,9 +30,10 @@ mod tests {
.build()
.unwrap();

let receipt = default_prover().prove(env, super::IS_EVEN_ELF).unwrap();
// NOTE: Use the executor to run tests without proving.
let session_info = default_executor().execute(env, super::IS_EVEN_ELF).unwrap();

let x = U256::abi_decode(&receipt.journal.bytes, true).unwrap();
let x = U256::abi_decode(&session_info.journal.bytes, true).unwrap();
assert_eq!(x, even_number);
}

Expand All @@ -46,6 +47,7 @@ mod tests {
.build()
.unwrap();

default_prover().prove(env, super::IS_EVEN_ELF).unwrap();
// NOTE: Use the executor to run tests without proving.
default_executor().execute(env, super::IS_EVEN_ELF).unwrap();
}
}

0 comments on commit 39ec285

Please sign in to comment.