mirror of https://github.com/poanetwork/hbbft.git
added a Travis configuration file, fixed Clippy lints
This commit is contained in:
parent
0732e0bac8
commit
7826987af1
|
@ -0,0 +1,25 @@
|
|||
language: rust
|
||||
rust: nightly-2018-04-19
|
||||
cache: cargo
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- unzip
|
||||
before_install:
|
||||
- curl -OL https://github.com/google/protobuf/releases/download/v3.5.1/protoc-3.5.1-linux-x86_64.zip
|
||||
- sudo unzip protoc-3.5.1-linux-x86_64.zip -d /usr/local bin/protoc
|
||||
- sudo chown $(whoami) /usr/local/bin/protoc
|
||||
- protoc --version
|
||||
- rm protoc-3.5.1-linux-x86_64.zip
|
||||
- rustup component add rustfmt-preview
|
||||
- cargo install clippy -f --vers=0.0.195
|
||||
env:
|
||||
global:
|
||||
- RUST_BACKTRACE=1
|
||||
- RUSTFLAGS="-D warnings"
|
||||
script:
|
||||
- cargo fmt -- --write-mode=diff
|
||||
- cargo clippy -- -D clippy
|
||||
- cargo clippy --tests -- -D clippy
|
||||
- cargo check --tests
|
||||
- cargo test
|
|
@ -3,16 +3,17 @@
|
|||
use proto::AgreementMessage;
|
||||
use std::collections::{BTreeSet, VecDeque};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Agreement {
|
||||
input: Option<bool>,
|
||||
bin_values: BTreeSet<bool>,
|
||||
_bin_values: BTreeSet<bool>,
|
||||
}
|
||||
|
||||
impl Agreement {
|
||||
pub fn new() -> Self {
|
||||
Agreement {
|
||||
input: None,
|
||||
bin_values: BTreeSet::new(),
|
||||
_bin_values: BTreeSet::new(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,7 +30,7 @@ impl Agreement {
|
|||
/// Receive input from a remote node.
|
||||
pub fn on_input(
|
||||
&self,
|
||||
_message: AgreementMessage,
|
||||
_message: &AgreementMessage,
|
||||
) -> Result<VecDeque<AgreementMessage>, Error> {
|
||||
Err(Error::NotImplemented)
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
//! Asynchronous Common Subset algorithm.
|
||||
|
||||
// TODO: This module is work in progress. Remove this attribute when it's not needed anymore.
|
||||
#![allow(unused)]
|
||||
|
||||
use std::collections::{HashMap, HashSet, VecDeque};
|
||||
use std::fmt::{Debug, Display};
|
||||
use std::hash::Hash;
|
||||
|
@ -70,7 +73,7 @@ impl<NodeUid: Clone + Debug + Display + Eq + Hash + Ord> CommonSubset<NodeUid> {
|
|||
num_nodes,
|
||||
num_faulty_nodes,
|
||||
agreement_true_outputs: HashSet::new(),
|
||||
broadcast_instances: broadcast_instances,
|
||||
broadcast_instances,
|
||||
agreement_instances: HashMap::new(),
|
||||
broadcast_results: HashMap::new(),
|
||||
agreement_results: HashMap::new(),
|
||||
|
@ -97,8 +100,11 @@ impl<NodeUid: Clone + Debug + Display + Eq + Hash + Ord> CommonSubset<NodeUid> {
|
|||
|
||||
/// Upon delivery of v_j from RBC_j, if input has not yet been provided to
|
||||
/// BA_j, then provide input 1 to BA_j. See Figure 11.
|
||||
pub fn on_broadcast_result(&mut self, uid: NodeUid) -> Result<Option<AgreementMessage>, Error> {
|
||||
if let Some(agreement_instance) = self.agreement_instances.get_mut(&uid) {
|
||||
pub fn on_broadcast_result(
|
||||
&mut self,
|
||||
uid: &NodeUid,
|
||||
) -> Result<Option<AgreementMessage>, Error> {
|
||||
if let Some(agreement_instance) = self.agreement_instances.get_mut(uid) {
|
||||
if !agreement_instance.has_input() {
|
||||
Ok(Some(agreement_instance.set_input(true)))
|
||||
} else {
|
||||
|
@ -131,7 +137,7 @@ impl<NodeUid: Clone + Debug + Display + Eq + Hash + Ord> CommonSubset<NodeUid> {
|
|||
}
|
||||
};
|
||||
if instance_result.is_some() {
|
||||
self.on_broadcast_result(uid)?;
|
||||
self.on_broadcast_result(&uid)?;
|
||||
}
|
||||
input_result
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ impl<T: Send + Sync + fmt::Debug> fmt::Debug for BroadcastMessage<T> {
|
|||
}
|
||||
|
||||
/// Messages sent during the binary Byzantine agreement stage.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
pub enum AgreementMessage {
|
||||
BVal(bool),
|
||||
Aux(bool),
|
||||
|
|
|
@ -294,7 +294,7 @@ fn test_8_broadcast_equal_leaves() {
|
|||
let adversary = SilentAdversary::new(MessageScheduler::Random);
|
||||
// Space is ASCII character 32. So 32 spaces will create shards that are all equal, even if the
|
||||
// length of the value is inserted.
|
||||
test_broadcast(TestNetwork::new(8, 0, adversary), &vec![b' '; 32]);
|
||||
test_broadcast(TestNetwork::new(8, 0, adversary), &[b' '; 32]);
|
||||
}
|
||||
|
||||
// TODO: Unignore once node numbers are supported that are not powers of two.
|
||||
|
|
Loading…
Reference in New Issue