Get rid of test-helpers feature in sc-consensus-babe (#8486)

This is not really required and having a special `test-helpers` feature
is a bad idea anyway.
This commit is contained in:
Bastian Köcher
2021-03-30 08:10:54 +02:00
committed by GitHub
parent fb73a4eef6
commit 2998b42311
4 changed files with 24 additions and 58 deletions
+1 -1
View File
@@ -116,7 +116,7 @@ sp-trie = { version = "3.0.0", default-features = false, path = "../../../primit
[dev-dependencies]
sc-keystore = { version = "3.0.0", path = "../../../client/keystore" }
sc-consensus = { version = "0.9.0", path = "../../../client/consensus/common" }
sc-consensus-babe = { version = "0.9.0", features = ["test-helpers"], path = "../../../client/consensus/babe" }
sc-consensus-babe = { version = "0.9.0", path = "../../../client/consensus/babe" }
sc-consensus-epochs = { version = "0.9.0", path = "../../../client/consensus/epochs" }
sc-service-test = { version = "2.0.0", path = "../../../client/service/test" }
futures = "0.3.9"
+23 -16
View File
@@ -638,27 +638,34 @@ mod tests {
None,
);
let epoch_descriptor = babe_link.epoch_changes().lock().epoch_descriptor_for_child_of(
descendent_query(&*service.client()),
&parent_hash,
parent_number,
slot.into(),
).unwrap().unwrap();
let mut digest = Digest::<H256>::default();
// even though there's only one authority some slots might be empty,
// so we must keep trying the next slots until we can claim one.
let babe_pre_digest = loop {
inherent_data.replace_data(sp_timestamp::INHERENT_IDENTIFIER, &(slot * SLOT_DURATION));
if let Some(babe_pre_digest) = sc_consensus_babe::test_helpers::claim_slot(
let (babe_pre_digest, epoch_descriptor) = loop {
inherent_data.replace_data(
sp_timestamp::INHERENT_IDENTIFIER,
&(slot * SLOT_DURATION),
);
let epoch_descriptor = babe_link.epoch_changes().lock().epoch_descriptor_for_child_of(
descendent_query(&*service.client()),
&parent_hash,
parent_number,
slot.into(),
&parent_header,
&*service.client(),
keystore.clone(),
&babe_link,
) {
break babe_pre_digest;
).unwrap().unwrap();
let epoch = babe_link.epoch_changes().lock().epoch_data(
&epoch_descriptor,
|slot| sc_consensus_babe::Epoch::genesis(&babe_link.config(), slot),
).unwrap();
if let Some(babe_pre_digest) = sc_consensus_babe::authorship::claim_slot(
slot.into(),
&epoch,
&keystore,
).map(|(digest, _)| digest) {
break (babe_pre_digest, epoch_descriptor)
}
slot += 1;