mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 20:11:09 +00:00
a few more tests for the accumulator
This commit is contained in:
@@ -524,4 +524,42 @@ mod tests {
|
||||
s => panic!("wrong state: {:?}", s),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn begin_to_advance() {
|
||||
let mut accumulator = Accumulator::<Candidate, Digest, _, _>::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::<Candidate, _, _, _>::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),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,6 @@ pub struct Agreed<T, P, V, S> {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user