mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 00:01:09 +00:00
Add erasure-coding/fuzzer to workspace (#7210)
* Add to workspace Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * fmt Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Remove dumb clones Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Update Cargo.lock Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> --------- Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: parity-processbot <>
This commit is contained in:
committed by
GitHub
parent
7f391adf44
commit
7d8ecced0e
@@ -14,9 +14,9 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use honggfuzz::fuzz;
|
||||
use polkadot_erasure_coding::*;
|
||||
use primitives::AvailableData;
|
||||
use honggfuzz::fuzz;
|
||||
|
||||
fn main() {
|
||||
loop {
|
||||
@@ -24,7 +24,7 @@ fn main() {
|
||||
let (num_validators, chunk_input) = data;
|
||||
let reconstructed: Result<AvailableData, _> = reconstruct_v1(
|
||||
num_validators,
|
||||
chunk_input.iter().map(|t| (&*t.0, t.1)).collect::<Vec<(&[u8], usize)>>()
|
||||
chunk_input.iter().map(|t| (&*t.0, t.1)).collect::<Vec<(&[u8], usize)>>(),
|
||||
);
|
||||
println!("reconstructed {:?}", reconstructed);
|
||||
});
|
||||
|
||||
@@ -14,41 +14,33 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use honggfuzz::fuzz;
|
||||
use polkadot_erasure_coding::*;
|
||||
use polkadot_primitives::PersistedValidationData;
|
||||
use primitives::{AvailableData, BlockData, PoV};
|
||||
use std::sync::Arc;
|
||||
use honggfuzz::fuzz;
|
||||
use polkadot_primitives::PersistedValidationData;
|
||||
|
||||
|
||||
fn main() {
|
||||
loop {
|
||||
fuzz!(|data: &[u8]| {
|
||||
let pov_block = PoV {
|
||||
block_data: BlockData(data.iter().cloned().collect()),
|
||||
};
|
||||
let pov_block = PoV { block_data: BlockData(data.iter().cloned().collect()) };
|
||||
|
||||
let available_data = AvailableData {
|
||||
pov: Arc::new(pov_block),
|
||||
validation_data: PersistedValidationData::default(),
|
||||
};
|
||||
let chunks = obtain_chunks_v1(
|
||||
10,
|
||||
&available_data,
|
||||
).unwrap();
|
||||
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();
|
||||
[(&*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