mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-17 00:45:42 +00:00
erasure-coding: do not panic on 1 validator (#2022)
* erasure-coding: do not panic on 1 validator * tabify fuzz tests * remove num_validators length check * remove unused import * move erasure_coding_fuzzer to fuzzer * change the authors to admit (at) parity.io * Apply suggestions from code review Co-authored-by: Sergei Shulepov <sergei@parity.io> Co-authored-by: Sergei Shulepov <sergei@parity.io>
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
use polkadot_erasure_coding::*;
|
||||
use primitives::v1::{AvailableData, BlockData, PoV};
|
||||
use std::sync::Arc;
|
||||
use honggfuzz::fuzz;
|
||||
|
||||
|
||||
fn main() {
|
||||
loop {
|
||||
fuzz!(|data: &[u8]| {
|
||||
let pov_block = PoV {
|
||||
block_data: BlockData(data.iter().cloned().collect()),
|
||||
};
|
||||
|
||||
let available_data = AvailableData {
|
||||
pov: Arc::new(pov_block),
|
||||
validation_data: Default::default(),
|
||||
};
|
||||
let chunks = obtain_chunks_v1(
|
||||
10,
|
||||
&available_data,
|
||||
).unwrap();
|
||||
|
||||
assert_eq!(chunks.len(), 10);
|
||||
|
||||
// any 4 chunks should work.
|
||||
let reconstructed: AvailableData = reconstruct_v1(
|
||||
10,
|
||||
[
|
||||
(&*chunks[1], 1),
|
||||
(&*chunks[4], 4),
|
||||
(&*chunks[6], 6),
|
||||
(&*chunks[9], 9),
|
||||
].iter().cloned(),
|
||||
).unwrap();
|
||||
|
||||
assert_eq!(reconstructed, available_data);
|
||||
println!("{:?}", reconstructed);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user