MCPcopy Create free account
hub / github.com/base/base / new_multi_batch_compressed_data

Function new_multi_batch_compressed_data

crates/consensus/protocol/src/batch/reader.rs:242–252  ·  view source on GitHub ↗

Builds zlib-compressed channel data containing `n` copies of the same batch by duplicating the decompressed RLP content from the test fixture.

(n: usize)

Source from the content-addressed store, hash-verified

240 /// Builds zlib-compressed channel data containing `n` copies of the same
241 /// batch by duplicating the decompressed RLP content from the test fixture.
242 fn new_multi_batch_compressed_data(n: usize) -> (Bytes, usize) {
243 let raw = new_compressed_batch_data();
244 let single = decompress_to_vec_zlib(&raw).unwrap();
245
246 let mut multi = alloc::vec::Vec::with_capacity(single.len() * n);
247 for _ in 0..n {
248 multi.extend_from_slice(&single);
249 }
250 let decompressed_len = multi.len();
251 (compress_to_vec_zlib(&multi, CompressionLevel::BestSpeed.into()).into(), decompressed_len)
252 }
253
254 #[test]
255 fn test_zlib_truncation_instead_of_rejection() {

Calls 2

lenMethod · 0.45