Skip to content

Commit

Permalink
Clippy (#150)
Browse files Browse the repository at this point in the history
  • Loading branch information
aurexav authored Dec 21, 2022
1 parent acc0c60 commit e4cf09a
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 26 deletions.
1 change: 1 addition & 0 deletions core/inflation/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use crate::*;
fn inflate_should_work() {
let max = 10_000_000_000_u128 * UNIT;
let init = 2_000_000_000_u128 * UNIT;
#[allow(clippy::approx_constant)]
let rates = [
4_f64, 5.37, 6.15, 6.56, 6.74, 6.76, 6.66, 6.5, 6.28, 6.04, 5.79, 5.52, 5.26, 4.99, 4.74,
4.49, 4.25, 4.03, 3.81, 3.6, 3.4, 3.21, 3.04, 2.87, 2.71, 2.55, 2.41, 2.27, 2.14, 2.02,
Expand Down
6 changes: 3 additions & 3 deletions pallet/deposit/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,13 @@ fn claim_should_work() {
assert!(Deposit::deposit_of(&1).is_none());

assert_ok!(Deposit::lock(RuntimeOrigin::signed(1), UNIT, 1));
assert!(!Deposit::deposit_of(&1).is_none());
assert!(Deposit::deposit_of(&1).is_some());

efflux(MILLISECS_PER_MONTH - 1);
assert_eq!(System::account(&1).consumers, 1);
assert_ok!(Deposit::claim(RuntimeOrigin::signed(1)));
assert_eq!(System::account(&1).consumers, 1);
assert!(!Deposit::deposit_of(&1).is_none());
assert!(Deposit::deposit_of(&1).is_some());

efflux(MILLISECS_PER_MONTH);
assert_eq!(System::account(&1).consumers, 1);
Expand All @@ -273,7 +273,7 @@ fn claim_should_work() {
assert_eq!(System::account(&1).consumers, 1);
assert_ok!(Deposit::claim(RuntimeOrigin::signed(1)));
assert_eq!(System::account(&1).consumers, 1);
assert!(!Deposit::deposit_of(&1).is_none());
assert!(Deposit::deposit_of(&1).is_some());

assert_ok!(Deposit::unstake(&1, 0));
assert_eq!(System::account(&1).consumers, 1);
Expand Down
2 changes: 1 addition & 1 deletion pallet/message-transact/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ impl CallValidate<AccountId, RuntimeOrigin, RuntimeCall> for MockCallValidator {
match call {
RuntimeCall::MessageTransact(crate::Call::message_transact { transaction: tx }) => {
let total_payment = crate::total_payment::<TestRuntime>((&**tx).into());
let relayer = pallet_evm::Pallet::<TestRuntime>::account_basic(&relayer_account).0;
let relayer = pallet_evm::Pallet::<TestRuntime>::account_basic(relayer_account).0;

ensure!(relayer.balance >= total_payment, "Insufficient balance");
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion pallet/message-transact/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl LegacyUnsignedTransaction {
fn signing_hash(&self) -> H256 {
let mut stream = RlpStream::new();
self.signing_rlp_append(&mut stream);
H256::from_slice(&Keccak256::digest(&stream.out()).as_slice())
H256::from_slice(Keccak256::digest(&stream.out()).as_slice())
}

pub fn sign(&self, key: &H256) -> Transaction {
Expand Down
4 changes: 2 additions & 2 deletions pallet/staking/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl pallet_session::SessionHandler<u32> for TestSessionHandler {
&[sp_runtime::testing::UintAuthorityId::ID];

fn on_genesis_session<Ks: sp_runtime::traits::OpaqueKeys>(keys: &[(u32, Ks)]) {
SessionHandlerCollators::set(keys.into_iter().map(|(a, _)| *a).collect::<Vec<_>>())
SessionHandlerCollators::set(keys.iter().map(|(a, _)| *a).collect::<Vec<_>>())
}

fn on_new_session<Ks: sp_runtime::traits::OpaqueKeys>(
Expand All @@ -163,7 +163,7 @@ impl pallet_session::SessionHandler<u32> for TestSessionHandler {
_: &[(u32, Ks)],
) {
SessionChangeBlock::set(System::block_number());
SessionHandlerCollators::set(keys.into_iter().map(|(a, _)| *a).collect::<Vec<_>>())
SessionHandlerCollators::set(keys.iter().map(|(a, _)| *a).collect::<Vec<_>>())
}

fn on_before_session_ending() {}
Expand Down
10 changes: 5 additions & 5 deletions pallet/staking/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ fn unstake_should_work() {
assert_eq!(
Staking::ledger_of(1).unwrap(),
Ledger {
staked_ring: 1 * UNIT,
staked_ring: UNIT,
staked_kton: 2 * UNIT,
staked_deposits: BoundedVec::truncate_from(vec![0, 1, 2]),
unstaking_ring: BoundedVec::truncate_from(vec![(UNIT, 4)]),
Expand All @@ -125,8 +125,8 @@ fn unstake_should_work() {
assert_eq!(
Staking::ledger_of(1).unwrap(),
Ledger {
staked_ring: 1 * UNIT,
staked_kton: 1 * UNIT,
staked_ring: UNIT,
staked_kton: UNIT,
staked_deposits: BoundedVec::truncate_from(vec![0, 1, 2]),
unstaking_ring: BoundedVec::truncate_from(vec![(UNIT, 4)]),
unstaking_kton: BoundedVec::truncate_from(vec![(UNIT, 5)]),
Expand All @@ -140,8 +140,8 @@ fn unstake_should_work() {
assert_eq!(
Staking::ledger_of(1).unwrap(),
Ledger {
staked_ring: 1 * UNIT,
staked_kton: 1 * UNIT,
staked_ring: UNIT,
staked_kton: UNIT,
staked_deposits: BoundedVec::truncate_from(vec![1, 2]),
unstaking_ring: BoundedVec::truncate_from(vec![(UNIT, 4)]),
unstaking_kton: BoundedVec::truncate_from(vec![(UNIT, 5)]),
Expand Down
3 changes: 1 addition & 2 deletions precompile/assets/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ fn addr(a: u64) -> H160 {
pub struct AssetIdConverter;
impl AccountToAssetId<AccountId, AssetId> for AssetIdConverter {
fn account_to_asset_id(account_id: AccountId) -> AssetId {
let addr: H160 = account_id.into();
addr.to_low_u64_be()
account_id.to_low_u64_be()
}
}

Expand Down
12 changes: 6 additions & 6 deletions precompile/assets/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,8 @@ fn transfer_not_enough_founds() {
InternalCall::transfer { to: Address(Charlie.into()), value: 50.into() },
)
.execute_reverts(|output| {
from_utf8(&output).unwrap().contains("Dispatched call failed with error: ")
&& from_utf8(&output).unwrap().contains("BalanceLow")
from_utf8(output).unwrap().contains("Dispatched call failed with error: ")
&& from_utf8(output).unwrap().contains("BalanceLow")
});
});
}
Expand Down Expand Up @@ -665,8 +665,8 @@ fn freeze() {
InternalCall::transfer { to: Address(Alice.into()), value: 400.into() },
)
.execute_reverts(|output| {
from_utf8(&output).unwrap().contains("Dispatched call failed with error: ")
&& from_utf8(&output).unwrap().contains("Frozen")
from_utf8(output).unwrap().contains("Dispatched call failed with error: ")
&& from_utf8(output).unwrap().contains("Frozen")
});
});
}
Expand Down Expand Up @@ -753,8 +753,8 @@ fn transfer_ownership() {
InternalCall::transfer_ownership { owner: Address(Bob.into()) },
)
.execute_reverts(|output| {
from_utf8(&output).unwrap().contains("Dispatched call failed with error: ")
&& from_utf8(&output).unwrap().contains("NoPermission")
from_utf8(output).unwrap().contains("Dispatched call failed with error: ")
&& from_utf8(output).unwrap().contains("NoPermission")
});

precompiles()
Expand Down
6 changes: 0 additions & 6 deletions tool/state-processor/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,6 @@ where
Ok(serde_json::from_slice(&v)?)
}

fn pallet_key(pallet: &[u8]) -> String {
let prefix = subhasher::twox128(pallet);

array_bytes::bytes2hex("0x", prefix)
}

fn item_key(pallet: &[u8], item: &[u8]) -> String {
let k = substorager::storage_key(pallet, item);

Expand Down

0 comments on commit e4cf09a

Please sign in to comment.