mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-05 23:33:07 +00:00
PR feedback + underflow check
This commit is contained in:
parent
5e27e7264d
commit
d35d3e2095
@ -696,18 +696,32 @@ pub(crate) mod testutils {
|
||||
let empty = &vec![];
|
||||
// Check that every row in the looking tables appears in the looked table the same number of times
|
||||
// with some special logic for the default row.
|
||||
let mut extra_default_count = default.as_ref().map(|_| 0);
|
||||
for (row, looking_locations) in &looking_multiset {
|
||||
let looked_locations = looked_multiset.get(row).unwrap_or(empty);
|
||||
if let Some(default) = default {
|
||||
if row == default {
|
||||
*extra_default_count.as_mut().unwrap() +=
|
||||
looking_locations.len() - looked_locations.len();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
check_locations(looking_locations, looked_locations, ctl_index, row);
|
||||
}
|
||||
let extra_default_count = default.as_ref().map(|d| {
|
||||
let looking_default_locations = looking_multiset.get(d).unwrap_or(empty);
|
||||
let looked_default_locations = looked_multiset.get(d).unwrap_or(empty);
|
||||
looking_default_locations
|
||||
.len()
|
||||
.checked_sub(looked_default_locations.len())
|
||||
.unwrap_or_else(|| {
|
||||
// If underflow, panic. There should be more default rows in the looking side.
|
||||
check_locations(
|
||||
looking_default_locations,
|
||||
looked_default_locations,
|
||||
ctl_index,
|
||||
d,
|
||||
);
|
||||
unreachable!()
|
||||
})
|
||||
});
|
||||
// Check that the number of extra default rows is correct.
|
||||
if let Some(count) = extra_default_count {
|
||||
assert_eq!(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user