test: add import history data test

This commit is contained in:
Zixuan Chen 2023-08-30 17:07:58 +08:00
parent 1d3cd60873
commit 4ecd850632
No known key found for this signature in database
3 changed files with 10 additions and 3 deletions

View file

@ -369,16 +369,17 @@ impl OpLog {
for change in changes.iter() {
if change.id.counter < 0 {
return Err(LoroError::DecodeError(
"Invalid data".to_string().into_boxed_str(),
"Invalid data. Negative id counter.".into(),
));
}
if let Some(last_end_counter) = &mut last_end_counter {
if change.id.counter != *last_end_counter {
*last_end_counter = change.id_end().counter;
return Err(LoroError::DecodeError(
"Invalid data".to_string().into_boxed_str(),
"Invalid data. Not continuous counter.".into(),
));
}
*last_end_counter = change.id_end().counter;
} else {
last_end_counter = Some(change.id_end().counter);
}

Binary file not shown.

View file

@ -19,6 +19,12 @@ fn import() {
.unwrap_or_default();
}
#[test]
fn import_history() {
let doc = LoroDoc::new();
doc.import(include_bytes!("./history_data_v1.dat")).unwrap();
}
#[test]
fn test_timestamp() {
let doc = LoroDoc::new();