fix: pass dag prop test

This commit is contained in:
Zixuan Chen 2022-10-17 14:45:24 +08:00
parent 906aebfa8a
commit 56be50c1b6
2 changed files with 34 additions and 22 deletions

View file

@ -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) {

View file

@ -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);
}