diff --git a/crates/loro-core/src/fuzz.rs b/crates/loro-core/src/fuzz.rs index 89d8c6ed..29c3a290 100644 --- a/crates/loro-core/src/fuzz.rs +++ b/crates/loro-core/src/fuzz.rs @@ -649,12 +649,25 @@ mod test { #[test] fn case_two() { test_multi_sites( - 2, - &mut [Ins { - content: 123, - pos: 0, - site: 1, - }], + 3, + &mut [ + Ins { + content: 35108, + pos: 0, + site: 2, + }, + Ins { + content: 4626, + pos: 0, + site: 4, + }, + SyncAll, + Ins { + content: 65462, + pos: 7, + site: 4, + }, + ], ) } diff --git a/crates/loro-core/src/log_store/iter.rs b/crates/loro-core/src/log_store/iter.rs index ce94c7f3..d23910f9 100644 --- a/crates/loro-core/src/log_store/iter.rs +++ b/crates/loro-core/src/log_store/iter.rs @@ -94,8 +94,8 @@ impl<'a> Iterator for OpSpanIter<'a> { let op = RichOp::new_by_slice_on_change( change, op, - self.span.counter.min(), - self.span.counter.end(), + self.span.counter.min() - change.id.counter, + self.span.counter.end() - change.id.counter, ); if op.atom_len() == 0 { return None; diff --git a/crates/loro-core/tests/test.rs b/crates/loro-core/tests/test.rs index 62796608..7233c527 100644 --- a/crates/loro-core/tests/test.rs +++ b/crates/loro-core/tests/test.rs @@ -1,6 +1,5 @@ use ctor::ctor; -pub mod tests; use loro_core::container::registry::ContainerWrapper; use loro_core::{LoroCore, LoroValue}; diff --git a/crates/loro-core/tests/tests/mod.rs b/crates/loro-core/tests/tests/mod.rs deleted file mode 100644 index cdafe4ad..00000000 --- a/crates/loro-core/tests/tests/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod task; diff --git a/crates/loro-core/tests/tests/task.rs b/crates/loro-core/tests/tests/task.rs deleted file mode 100644 index 04ee3dd0..00000000 --- a/crates/loro-core/tests/tests/task.rs +++ /dev/null @@ -1,40 +0,0 @@ -use std::io::Read; - -use flate2::read::GzDecoder; -use loro_core::container::registry::ContainerWrapper; -use loro_core::LoroCore; -use serde_json::Value; - -const RAW_DATA: &[u8; 901823] = include_bytes!("../../benches/automerge-paper.json.gz"); - -#[test] -pub fn automerge_direct_sync() { - let mut d = GzDecoder::new(&RAW_DATA[..]); - let mut s = String::new(); - d.read_to_string(&mut s).unwrap(); - let json: Value = serde_json::from_str(&s).unwrap(); - let txns = json.as_object().unwrap().get("txns"); - let mut loro = LoroCore::default(); - let mut loro_b = LoroCore::default(); - for txn in txns.unwrap().as_array().unwrap() { - let text = loro.get_text("text"); - text.with_container(|text| { - let patches = txn - .as_object() - .unwrap() - .get("patches") - .unwrap() - .as_array() - .unwrap(); - for patch in patches { - let pos = patch[0].as_u64().unwrap() as usize; - let del_here = patch[1].as_u64().unwrap() as usize; - let ins_content = patch[2].as_str().unwrap(); - text.delete(&loro, pos, del_here); - text.insert(&loro, pos, ins_content); - } - }); - - loro_b.import(loro.export(loro_b.vv())); - } -}