diff --git a/kimchi/src/circuits/lookup/index.rs b/kimchi/src/circuits/lookup/index.rs index b9e2bd3dc6..b01f5a5a85 100644 --- a/kimchi/src/circuits/lookup/index.rs +++ b/kimchi/src/circuits/lookup/index.rs @@ -443,3 +443,42 @@ impl LookupConstraintSystem { } } } + + +#[cfg(test)] +mod tests { + + use super::*; + use mina_curves::pasta::Fp; + use crate::circuits::{ + gate::{CircuitGate, GateType}, + wires::Wire, + }; + + #[test] + fn test_zero_table_zero_row() { + let lookup_r: u64 = 32; + let num_lookups: usize = 16; + if let Ok(domain) = EvaluationDomains::::create(2*lookup_r as usize) { + + // Table column that does not contain zeros + let lookup_table_values: Vec<_> = + (1..lookup_r+1).map(From::from).collect(); + + let lookup_tables: Vec> = vec![ + LookupTable { + id: 0, + data: vec![lookup_table_values], + } + ]; + + let gates: Vec> = (0..num_lookups) + .map(|i| CircuitGate::new(GateType::Lookup, Wire::for_row(i), vec![])) + .collect(); + + let res = LookupConstraintSystem::create(gates.as_slice(), lookup_tables, None, &domain); + assert!(matches!(res,Err(LookupError::TableIDZeroMustHaveZeroEntry)), + "LookupConstraintSystem::create(...) returns OK when zero table has no zero rows"); + } + } +}