fix: remove `Qc.parent_view()` that has a bug (#223)

This commit is contained in:
Youngjoon Lee 2023-06-27 23:56:36 +09:00 committed by GitHub
parent b884e1ceca
commit 8956a3547b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 32 additions and 8 deletions

View File

@ -139,14 +139,6 @@ impl Qc {
}
}
/// The view of the block this qc is for.
pub fn parent_view(&self) -> View {
match self {
Qc::Standard(StandardQc { view, .. }) => *view,
Qc::Aggregated(AggregateQc { view, .. }) => *view,
}
}
/// The id of the block this qc is for.
/// This will be the parent of the block which will include this qc
pub fn block(&self) -> BlockId {
@ -163,3 +155,35 @@ impl Qc {
}
}
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn standard_qc() {
let standard_qc = StandardQc {
view: 10,
id: [0; 32],
};
let qc = Qc::Standard(standard_qc.clone());
assert_eq!(qc.view(), 10);
assert_eq!(qc.block(), [0; 32]);
assert_eq!(qc.high_qc(), standard_qc);
}
#[test]
fn aggregated_qc() {
let aggregated_qc = AggregateQc {
view: 20,
high_qc: StandardQc {
view: 10,
id: [0; 32],
},
};
let qc = Qc::Aggregated(aggregated_qc.clone());
assert_eq!(qc.view(), 20);
assert_eq!(qc.block(), [0; 32]);
assert_eq!(qc.high_qc(), aggregated_qc.high_qc);
}
}