From 57ea400b8848fea16eeedd14f075982215fb2368 Mon Sep 17 00:00:00 2001 From: egmkang wang Date: Wed, 18 Aug 2021 15:33:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=87=8F=E5=B0=91=E4=B8=80=E7=82=B9=E6=8B=AC?= =?UTF-8?q?=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: egmkang wang --- src/quorum/datadriven_test.rs | 75 ++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/src/quorum/datadriven_test.rs b/src/quorum/datadriven_test.rs index 1135c6904..f1b098c08 100644 --- a/src/quorum/datadriven_test.rs +++ b/src/quorum/datadriven_test.rs @@ -202,46 +202,47 @@ fn test_quorum(data: &TestData) -> String { // If the committed index was definitely above the currently inspected idx, // the result shouldn't change if we lower it further. for &id in c.ids() { - if let Some(iidx) = l.acked_index(id) { - if idx.0 > iidx.index { - // try index - 1 - l.insert( - id, - Index { - index: iidx.index - 1, - group_id: iidx.group_id, - }, - ); + let s = l.acked_index(id); + if s.is_none() { + continue; + } + let iidx = s.unwrap(); + if idx.0 <= iidx.index { + continue; + } + // try index - 1 + l.insert( + id, + Index { + index: iidx.index - 1, + group_id: iidx.group_id, + }, + ); - let a_idx = c.committed_index(use_group_commit, &l); - if a_idx != idx { - buf.push_str(&format!( - "{} <-- overlaying {}->{}\n", - a_idx.0, - id, - iidx.index - 1 - )); - } - // try 0 - l.insert( - id, - Index { - index: 0, - group_id: iidx.group_id, - }, - ); + let a_idx = c.committed_index(use_group_commit, &l); + if a_idx != idx { + buf.push_str(&format!( + "{} <-- overlaying {}->{}\n", + a_idx.0, + id, + iidx.index - 1 + )); + } + // try 0 + l.insert( + id, + Index { + index: 0, + group_id: iidx.group_id, + }, + ); - let a_idx = c.committed_index(use_group_commit, &l); - if a_idx != idx { - buf.push_str(&format!( - "{} <-- overlaying {}->{}\n", - a_idx.0, id, 0 - )); - } - // recovery - l.insert(id, iidx); - } + let a_idx = c.committed_index(use_group_commit, &l); + if a_idx != idx { + buf.push_str(&format!("{} <-- overlaying {}->{}\n", a_idx.0, id, 0)); } + // recovery + l.insert(id, iidx); } } buf.push_str(&format!(