Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Admin AWS GPU committed Mar 1, 2024
1 parent 8a61c2d commit 06182b0
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
39 changes: 39 additions & 0 deletions plonky2/tests/range_check_test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
use anyhow::Result;
use plonky2::field::types::Field;
use plonky2::iop::witness::{PartialWitness, WitnessWrite};
use plonky2::plonk::circuit_builder::CircuitBuilder;
use plonky2::plonk::circuit_data::CircuitConfig;
use plonky2::plonk::config::{GenericConfig, PoseidonGoldilocksConfig};
#[cfg(feature = "cuda")]
use crate::test_utils::init_cuda;
#[cfg(feature = "cuda")]
pub mod test_utils;

#[test]
fn test_range_check_proof() {
#[cfg(feature = "cuda")]
init_cuda();

const D: usize = 2;
type C = PoseidonGoldilocksConfig;
type F = <C as GenericConfig<D>>::F;

let config = CircuitConfig::standard_recursion_config();
let mut builder = CircuitBuilder::<F, D>::new(config);

// The secret value.
let value = builder.add_virtual_target();
builder.register_public_input(value);

let log_max = 6;
builder.range_check(value, log_max);

let mut pw = PartialWitness::new();
pw.set_target(value, F::from_canonical_usize(42));

let data = builder.build::<C>();
let proof = data.prove(pw).unwrap();


data.verify(proof);
}
1 change: 1 addition & 0 deletions run_proof_tests.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/sh -e
cargo test --package plonky2 --features=cuda,batch --release --test fibonacci_test -- test_fibonacci_proof --exact --nocapture
cargo test --package plonky2 --features=cuda,batch --release --test factorial_test -- test_factorial_proof --exact --nocapture
cargo test --package plonky2 --features=cuda,batch --release --test range_check_test -- test_range_check_proof --exact --nocapture

0 comments on commit 06182b0

Please sign in to comment.