Skip to content

Commit

Permalink
[refactor]: Fix clippy lints
Browse files Browse the repository at this point in the history
Signed-off-by: Daniil Polyakov <[email protected]>
  • Loading branch information
Arjentix committed Jan 23, 2024
1 parent 9c79f56 commit 1bafba1
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 4 deletions.
6 changes: 3 additions & 3 deletions core/src/sumeragi/main_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ impl Sumeragi {
if let Some(msg) = block_msg.as_ref() {
let vc_index : Option<u64> = match msg {
BlockMessage::BlockCreated(bc) => Some(bc.block.payload().header.view_change_index),
BlockMessage::BlockSigned(_) => None, // Signed and Committed contain no block.
BlockMessage::BlockCommitted(_) => None,
BlockMessage::BlockSyncUpdate(_) => None, // Block sync updates are exempt from early pruning
// Signed and Committed contain no block.
// Block sync updates are exempt from early pruning.
BlockMessage::BlockSigned(_) | BlockMessage::BlockCommitted(_) | BlockMessage::BlockSyncUpdate(_) => None,
};
if let Some(vc_index) = vc_index {
if vc_index < current_view_change_index {
Expand Down
1 change: 1 addition & 0 deletions crypto/src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ impl<T> Clone for HashOf<T> {
}
impl<T> Copy for HashOf<T> {}

#[allow(clippy::unconditional_recursion)] // False-positive
impl<T> PartialEq for HashOf<T> {
fn eq(&self, other: &Self) -> bool {
self.0.eq(&other.0)
Expand Down
4 changes: 4 additions & 0 deletions crypto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,10 @@ ffi::ffi_item! {
#[ffi_impl_opaque]
impl PublicKey {
/// Creates a new public key from raw bytes received from elsewhere
///
/// # Errors
///
/// Fails if public key parsing fails
pub fn from_raw(algorithm: Algorithm, payload: &[u8]) -> Result<Self, ParseError> {
match algorithm {
Algorithm::Ed25519 => {
Expand Down
2 changes: 1 addition & 1 deletion crypto/src/signature/bls/implementation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl<C: BlsConfiguration + ?Sized> BlsImpl<C> {
.map_err(|_| ParseError("Failed to parse signature.".to_owned()))?;
let message = w3f_bls::Message::new(MESSAGE_CONTEXT, message);

if !signature.verify(&message, &pk) {
if !signature.verify(&message, pk) {
return Err(Error::BadSignature);
}

Expand Down
2 changes: 2 additions & 0 deletions crypto/src/signature/bls/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const MESSAGE_1: &[u8; 22] = b"This is a test message";
const MESSAGE_2: &[u8; 20] = b"Another test message";
const SEED: &[u8; 10] = &[1u8; 10];

#[allow(clippy::similar_names)]
fn test_keypair_generation_from_seed<C: BlsConfiguration>() {
let (pk_1, sk_1) = BlsImpl::<C>::keypair(Some(KeyGenOption::UseSeed(SEED.to_vec())));
let (pk_2, sk_2) = BlsImpl::<C>::keypair(Some(KeyGenOption::UseSeed(SEED.to_vec())));
Expand All @@ -37,6 +38,7 @@ fn test_signature_verification_different_messages<C: BlsConfiguration>() {
.expect_err("Signature verification for wrong message should fail");
}

#[allow(clippy::similar_names)]
fn test_signature_verification_different_keys<C: BlsConfiguration>() {
let (_pk_1, sk_1) = BlsImpl::<C>::keypair(None);
let (pk_2, _sk_2) = BlsImpl::<C>::keypair(None);
Expand Down
3 changes: 3 additions & 0 deletions crypto/src/signature/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ impl<T> Clone for SignatureOf<T> {
}
}

#[allow(clippy::unconditional_recursion)] // False-positive
impl<T> PartialEq for SignatureOf<T> {
fn eq(&self, other: &Self) -> bool {
self.0.eq(&other.0)
Expand Down Expand Up @@ -266,6 +267,7 @@ impl<T> Clone for SignatureWrapperOf<T> {
}
}

#[allow(clippy::unconditional_recursion)] // False-positive
#[cfg(not(feature = "ffi_import"))]
impl<T> PartialEq for SignatureWrapperOf<T> {
fn eq(&self, other: &Self) -> bool {
Expand Down Expand Up @@ -329,6 +331,7 @@ impl<T> Clone for SignaturesOf<T> {
}
}

#[allow(clippy::unconditional_recursion)] // False-positive
#[cfg(not(feature = "ffi_import"))]
impl<T> PartialEq for SignaturesOf<T> {
fn eq(&self, other: &Self) -> bool {
Expand Down
1 change: 1 addition & 0 deletions primitives/src/small.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ mod small_vector {
}
}

#[allow(clippy::unconditional_recursion)] // False-positive
impl<A: Array> PartialEq for SmallVec<A>
where
A::Item: PartialEq,
Expand Down

0 comments on commit 1bafba1

Please sign in to comment.