mirror of
https://github.com/loro-dev/loro.git
synced 2025-01-23 05:24:51 +00:00
fix: pass dag prop test
This commit is contained in:
parent
906aebfa8a
commit
56be50c1b6
2 changed files with 34 additions and 22 deletions
|
@ -353,24 +353,25 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
// if top nodes are from the same client with different source, we find a shared node
|
||||
if let Some((other_node, other_type)) = queue.peek() {
|
||||
if node_type != *other_type && node.id.client_id == other_node.id.client_id {
|
||||
if node_type != NodeType::Shared {
|
||||
ans.push(ID {
|
||||
client_id: node.id.client_id,
|
||||
counter: node.id.counter.min(other_node.id.counter),
|
||||
});
|
||||
node_type = NodeType::Shared;
|
||||
}
|
||||
match other_type {
|
||||
NodeType::A => a_count -= 1,
|
||||
NodeType::B => b_count -= 1,
|
||||
NodeType::Shared => {}
|
||||
}
|
||||
queue.pop();
|
||||
}
|
||||
}
|
||||
// // if top nodes are from the same client with different source, we find a shared node
|
||||
// if let Some((other_node, other_type)) = queue.peek() {
|
||||
// if node_type != *other_type && node.id.client_id == other_node.id.client_id {
|
||||
// if node_type != NodeType::Shared {
|
||||
// debug_assert!(other_node.id.counter < node.id.counter);
|
||||
// ans.push(ID {
|
||||
// client_id: node.id.client_id,
|
||||
// counter: other_node.id.counter,
|
||||
// });
|
||||
// node_type = NodeType::Shared;
|
||||
// }
|
||||
// match other_type {
|
||||
// NodeType::A => a_count -= 1,
|
||||
// NodeType::B => b_count -= 1,
|
||||
// NodeType::Shared => {}
|
||||
// }
|
||||
// queue.pop();
|
||||
// }
|
||||
// }
|
||||
|
||||
// detect whether client is visited by other
|
||||
if let Some((ctr, visited_type)) = visited.get_mut(&node.id.client_id) {
|
||||
|
|
|
@ -580,12 +580,12 @@ mod find_common_ancestors_proptest {
|
|||
fn issue() {
|
||||
if let Err(err) = test_mul_ancestors::<3>(
|
||||
10,
|
||||
vec![],
|
||||
vec![Interaction {
|
||||
dag_idx: 4,
|
||||
merge_with: Some(2),
|
||||
dag_idx: 2,
|
||||
merge_with: Some(5),
|
||||
len: 1,
|
||||
}],
|
||||
vec![],
|
||||
) {
|
||||
println!("{}", err);
|
||||
panic!();
|
||||
|
@ -681,7 +681,18 @@ mod find_common_ancestors_proptest {
|
|||
dags.push(TestDag::new(i as ClientID));
|
||||
}
|
||||
|
||||
for interaction in before_merge_insertion {
|
||||
for mut interaction in before_merge_insertion {
|
||||
if interaction.dag_idx < N {
|
||||
// cannot act on first N nodes
|
||||
interaction.dag_idx = interaction.dag_idx % (dags.len() - N) + N;
|
||||
}
|
||||
if let Some(merge) = interaction.merge_with {
|
||||
if interaction.dag_idx == merge {
|
||||
let next_merge = (merge + 1) % dags.len();
|
||||
interaction.merge_with = Some(next_merge);
|
||||
}
|
||||
}
|
||||
|
||||
apply(interaction, &mut dags);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue