diff --git a/substrate/candidate-agreement/src/bft/accumulator.rs b/substrate/candidate-agreement/src/bft/accumulator.rs index a0c99698df..ce54c55ea1 100644 --- a/substrate/candidate-agreement/src/bft/accumulator.rs +++ b/substrate/candidate-agreement/src/bft/accumulator.rs @@ -524,4 +524,42 @@ mod tests { s => panic!("wrong state: {:?}", s), } } + + #[test] + fn begin_to_advance() { + let mut accumulator = Accumulator::::new(1, 3, ValidatorId(8)); + assert_eq!(accumulator.state(), &State::Begin); + + for i in 0..7 { + accumulator.import_message(LocalizedMessage { + sender: ValidatorId(i), + signature: Signature(1, i), + message: Message::AdvanceRound(1), + }); + } + + match accumulator.state() { + &State::Advanced(ref j) => assert!(j.is_none()), + s => panic!("wrong state: {:?}", s), + } + } + + #[test] + fn conclude_without_prepare() { + let mut accumulator = Accumulator::::new(1, 3, ValidatorId(8)); + assert_eq!(accumulator.state(), &State::Begin); + + for i in 0..7 { + accumulator.import_message(LocalizedMessage { + sender: ValidatorId(i), + signature: Signature(999, i), + message: Message::Commit(1, Digest(999)), + }); + } + + match accumulator.state() { + &State::Concluded(ref j) => assert_eq!(j.digest, Digest(999)), + s => panic!("wrong state: {:?}", s), + } + } } diff --git a/substrate/candidate-agreement/src/bft/mod.rs b/substrate/candidate-agreement/src/bft/mod.rs index 74476b98b0..bcb3571842 100644 --- a/substrate/candidate-agreement/src/bft/mod.rs +++ b/substrate/candidate-agreement/src/bft/mod.rs @@ -67,7 +67,6 @@ pub struct Agreed { pub struct Params< Validator, SignLocal, - Timeout, CanInclude, MessagesIn, MessagesOut, @@ -78,8 +77,6 @@ pub struct Params< pub local_id: Validator, /// A closure for signing local messages. pub sign_local: SignLocal, - /// A timeout that fires when the view change should begin. - pub begin_view_change: Timeout, /// A function for checking if a proposal can be voted for. pub can_include: CanInclude, /// The input stream. Should never conclude, and should yield only messages