test: disperse random data
This commit is contained in:
parent
a4ffffb898
commit
ba703b8cef
|
@ -154,11 +154,14 @@ mod tests {
|
||||||
DispersalExecutorBehaviour, DispersalExecutorEvent,
|
DispersalExecutorBehaviour, DispersalExecutorEvent,
|
||||||
};
|
};
|
||||||
use kzgrs_backend::common::blob::DaBlob;
|
use kzgrs_backend::common::blob::DaBlob;
|
||||||
use kzgrs_backend::common::Column;
|
use kzgrs_backend::common::ColumnIndex;
|
||||||
|
use kzgrs_backend::encoder::{DaEncoder, DaEncoderParams, EncodedData};
|
||||||
use libp2p::identity::Keypair;
|
use libp2p::identity::Keypair;
|
||||||
use libp2p::swarm::SwarmEvent;
|
use libp2p::swarm::SwarmEvent;
|
||||||
use libp2p::{identity, quic, PeerId, Swarm};
|
use libp2p::{identity, quic, PeerId, Swarm};
|
||||||
|
use nomos_core::da::DaEncoder as TraitDaEncoder;
|
||||||
use nomos_da_messages::common::Blob;
|
use nomos_da_messages::common::Blob;
|
||||||
|
use rand::RngCore;
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use tokio::sync::mpsc::UnboundedSender;
|
use tokio::sync::mpsc::UnboundedSender;
|
||||||
|
@ -360,21 +363,31 @@ mod tests {
|
||||||
subnet_id: u32,
|
subnet_id: u32,
|
||||||
messages_to_send: usize,
|
messages_to_send: usize,
|
||||||
) {
|
) {
|
||||||
for i in 0..messages_to_send {
|
// Generate 16 blobs
|
||||||
debug!("Sending blob {i} to subnet {subnet_id} ...");
|
let mut buff = vec![0; 32 * DaEncoderParams::MAX_BLS12_381_ENCODING_CHUNK_SIZE];
|
||||||
disperse_blob_sender
|
rand::thread_rng().fill_bytes(&mut buff);
|
||||||
.send((
|
let params = DaEncoderParams::default_with(32);
|
||||||
subnet_id,
|
let encoder = DaEncoder::new(params);
|
||||||
DaBlob {
|
let encoded_data: EncodedData = encoder.encode(&buff).unwrap();
|
||||||
column_idx: 0,
|
let blobs: Vec<DaBlob> = encoded_data
|
||||||
column: Column(vec![]),
|
.chunked_data
|
||||||
|
.columns()
|
||||||
|
.enumerate()
|
||||||
|
.map(|(idx, column)| DaBlob {
|
||||||
|
column,
|
||||||
|
column_idx: idx as ColumnIndex,
|
||||||
column_commitment: Default::default(),
|
column_commitment: Default::default(),
|
||||||
aggregated_column_commitment: Default::default(),
|
aggregated_column_commitment: Default::default(),
|
||||||
aggregated_column_proof: Default::default(),
|
aggregated_column_proof: Default::default(),
|
||||||
rows_commitments: vec![],
|
rows_commitments: vec![],
|
||||||
rows_proofs: vec![],
|
rows_proofs: vec![],
|
||||||
},
|
})
|
||||||
))
|
.collect();
|
||||||
|
|
||||||
|
for i in 0..messages_to_send {
|
||||||
|
debug!("Sending blob {i} to subnet {subnet_id} ...");
|
||||||
|
disperse_blob_sender
|
||||||
|
.send((subnet_id, blobs[i].clone()))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue