Skip to content

Commit

Permalink
Add some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ConstanceBeguier committed Oct 5, 2023
1 parent cb9eff3 commit 7e88834
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions halo2_gadgets/src/utilities/lookup_range_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,5 +739,34 @@ mod tests {
}])
);
}

// Element within 4 bits
{
let circuit: MyCircuit<pallas::Base> = MyCircuit {
element: Value::known(pallas::Base::from((1 << 4) - 1)),
num_bits: 4,
};
let prover = MockProver::<pallas::Base>::run(11, &circuit, vec![]).unwrap();
assert_eq!(prover.verify(), Ok(()));
}

// Element larger than 5 bits
{
let circuit: MyCircuit<pallas::Base> = MyCircuit {
element: Value::known(pallas::Base::from(1 << 5)),
num_bits: 5,
};
let prover = MockProver::<pallas::Base>::run(11, &circuit, vec![]).unwrap();
assert_eq!(
prover.verify(),
Err(vec![VerifyFailure::Lookup {
lookup_index: 0,
location: FailureLocation::InRegion {
region: (1, "Range check 5 bits").into(),
offset: 0,
},
}])
);
}
}
}

0 comments on commit 7e88834

Please sign in to comment.