Skip to content

Commit

Permalink
test: factor for running product with Op Stack Table never panics
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-ferdinand committed Oct 23, 2023
1 parent 4efffde commit 224e792
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions triton-vm/src/table/challenges.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
//! table. Instead, the terminal of the Evaluation Argument is computed directly from the
//! public input (respectively output) and the indeterminate.

use arbitrary::Arbitrary;
use std::fmt::Debug;
use std::hash::Hash;
use std::ops::Index;
Expand Down Expand Up @@ -216,6 +217,7 @@ impl ChallengeId {
/// known only at runtime. The challenges are indexed using enum [`ChallengeId`]. The `Challenges`
/// struct is essentially a thin wrapper around an array of [`XFieldElement`]s, providing
/// convenience methods.
#[derive(Debug, Clone, Arbitrary)]
pub struct Challenges {
pub challenges: [XFieldElement; Self::count()],
}
Expand Down
24 changes: 24 additions & 0 deletions triton-vm/src/table/processor_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3045,7 +3045,9 @@ impl<'a> Display for ExtProcessorTraceRow<'a> {
#[cfg(test)]
pub(crate) mod tests {
use ndarray::Array2;
use proptest::collection::vec;
use proptest::prelude::*;
use proptest_arbitrary_interop::arb;
use rand::thread_rng;
use rand::Rng;
use strum::IntoEnumIterator;
Expand Down Expand Up @@ -3861,4 +3863,26 @@ pub(crate) mod tests {
let _ = ProcessorTable::op_stack_column_by_index(index);
}
}

proptest! {
#[test]
fn constructing_factor_for_op_stack_table_running_product_never_panics(
has_previous_row: bool,
previous_row in vec(arb::<BFieldElement>(), BASE_WIDTH),
current_row in vec(arb::<BFieldElement>(), BASE_WIDTH),
challenges in arb::<Challenges>(),
) {
let previous_row = Array1::from(previous_row);
let current_row = Array1::from(current_row);
let maybe_previous_row = match has_previous_row {
true => Some(previous_row.view()),
false => None,
};
let _ = ProcessorTable::factor_for_op_stack_table_running_product(
maybe_previous_row,
current_row.view(),
&challenges
);
}
}
}

0 comments on commit 224e792

Please sign in to comment.