Skip to content

Commit

Permalink
test: migrate tests to dedicated crate
Browse files Browse the repository at this point in the history
  • Loading branch information
redshiftzero committed Apr 4, 2024
1 parent 37b37d8 commit 6b25ac1
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 28 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ members = [
"poseidon-permutation",
# "poseidon-consistency", # Temporarily excluded until paramgen is refactored
"poseidon-parameters",
"poseidon-tests",
]

[profile.release]
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This repository contains:
parameters
* [`poseidon-permutation`](../main/poseidon-permutation): an independent implementation of the Poseidon permutation
* [`poseidon-consistency`](../main/poseidon-consistency): property-based tests for consistency between Poseidon implementations
* [`poseidon-tests`](../main/poseidon-tests): test vectors for `poseidon-parameters` and `poseidon377`

## Audits

Expand Down
5 changes: 0 additions & 5 deletions poseidon-parameters/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ repository = "https://github.com/penumbra-zone/poseidon377"
[dependencies]
decaf377 = { version="0.9", default-features = false }

[dev-dependencies]
ark-ff = { version = "^0.4.0", default-features = false }
ark-ed-on-bls12-377 = "0.4"
proptest = "1"

[features]
default = ["std"]
alloc = [
Expand Down
3 changes: 0 additions & 3 deletions poseidon-parameters/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ mod matrix_ops;
mod mds_matrix;
mod round_numbers;

#[cfg(test)]
mod tests;

/// Structures related to Poseidon version 1 parameters.
pub mod v1;

Expand Down
30 changes: 30 additions & 0 deletions poseidon-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[package]
name = "poseidon-tests"
version = "0.3.0"
edition = "2018"
authors = ["Penumbra <[email protected]>", "redshiftzero <[email protected]>"]
description = "Common tests for penumbra's poseidon implementation"
license = "MIT OR Apache-2.0"
repository = "https://github.com/penumbra-zone/poseidon377"

[dependencies]
poseidon-parameters = { path = "../poseidon-parameters", default-features = false }
#poseidon-paramgen = { path = "../poseidon-paramgen", default-features = false }
poseidon-permutation = { path="../poseidon-permutation", default-features = false }
decaf377 = { version="0.9", default-features = false }
poseidon377 = { path="../poseidon377", features = ["r1cs"] }

[dev-dependencies]
ark-ff = { version = "^0.4.0", default-features = false }
ark-ed-on-bls12-377 = { version="0.4", default-features = false }
proptest = "1"
ark-ed-on-bls12-381 = "0.4"
rand_core = { version = "0.6.3", default-features=false }
rand_chacha = "0.3"
ark-groth16 = { version = "0.4", default-features = false }
ark-r1cs-std = {version = "0.4", default-features = false }
ark-relations = { version="0.4", default-features = false }
ark-snark = { version = "0.4", default-features = false }
ark-ec = { version = "0.4", default_features = false }
ark-std = { version = "0.4", default-features = false }
ark-serialize = { version = "0.4", default_features = false }
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
use decaf377::Fq;
use proptest::prelude::*;

use super::*;

use crate::matrix::{mat_mul, square_mat_mul};
use crate::{matrix::Matrix, matrix_ops::MatrixOperations};
use crate::{matrix::SquareMatrix, matrix_ops::SquareMatrixOperations};
use poseidon_parameters::v1::{mat_mul, square_mat_mul};
use poseidon_parameters::v1::{Matrix, MatrixOperations};
use poseidon_parameters::v1::{SquareMatrix, SquareMatrixOperations};

#[test]
fn identity_matrix() {
Expand Down Expand Up @@ -48,7 +46,7 @@ fn nonsquare_matmul_happy() {
let matrix_2x3 = Matrix::<3, 2, 6>::new(test_elements);

let matrix_3x2 = matrix_2x3.transpose();
let res: matrix::Matrix<3, 3, 9> = mat_mul(&matrix_2x3, &matrix_3x2);
let res: Matrix<3, 3, 9> = mat_mul(&matrix_2x3, &matrix_3x2);
assert_eq!(res.get_element(0, 0), Fq::from(5u64));
assert_eq!(res.get_element(0, 1), Fq::from(11u64));
assert_eq!(res.get_element(0, 2), Fq::from(17u64));
Expand Down
File renamed without changes.
14 changes: 0 additions & 14 deletions poseidon377/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,6 @@ ark-ec = { version = "0.4", default_features = false, optional=true }
ark-std = { version = "0.4", default-features = false, optional=true }
ark-serialize = { version = "0.4", default_features = false, optional=true }

[dev-dependencies]
ark-ed-on-bls12-381 = "0.4"
proptest = "1"
rand_core = { version = "0.6.3", default-features=false }
rand_chacha = "0.3"
ark-ff = "0.4"

# Dependencies added for ark-sponge tests
ark-test-curves = { version = "0.4", features = ["bls12_381_curve", "mnt4_753_curve"]}

[features]
default = ["arkworks"]
alloc = ["decaf377/alloc"]
Expand Down Expand Up @@ -66,7 +56,3 @@ parallel = [
"ark-std/parallel",
"ark-ec/parallel",
]

[[test]]
name = "r1cs"
required-features = ["r1cs"]

0 comments on commit 6b25ac1

Please sign in to comment.