Skip to content

Commit

Permalink
A0-4600: Fix ancient parent test (#536)
Browse files Browse the repository at this point in the history
* A0-4600: Fix ancient parent test

* fmt

* clippy
  • Loading branch information
Marcin-Radecki authored Feb 7, 2025
1 parent ffc842d commit 4b3d8f2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion consensus/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "aleph-bft"
version = "0.42.1"
version = "0.42.2"
edition = "2021"
authors = ["Cardinal Cryptography"]
categories = ["algorithms", "data-structures", "cryptography", "database"]
Expand Down
10 changes: 7 additions & 3 deletions consensus/src/extension/extender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl<U: UnitWithParents> Extender<U> {

#[cfg(test)]
mod test {
use crate::units::{minimal_reconstructed_dag_units_up_to, Unit};
use crate::units::{minimal_reconstructed_dag_units_up_to, Unit, UnitWithParents};
use crate::{
extension::extender::Extender, units::random_full_parent_reconstrusted_units_up_to,
NodeCount, Round,
Expand Down Expand Up @@ -104,7 +104,7 @@ mod test {
let mut extender = Extender::new();
let n_members = NodeCount(4);
let threshold = n_members.consensus_threshold();
let max_round: Round = 4;
let max_round: Round = 11;
let session_id = 2137;
let keychains = Keychain::new_vec(n_members);
let mut batches = Vec::new();
Expand All @@ -119,7 +119,11 @@ mod test {
assert_eq!(batches[0].len(), 1);
assert_eq!(batches[0][0].round(), 0);
for batch in batches.iter().skip(1) {
assert_eq!(batch.len(), threshold.0);
assert!(batch.len() == threshold.0 || batch.len() == n_members.0);
if batch.len() == n_members.0 {
// the batch that should have ancient unit
assert!(batch.iter().any(|unit| unit.parents().count() == 0));
}
}
}
}
2 changes: 1 addition & 1 deletion consensus/src/units/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ pub fn minimal_reconstructed_dag_units_up_to(
.choose_multiple(&mut rng, threshold)
.into_iter()
.collect();
if r == round {
if r == round / 2 {
let ancestor_unit = dag
.first()
.expect("first round present")
Expand Down

0 comments on commit 4b3d8f2

Please sign in to comment.