Skip to content

Commit

Permalink
fix: formatted the code to granularity
Browse files Browse the repository at this point in the history
Signed-off-by: Abinand P <[email protected]>
  • Loading branch information
Abiji-2020 committed Oct 19, 2024
1 parent 0f143ab commit 71b680b
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 56 deletions.
20 changes: 4 additions & 16 deletions crates/proof-of-sql/src/base/bit/bit_distribution_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ fn we_can_compute_the_bit_distribution_of_an_empty_slice() {
assert!(!dist.has_varying_sign_bit());
assert!(!dist.sign_bit());
assert!(dist.is_valid());
assert_eq!(
TestScalar::from(dist.constant_part()),
TestScalar::zero()
);
assert_eq!(TestScalar::from(dist.constant_part()), TestScalar::zero());

let mut cnt = 0;
dist.for_each_abs_constant_bit(|_i: usize, _pos: usize| {
Expand Down Expand Up @@ -160,10 +157,7 @@ fn we_can_compute_the_bit_distribution_of_negative_values() {
assert!(!dist.has_varying_sign_bit());
assert!(dist.sign_bit());
assert!(dist.is_valid());
assert_eq!(
TestScalar::from(dist.constant_part()),
TestScalar::one()
);
assert_eq!(TestScalar::from(dist.constant_part()), TestScalar::one());
assert_eq!(dist.most_significant_abs_bit(), 0);

let mut cnt = 0;
Expand Down Expand Up @@ -193,10 +187,7 @@ fn we_can_compute_the_bit_distribution_of_values_with_different_signs() {
let dist = BitDistribution::new::<TestScalar, _>(&data);
assert_eq!(dist.num_varying_bits(), 1);
assert!(dist.has_varying_sign_bit());
assert_eq!(
TestScalar::from(dist.constant_part()),
TestScalar::one()
);
assert_eq!(TestScalar::from(dist.constant_part()), TestScalar::one());
assert_eq!(dist.most_significant_abs_bit(), 0);

let mut cnt = 0;
Expand Down Expand Up @@ -229,10 +220,7 @@ fn we_can_compute_the_bit_distribution_of_values_with_different_signs_and_values
assert_eq!(dist.num_varying_bits(), 3);
assert!(dist.has_varying_sign_bit());
assert!(dist.is_valid());
assert_eq!(
TestScalar::from(dist.constant_part()),
TestScalar::zero()
);
assert_eq!(TestScalar::from(dist.constant_part()), TestScalar::zero());
assert_eq!(dist.most_significant_abs_bit(), 2);

let mut cnt = 0;
Expand Down
3 changes: 1 addition & 2 deletions crates/proof-of-sql/src/base/bit/bit_matrix_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ fn we_can_compute_the_bit_matrix_for_data_with_varying_bits_and_constant_bits()
fn we_can_compute_the_bit_matrix_for_data_entries_bigger_than_64_bit_integers() {
let mut val = [0; 4];
val[3] = 1 << 2;
let data: Vec<TestScalar> =
vec![TestScalar::from_bigint(val), TestScalar::one()];
let data: Vec<TestScalar> = vec![TestScalar::from_bigint(val), TestScalar::one()];
let dist = BitDistribution::new::<TestScalar, _>(&data);
let alloc = Bump::new();
let matrix = compute_varying_bit_matrix(&alloc, &data, &dist);
Expand Down
6 changes: 2 additions & 4 deletions crates/proof-of-sql/src/base/database/filter_util_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ use bumpalo::Bump;
#[test]
fn we_can_filter_columns() {
let selection = vec![true, false, true, false, true];
let str_scalars: [TestScalar; 5] =
["1".into(), "2".into(), "3".into(), "4".into(), "5".into()];
let str_scalars: [TestScalar; 5] = ["1".into(), "2".into(), "3".into(), "4".into(), "5".into()];
let scalars = [1.into(), 2.into(), 3.into(), 4.into(), 5.into()];
let decimals = [1.into(), 2.into(), 3.into(), 4.into(), 5.into()];
let columns = vec![
Expand Down Expand Up @@ -40,8 +39,7 @@ fn we_can_filter_columns() {
#[test]
fn we_can_filter_columns_with_empty_result() {
let selection = vec![false, false, false, false, false];
let str_scalars: [TestScalar; 5] =
["1".into(), "2".into(), "3".into(), "4".into(), "5".into()];
let str_scalars: [TestScalar; 5] = ["1".into(), "2".into(), "3".into(), "4".into(), "5".into()];
let scalars = [1.into(), 2.into(), 3.into(), 4.into(), 5.into()];
let decimals = [1.into(), 2.into(), 3.into(), 4.into(), 5.into()];
let columns = vec![
Expand Down
2 changes: 1 addition & 1 deletion crates/proof-of-sql/src/base/database/owned_table_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{
base::{
database::{owned_table_utility::*, OwnedColumn, OwnedTable, OwnedTableError},
map::IndexMap,
scalar::test_scalar::TestScalar
scalar::test_scalar::TestScalar,
},
proof_primitive::dory::DoryScalar,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ use super::{
OwnedTableTestAccessor, SchemaAccessor, TestAccessor,
};
use crate::base::{
commitment::{Commitment, CommittableColumn},
commitment::{
naive_commitment::NaiveCommitment, test_evaluation_proof::TestEvaluationProof, Commitment,
CommittableColumn,
},
database::owned_table_utility::*,
scalar::test_scalar::TestScalar,
commitment::test_evaluation_proof::TestEvaluationProof,
commitment::naive_commitment::NaiveCommitment
};
use proof_of_sql_parser::posql_time::{PoSQLTimeUnit, PoSQLTimeZone};

Expand Down
8 changes: 2 additions & 6 deletions crates/proof-of-sql/src/base/encode/scalar_varint_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,7 @@ fn write_read_and_compare_encoding(expected_scals: &[TestScalar]) {
let total_bytes_read = write_scalar_varints(&mut buf_vec[..], expected_scals);

let buf = &buf_vec[0..total_bytes_read];
let mut scals =
vec![TestScalar::from_le_bytes_mod_order(&[0_u8; 32]); expected_scals.len()];
let mut scals = vec![TestScalar::from_le_bytes_mod_order(&[0_u8; 32]); expected_scals.len()];
read_scalar_varints(&mut scals[..], buf).unwrap();

for (scal, expected_scal) in scals.iter().zip(expected_scals.iter()) {
Expand All @@ -276,10 +275,7 @@ fn write_read_and_compare_encoding(expected_scals: &[TestScalar]) {
#[test]
fn scalar_slices_are_correctly_encoded_and_decoded() {
write_read_and_compare_encoding(&[TestScalar::from(0_u128)]);
write_read_and_compare_encoding(&[
TestScalar::from(1_u64),
TestScalar::from(4_u32),
]);
write_read_and_compare_encoding(&[TestScalar::from(1_u64), TestScalar::from(4_u32)]);
write_read_and_compare_encoding(&[
TestScalar::from(1_u64),
TestScalar::from(u128::MAX),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ fn test_composite_polynomial_hypercube_sum() {
let sum = prod.hypercube_sum(4);
assert_eq!(
sum,
TestScalar::from(
3 * ((-7) * 2 + 2 * (-8) + (-6) * 4 + 17 * 1) + 2 * (1 + 3 + (-5) + (-9))
)
TestScalar::from(3 * ((-7) * 2 + 2 * (-8) + (-6) * 4 + 17 * 1) + 2 * (1 + 3 + (-5) + (-9)))
);
}
21 changes: 5 additions & 16 deletions crates/proof-of-sql/src/base/polynomial/evaluation_vector_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,9 @@ fn we_compute_the_correct_evaluation_vector_for_a_small_example() {
assert_eq!(v, expected_v);

let mut v = [TestScalar::zero(); 4];
compute_evaluation_vector(
&mut v,
&[TestScalar::from(3u64), TestScalar::from(4u64)],
);
compute_evaluation_vector(&mut v, &[TestScalar::from(3u64), TestScalar::from(4u64)]);
let expected_v = [
(TestScalar::one() - TestScalar::from(4u64))
* (TestScalar::one() - TestScalar::from(3u64)),
(TestScalar::one() - TestScalar::from(4u64)) * (TestScalar::one() - TestScalar::from(3u64)),
(TestScalar::one() - TestScalar::from(4u64)) * TestScalar::from(3u64),
TestScalar::from(4u64) * (TestScalar::one() - TestScalar::from(3u64)),
TestScalar::from(4u64) * TestScalar::from(3u64),
Expand All @@ -36,13 +32,9 @@ fn we_compute_the_evaluation_vectors_not_a_power_of_2() {
assert_eq!(v, expected_v);

let mut v = [TestScalar::zero(); 3];
compute_evaluation_vector(
&mut v,
&[TestScalar::from(3u64), TestScalar::from(4u64)],
);
compute_evaluation_vector(&mut v, &[TestScalar::from(3u64), TestScalar::from(4u64)]);
let expected_v = [
(TestScalar::one() - TestScalar::from(4u64))
* (TestScalar::one() - TestScalar::from(3u64)),
(TestScalar::one() - TestScalar::from(4u64)) * (TestScalar::one() - TestScalar::from(3u64)),
(TestScalar::one() - TestScalar::from(4u64)) * TestScalar::from(3u64),
TestScalar::from(4u64) * (TestScalar::one() - TestScalar::from(3u64)),
];
Expand Down Expand Up @@ -98,9 +90,6 @@ fn we_get_the_same_result_using_evaluation_vector_as_direct_evaluation() {
3,
&TestScalar::unwrap_slice(&xs),
);
let expected_eval = TestScalar::new(
poly.evaluate(&TestScalar::unwrap_slice(&point))
.unwrap(),
);
let expected_eval = TestScalar::new(poly.evaluate(&TestScalar::unwrap_slice(&point)).unwrap());
assert_eq!(eval, expected_eval);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* See third_party/license/arkworks.LICENSE
*/
use super::interpolate::*;
use crate::base::scalar::{test_scalar::TestScalar as S, test_scalar::TestScalar};
use crate::base::scalar::test_scalar::{TestScalar as S, TestScalar};
use ark_std::UniformRand;
use core::iter;
use num_traits::{Inv, Zero};
Expand Down
3 changes: 1 addition & 2 deletions crates/proof-of-sql/src/base/slice_ops/inner_product_test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use super::*;
use crate::base::scalar::test_scalar::TestScalar;
use crate::base::scalar::Curve25519Scalar;
use crate::base::scalar::{test_scalar::TestScalar, Curve25519Scalar};

#[test]
fn test_inner_product() {
Expand Down
3 changes: 1 addition & 2 deletions crates/proof-of-sql/src/base/slice_ops/slice_cast_test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use super::*;
use crate::base::scalar::Curve25519Scalar;
use crate::base::scalar::test_scalar::TestScalar;
use crate::base::scalar::{test_scalar::TestScalar, Curve25519Scalar};
use curve25519_dalek::scalar::Scalar;

#[test]
Expand Down

0 comments on commit 71b680b

Please sign in to comment.