crashes generate_coding()
This commit is contained in:
@ -622,7 +622,7 @@ mod test {
|
|||||||
use crdt;
|
use crdt;
|
||||||
use erasure;
|
use erasure;
|
||||||
use logger;
|
use logger;
|
||||||
use packet::{BlobRecycler, BLOB_HEADER_SIZE, BLOB_SIZE};
|
use packet::{BlobRecycler, BLOB_DATA_SIZE, BLOB_HEADER_SIZE, BLOB_SIZE};
|
||||||
use rand::{thread_rng, Rng};
|
use rand::{thread_rng, Rng};
|
||||||
use signature::Keypair;
|
use signature::Keypair;
|
||||||
use signature::KeypairUtil;
|
use signature::KeypairUtil;
|
||||||
@ -737,7 +737,12 @@ mod test {
|
|||||||
let b_ = b.clone();
|
let b_ = b.clone();
|
||||||
let mut w = b.write().unwrap();
|
let mut w = b.write().unwrap();
|
||||||
// generate a random length, multiple of 4 between 8 and 32
|
// generate a random length, multiple of 4 between 8 and 32
|
||||||
let data_len = (thread_rng().gen_range(2, 8) * 4) + 1;
|
let data_len = if i == 3 {
|
||||||
|
BLOB_DATA_SIZE
|
||||||
|
} else {
|
||||||
|
(thread_rng().gen_range(2, 8) * 4) + 1
|
||||||
|
};
|
||||||
|
|
||||||
eprintln!("data_len of {} is {}", i, data_len);
|
eprintln!("data_len of {} is {}", i, data_len);
|
||||||
w.set_size(data_len);
|
w.set_size(data_len);
|
||||||
|
|
||||||
@ -786,34 +791,34 @@ mod test {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn pollute_recycler(blob_recycler: &BlobRecycler) {
|
||||||
|
let mut blobs = Vec::with_capacity(WINDOW_SIZE * 2);
|
||||||
|
for _ in 0..WINDOW_SIZE * 10 {
|
||||||
|
let blob = blob_recycler.allocate();
|
||||||
|
{
|
||||||
|
let mut b_l = blob.write().unwrap();
|
||||||
|
|
||||||
|
for i in 0..BLOB_SIZE {
|
||||||
|
b_l.data[i] = thread_rng().gen();
|
||||||
|
}
|
||||||
|
// some of the blobs should previously been used for coding
|
||||||
|
if thread_rng().gen_bool(erasure::NUM_CODING as f64 / erasure::NUM_DATA as f64) {
|
||||||
|
b_l.set_coding().unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
blobs.push(blob);
|
||||||
|
}
|
||||||
|
for blob in blobs {
|
||||||
|
blob_recycler.recycle(blob);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
pub fn test_window_recover_basic() {
|
pub fn test_window_recover_basic() {
|
||||||
logger::setup();
|
logger::setup();
|
||||||
let blob_recycler = BlobRecycler::default();
|
let blob_recycler = BlobRecycler::default();
|
||||||
|
|
||||||
{
|
pollute_recycler(&blob_recycler);
|
||||||
let mut blobs = Vec::with_capacity(WINDOW_SIZE * 2);
|
|
||||||
for _ in 0..WINDOW_SIZE * 10 {
|
|
||||||
let blob = blob_recycler.allocate();
|
|
||||||
|
|
||||||
{
|
|
||||||
let mut b_l = blob.write().unwrap();
|
|
||||||
|
|
||||||
for i in 0..BLOB_SIZE {
|
|
||||||
b_l.data[i] = thread_rng().gen();
|
|
||||||
}
|
|
||||||
// some of the blobs should previously been used for coding
|
|
||||||
if thread_rng().gen_bool(erasure::NUM_CODING as f64 / erasure::NUM_DATA as f64)
|
|
||||||
{
|
|
||||||
b_l.set_coding().unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
blobs.push(blob);
|
|
||||||
}
|
|
||||||
for blob in blobs {
|
|
||||||
blob_recycler.recycle(blob);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate a window
|
// Generate a window
|
||||||
let offset = 0;
|
let offset = 0;
|
||||||
|
@ -165,9 +165,6 @@ impl Reset for Blob {
|
|||||||
fn reset(&mut self) {
|
fn reset(&mut self) {
|
||||||
self.meta = Meta::default();
|
self.meta = Meta::default();
|
||||||
self.data[..BLOB_HEADER_SIZE].copy_from_slice(&[0u8; BLOB_HEADER_SIZE]);
|
self.data[..BLOB_HEADER_SIZE].copy_from_slice(&[0u8; BLOB_HEADER_SIZE]);
|
||||||
for i in 0..BLOB_SIZE {
|
|
||||||
self.data[i] = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user