mirror of https://github.com/poanetwork/hbbft.git
Merge pull request #114 from poanetwork/afck-subset-1-node
Fix Subset for a single validator.
This commit is contained in:
commit
4f7feda9fc
|
@ -287,11 +287,10 @@ impl<NodeUid: Clone + Debug + Ord> Agreement<NodeUid> {
|
|||
return Err(ErrorKind::InputNotAccepted.into());
|
||||
}
|
||||
if self.netinfo.num_nodes() == 1 {
|
||||
self.decision = Some(input);
|
||||
self.output = Some(input);
|
||||
self.terminated = true;
|
||||
self.send_bval(input)?;
|
||||
self.send_aux(input)
|
||||
self.send_aux(input)?;
|
||||
self.decide(input);
|
||||
Ok(())
|
||||
} else {
|
||||
// Set the initial estimated value to the input value.
|
||||
self.estimated = Some(input);
|
||||
|
@ -515,6 +514,9 @@ impl<NodeUid: Clone + Debug + Ord> Agreement<NodeUid> {
|
|||
|
||||
/// Decides on a value and broadcasts a `Term` message with that value.
|
||||
fn decide(&mut self, b: bool) {
|
||||
if self.terminated {
|
||||
return;
|
||||
}
|
||||
// Output the agreement value.
|
||||
self.output = Some(b);
|
||||
// Latch the decided state.
|
||||
|
|
|
@ -108,3 +108,12 @@ fn test_common_subset_5_nodes_different_proposed_values() {
|
|||
let network = new_network(5, 0, adversary);
|
||||
test_common_subset(network, &proposals);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_common_subset_1_node() {
|
||||
let proposals: BTreeMap<NodeUid, ProposedValue> =
|
||||
once((NodeUid(0), Vec::from("Node 0 is the greatest!"))).collect();
|
||||
let adversary = |_| SilentAdversary::new(MessageScheduler::Random);
|
||||
let network = new_network(1, 0, adversary);
|
||||
test_common_subset(network, &proposals);
|
||||
}
|
||||
|
|
|
@ -196,7 +196,7 @@ where
|
|||
let _ = env_logger::try_init();
|
||||
|
||||
let mut rng = rand::thread_rng();
|
||||
let sizes = (4..5)
|
||||
let sizes = (2..5)
|
||||
.chain(once(rng.gen_range(6, 10)))
|
||||
.chain(once(rng.gen_range(11, 15)));
|
||||
for size in sizes {
|
||||
|
|
Loading…
Reference in New Issue