Skip to content

Commit

Permalink
add proptest
Browse files Browse the repository at this point in the history
  • Loading branch information
zemse committed Dec 9, 2024
1 parent c4a6f09 commit 3c38d5d
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 5 deletions.
91 changes: 91 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions ceno_zkvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ generic_static = "0.2"
rand.workspace = true
tempfile = "3.14"
thread_local = "1.1"
proptest = "1.5.0"

[dev-dependencies]
cfg-if.workspace = true
Expand Down
11 changes: 6 additions & 5 deletions ceno_zkvm/src/instructions/riscv/slt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ mod test {

use rand::Rng;

use proptest::prelude::*;

use super::*;
use crate::{
circuit_builder::{CircuitBuilder, ConstraintSystem},
Expand Down Expand Up @@ -244,10 +246,9 @@ mod test {

#[test]
fn test_sltu_random() {
let mut rng = rand::thread_rng();
let a: u32 = rng.gen();
let b: u32 = rng.gen();
verify::<SltuOp>("random 1", a, b, (a < b) as u32);
verify::<SltuOp>("random 2", b, a, (a >= b) as u32);
proptest::proptest!(|(a in any::<u32>(), b in any::<u32>())| {
verify::<SltuOp>("random 1", a, b, (a < b) as u32);
verify::<SltuOp>("random 2", b, a, (a >= b) as u32);
});
}
}

0 comments on commit 3c38d5d

Please sign in to comment.