Skip to content
Snippets Groups Projects

complete the FEC and "linear algebra" tests

Merged STEVAN Antoine requested to merge more-tests into main
1 file
+ 23
21
Compare changes
  • Side-by-side
  • Inline
+ 23
21
@@ -200,7 +200,7 @@ mod tests {
use ark_ff::PrimeField;
use crate::{
fec::{decode, encode, Shard},
fec::{decode, encode, recode_random, Shard},
field,
linalg::Matrix,
};
@@ -301,27 +301,29 @@ mod tests {
let shards = encode::<F>(data, &Matrix::random(k, n, &mut rng));
assert!(shards.is_ok(), "could not encode {test_case}");
let recoding_steps = [
[2, 4], // = n
[1, 3], // = (n + 1)
[n, (n + 1)], // = (n + 2) = ((2, 4), (1, 3))
];
let should_not_be_decodable = vec![
vec![2, 4, n],
vec![1, 3, (n + 1)],
vec![n, (n + 1), (n + 2)],
];
let mut shards = shards.unwrap();
shards.push(shards[2].recode_with(to_curve(7), &shards[4], to_curve(6)));
shards.push(shards[1].recode_with(to_curve(5), &shards[3], to_curve(4)));
shards.push(shards[n].recode_with(to_curve(3), &shards[n + 1], to_curve(8)));
// n = (2, 4)
// n + 1 = (1, 3)
// n + 2 = (n, n + 1) = ((2, 4), (1, 3))
try_all_decoding_combinations(
data,
&shards,
k,
&test_case,
None,
vec![
vec![2, 4, n],
vec![1, 3, (n + 1)],
vec![n, (n + 1), (n + 2)],
],
);
for step in recoding_steps {
let shards_to_recode: Vec<_> = shards
.iter()
.cloned()
.enumerate()
.filter_map(|(i, s)| if step.contains(&i) { Some(s) } else { None })
.collect();
shards.push(recode_random(&shards_to_recode, &mut rng).unwrap().unwrap());
}
try_all_decoding_combinations(data, &shards, k, &test_case, None, should_not_be_decodable);
}
#[test]
Loading