Skip to content

Commit

Permalink
add a test for a non self-evaluating expression
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurpaulino committed Nov 1, 2023
1 parent 4de2de2 commit 637ab79
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/lem/multiframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,7 @@ where

#[cfg(test)]
mod tests {
use bellpepper_core::test_cs::TestConstraintSystem;
use pasta_curves::Fq;

use crate::{
Expand Down Expand Up @@ -1014,4 +1015,33 @@ mod tests {
assert_eq!(x.hash().get_value(), y.hash().get_value());
}
}

#[test]
fn non_self_evaluating() {
let store = Store::default();

// not self-evaluating
let expr = store.read_with_default_state("(+ 1 2)").unwrap();

let lang = Arc::new(Lang::<Fq, Coproc<Fq>>::new());
let (mut frames, _) = evaluate::<Fq, Coproc<Fq>>(None, expr, &store, 1).unwrap();
assert_eq!(frames.len(), 1);

Check warning on line 1028 in src/lem/multiframe.rs

View check run for this annotation

Codecov / codecov/patch

src/lem/multiframe.rs#L1019-L1028

Added lines #L1019 - L1028 were not covered by tests

let mut frame = frames.pop().unwrap();
// faking a trivial evaluation frame
frame.output = vec![expr, store.intern_nil(), store.cont_terminal()];

let mut cs = TestConstraintSystem::<Fq>::new();

let folding_config = Arc::new(FoldingConfig::new_ivc(lang.clone(), 1));

store.hydrate_z_cache();
MultiFrame::from_frames(1, &[frame], &store, &folding_config)
.pop()
.unwrap()
.synthesize(&mut cs)
.unwrap();

assert!(!cs.is_satisfied());
}

Check warning on line 1046 in src/lem/multiframe.rs

View check run for this annotation

Codecov / codecov/patch

src/lem/multiframe.rs#L1030-L1046

Added lines #L1030 - L1046 were not covered by tests
}

0 comments on commit 637ab79

Please sign in to comment.