Skip to content

Commit ae042ce

Browse files
A0-4600: Fix ancient parent test
1 parent ffc842d commit ae042ce

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

consensus/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "aleph-bft"
3-
version = "0.42.1"
3+
version = "0.42.2"
44
edition = "2021"
55
authors = ["Cardinal Cryptography"]
66
categories = ["algorithms", "data-structures", "cryptography", "database"]

consensus/src/extension/extender.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl<U: UnitWithParents> Extender<U> {
7070

7171
#[cfg(test)]
7272
mod test {
73-
use crate::units::{minimal_reconstructed_dag_units_up_to, Unit};
73+
use crate::units::{minimal_reconstructed_dag_units_up_to, Unit, UnitWithParents};
7474
use crate::{
7575
extension::extender::Extender, units::random_full_parent_reconstrusted_units_up_to,
7676
NodeCount, Round,
@@ -104,7 +104,7 @@ mod test {
104104
let mut extender = Extender::new();
105105
let n_members = NodeCount(4);
106106
let threshold = n_members.consensus_threshold();
107-
let max_round: Round = 4;
107+
let max_round: Round = 11;
108108
let session_id = 2137;
109109
let keychains = Keychain::new_vec(n_members);
110110
let mut batches = Vec::new();
@@ -119,7 +119,11 @@ mod test {
119119
assert_eq!(batches[0].len(), 1);
120120
assert_eq!(batches[0][0].round(), 0);
121121
for batch in batches.iter().skip(1) {
122-
assert_eq!(batch.len(), threshold.0);
122+
assert!(batch.len() == threshold.0 || batch.len() == n_members.0);
123+
if batch.len() == n_members.0 {
124+
// the batch that should have ancient unit
125+
assert!(batch.iter().find(|&unit| unit.parents().count() == 0).is_some());
126+
}
123127
}
124128
}
125129
}

consensus/src/units/testing.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ pub fn minimal_reconstructed_dag_units_up_to(
251251
.choose_multiple(&mut rng, threshold)
252252
.into_iter()
253253
.collect();
254-
if r == round {
254+
if r == round / 2 {
255255
let ancestor_unit = dag
256256
.first()
257257
.expect("first round present")

0 commit comments

Comments
 (0)