Skip to content

Commit

Permalink
fixed error kind and added test
Browse files Browse the repository at this point in the history
  • Loading branch information
Shivani912 committed Mar 5, 2020
1 parent 96b2865 commit f95c01d
Show file tree
Hide file tree
Showing 3 changed files with 13,866 additions and 13,697 deletions.
136 changes: 136 additions & 0 deletions .idea/workspace.xml~fixed error kind and added test

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 12 additions & 4 deletions tendermint/src/lite_impl/signed_header.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! [`lite::SignedHeader`] implementation for [`block::signed_header::SignedHeader`].

use crate::lite::error::{Error, Kind};
use crate::lite::ValidatorSet;
use crate::validator::Set;
use crate::{block, hash, lite, vote};
use anomaly::fail;
Expand Down Expand Up @@ -60,10 +61,10 @@ impl lite::Commit for block::signed_header::SignedHeader {
);
}

// make sure each vote is for the correct header
for precommit_opt in self.commit.precommits.iter() {
match precommit_opt {
Some(precommit) => {
// make sure each vote is for the correct header
if let Some(header_hash) = precommit.header_hash() {
if header_hash != self.header_hash() {
fail!(
Expand All @@ -75,14 +76,21 @@ impl lite::Commit for block::signed_header::SignedHeader {
);
}
}

// returns FaultyFullNode error if it detects a signer isn't present in the validator set
if vals.validator(precommit.validator_address) == None {
let reason = format!(
"Found a faulty signer ({}) not present in the validator set ({})",
precommit.validator_address,
vals.hash()
);
return Err(Kind::FaultyFullNode { reason }.into());
}
}
None => (),
}
}

// TODO: check here if all the votes are from correct validators
// TODO: return error kind "InvalidValidator" if we find a vote from a validator not in the val set

Ok(())
}
}
Expand Down
Loading

0 comments on commit f95c01d

Please sign in to comment.