Skip to content

Commit

Permalink
Fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrylavrenov committed Sep 12, 2024
1 parent f63029b commit e522cff
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 15 deletions.
6 changes: 3 additions & 3 deletions crates/humanode-runtime/src/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! The benchmarking utilities.

// Allow simple integer arithmetic in tests.
#![allow(clippy::integer_arithmetic)]
// Allow integer arithmetic in tests.
#![allow(clippy::arithmetic_side_effects)]

use eip712_common::keccak_256;
use frame_support::{
Expand Down Expand Up @@ -44,7 +44,7 @@ fn ethereum_address_from_secret(secret: &libsecp256k1::SecretKey) -> EthereumAdd
}

fn eth_ecdsa_sign(secret: &libsecp256k1::SecretKey, msg_hash: &[u8; 32]) -> EcdsaSignature {
let (sig, recovery_id) = libsecp256k1::sign(&libsecp256k1::Message::parse(&msg_hash), secret);
let (sig, recovery_id) = libsecp256k1::sign(&libsecp256k1::Message::parse(msg_hash), secret);
let mut ecdsa_signature = [0u8; 65];
ecdsa_signature[0..64].copy_from_slice(&sig.serialize()[..]);
ecdsa_signature[64] = recovery_id.serialize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ pub mod pallet {

#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<Vec<u8>, &'static str> {
upgrade_init::pre_upgrade::<T>()
upgrade_init::pre_upgrade()
}

#[cfg(feature = "try-runtime")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub fn on_runtime_upgrade<T: Config>() -> Weight {
///
/// Panics if anything goes wrong.
#[cfg(feature = "try-runtime")]
pub fn pre_upgrade<T: Config>() -> Result<Vec<u8>, &'static str> {
pub fn pre_upgrade() -> Result<Vec<u8>, &'static str> {
// Do nothing.
Ok(Vec::new())
}
Expand Down
9 changes: 7 additions & 2 deletions crates/pallet-bioauth/src/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
//! Benchmark for pallet-bioauth extrinsics.

// Allow integer and float arithmetic in tests.
#![allow(clippy::arithmetic_side_effects, clippy::float_arithmetic)]

use frame_benchmarking::benchmarks;
use frame_support::traits::{Get, Hooks};
use frame_system::RawOrigin;
Expand Down Expand Up @@ -38,6 +41,7 @@ fn make_pubkey(prefix: &str, idx: u32) -> Vec<u8> {
pubkey
}

/// A helper function to make nonce.
fn make_nonce(prefix: &str, idx: u32) -> Vec<u8> {
let mut nonce = Vec::from(prefix);
let idx_in_bytes = idx.to_le_bytes();
Expand Down Expand Up @@ -67,9 +71,10 @@ fn make_authentications<Pubkey: From<[u8; 32]>, Moment: Copy>(
expires_at: Moment,
) -> Vec<Authentication<Pubkey, Moment>> {
(0..count)
.into_iter()
.map(|i| {
let public_key: [u8; 32] = make_pubkey(prefix, i as u32).try_into().unwrap();
let public_key: [u8; 32] = make_pubkey(prefix, i.try_into().unwrap())
.try_into()
.unwrap();
Authentication {
public_key: public_key.into(),
expires_at,
Expand Down
9 changes: 2 additions & 7 deletions crates/pallet-bioauth/src/mock/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,13 @@ impl crate::ValidatorSetUpdater<ValidatorPublicKey> for MockValidatorSetUpdater
) where
ValidatorPublicKey: 'a,
{
()
}

fn init_validators_set<'a, I: Iterator<Item = &'a ValidatorPublicKey> + 'a>(
_validator_public_keys: I,
) where
ValidatorPublicKey: 'a,
{
()
}
}

Expand Down Expand Up @@ -225,11 +223,8 @@ impl crate::benchmarking::RobonodePublicKeyBuilder for Benchmark {

/// Build benchmark externalities from the default genesis.
pub fn new_benchmark_ext() -> sp_io::TestExternalities {
// Build externalities with default genesis.
let externalities = new_benchmark_ext_with(Default::default());

// Return ready-to-use externalities.
externalities
// Build externalities with default genesis and return ready-to-use externalities.
new_benchmark_ext_with(Default::default())
}

/// Build benchmark externalities from the custom genesis.
Expand Down
5 changes: 4 additions & 1 deletion crates/pallet-currency-swap/src/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
//! The benchmarks for the pallet.

// Allow integer and float arithmetic in tests.
#![allow(clippy::arithmetic_side_effects, clippy::float_arithmetic)]

use frame_benchmarking::benchmarks;
use frame_support::{assert_ok, dispatch::DispatchResult, traits::Currency};
use frame_system::RawOrigin;
Expand Down Expand Up @@ -91,7 +94,7 @@ impl Interface for crate::mock::Test {
swap_ctx.expect().times(1..).return_once(move |_| {
Ok(
<mock::EvmBalances as Currency<mock::EvmAccountId>>::NegativeImbalance::new(
Self::to_balance().into(),
Self::to_balance(),
),
)
});
Expand Down
3 changes: 3 additions & 0 deletions crates/pallet-evm-accounts-mapping/src/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
//! The benchmarks for the pallet.

// Allow float arithmetic in tests.
#![allow(clippy::float_arithmetic)]

use frame_benchmarking::benchmarks;
use frame_system::RawOrigin;
use primitives_ethereum::{EcdsaSignature, EthereumAddress};
Expand Down
3 changes: 3 additions & 0 deletions crates/pallet-token-claims/src/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
//! The benchmarks for the pallet.

// Allow integer and float arithmetic in tests.
#![allow(clippy::arithmetic_side_effects, clippy::float_arithmetic)]

use frame_benchmarking::benchmarks;
use frame_support::{assert_ok, dispatch::DispatchResult, traits::Get};
use frame_system::RawOrigin;
Expand Down
3 changes: 3 additions & 0 deletions crates/pallet-vesting/src/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
//! The benchmarks for the pallet.

// Allow integer and float arithmetic in tests.
#![allow(clippy::arithmetic_side_effects, clippy::float_arithmetic)]

use frame_benchmarking::benchmarks;
use frame_support::{
assert_ok,
Expand Down

0 comments on commit e522cff

Please sign in to comment.