Merge pull request #114 from poanetwork/afck-subset-1-node

Fix Subset for a single validator.
This commit is contained in:
Vladimir Komendantskiy 2018-07-09 11:33:15 +01:00 committed by GitHub
commit 4f7feda9fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 5 deletions

View File

@ -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.

View File

@ -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);
}

View File

@ -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 {