Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
georgwiese committed Sep 23, 2024
1 parent 0a04573 commit a19e3a4
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 11 deletions.
26 changes: 19 additions & 7 deletions pipeline/tests/pil.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
#[cfg(feature = "halo2")]
use powdr_number::Bn254Field;
use powdr_number::GoldilocksField;
use powdr_pipeline::test_util::{
assert_proofs_fail_for_invalid_witnesses, assert_proofs_fail_for_invalid_witnesses_estark,
assert_proofs_fail_for_invalid_witnesses_halo2,
assert_proofs_fail_for_invalid_witnesses_pilcom, gen_estark_proof,
gen_estark_proof_with_backend_variant, make_prepared_pipeline, make_simple_prepared_pipeline,
regular_test, run_pilcom_with_backend_variant, test_halo2, test_halo2_with_backend_variant,
test_pilcom, test_plonky3_with_backend_variant, BackendVariant,
use powdr_pipeline::{
test_util::{
assert_proofs_fail_for_invalid_witnesses, assert_proofs_fail_for_invalid_witnesses_estark,
assert_proofs_fail_for_invalid_witnesses_halo2,
assert_proofs_fail_for_invalid_witnesses_pilcom, gen_estark_proof,
gen_estark_proof_with_backend_variant, make_prepared_pipeline,
make_simple_prepared_pipeline, regular_test, run_pilcom_with_backend_variant, test_halo2,
test_halo2_with_backend_variant, test_pilcom, test_plonky3_with_backend_variant,
BackendVariant,
},
Pipeline,
};

use test_log::test;
Expand Down Expand Up @@ -94,6 +98,14 @@ fn fibonacci() {
);
}

#[test]
fn fibonacci_with_public() {
// Public references are not supported by the backends yet, but we can test witness generation.
let f = "pil/fibonacci_with_public.pil";
let mut pipeline: Pipeline<GoldilocksField> = make_prepared_pipeline(f, vec![], vec![]);
pipeline.compute_witness().unwrap();
}

#[test]
fn fibonacci_invalid_witness() {
let f = "pil/fibonacci.pil";
Expand Down
2 changes: 1 addition & 1 deletion plonky3/src/stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ mod tests {
}

#[test]
#[should_panic = "not implemented: Unexpected expression: :oldstate"]
#[should_panic = "not yet implemented"]
fn public_reference() {
let content = r#"
namespace Global(8);
Expand Down
3 changes: 0 additions & 3 deletions test_data/pil/fibonacci.pil
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,3 @@ namespace Fibonacci(N);

(1-ISLAST) * (x' - y) = 0;
(1-ISLAST) * (y' - (x + y)) = 0;

public out = y(N-1);
ISLAST * (:out - y) = 0;
16 changes: 16 additions & 0 deletions test_data/pil/fibonacci_with_public.pil
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
let N = 4;

// This uses the alternative nomenclature as well.

namespace Fibonacci(N);
col fixed ISLAST(i) { if i == N - 1 { 1 } else { 0 } };
col witness x, y;

ISLAST * (y' - 1) = 0;
ISLAST * (x' - 1) = 0;

(1-ISLAST) * (x' - y) = 0;
(1-ISLAST) * (y' - (x + y)) = 0;

public out = y(N-1);
ISLAST * (:out - y) = 0;

0 comments on commit a19e3a4

Please sign in to comment.