Skip to content

Commit

Permalink
Fix clippy lints (#1362)
Browse files Browse the repository at this point in the history
  • Loading branch information
vedhavyas authored Sep 13, 2024
1 parent 817717c commit 393b50b
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 42 deletions.
6 changes: 1 addition & 5 deletions pallets/collator-selection/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,7 @@ parameter_types! {
pub struct IsRegistered;
impl ValidatorRegistration<u64> for IsRegistered {
fn is_registered(id: &u64) -> bool {
if *id == 7u64 {
false
} else {
true
}
*id != 7u64
}
}

Expand Down
1 change: 0 additions & 1 deletion pallets/dapp-staking/src/test/tests_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2913,7 +2913,6 @@ fn tier_configuration_basic_tests() {
},
])
.unwrap(),
..TierParameters::default()
};
assert!(params.is_valid(), "Example params must be valid!");

Expand Down
2 changes: 1 addition & 1 deletion pallets/vesting-mbm/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl ExtBuilder {
}

pub fn new_test_ext() -> sp_io::TestExternalities {
ExtBuilder::default().build()
ExtBuilder.build()
}

#[allow(dead_code)]
Expand Down
16 changes: 8 additions & 8 deletions precompiles/dispatch-lockdrop/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn precompiles() -> TestPrecompileSet<TestRuntime> {

#[test]
fn dispatch_calls_on_behalf_of_lockdrop_works() {
ExtBuilder::default().build().execute_with(|| {
ExtBuilder.build().execute_with(|| {
// Transfer balance to Alice
let call = RuntimeCall::Balances(pallet_balances::Call::transfer_keep_alive {
dest: ALICE,
Expand Down Expand Up @@ -73,7 +73,7 @@ fn dispatch_calls_on_behalf_of_lockdrop_works() {

#[test]
fn proper_gas_is_charged() {
ExtBuilder::default().build().execute_with(|| {
ExtBuilder.build().execute_with(|| {
let call = RuntimeCall::Balances(pallet_balances::Call::transfer_keep_alive {
dest: ALICE,
value: 15 * ONE,
Expand Down Expand Up @@ -109,7 +109,7 @@ fn proper_gas_is_charged() {

#[test]
fn pubkey_does_not_match_caller_address() {
ExtBuilder::default().build().execute_with(|| {
ExtBuilder.build().execute_with(|| {
// Transfer balance to Alice
let call = RuntimeCall::Balances(pallet_balances::Call::transfer_keep_alive {
dest: ALICE,
Expand Down Expand Up @@ -146,7 +146,7 @@ fn pubkey_does_not_match_caller_address() {

#[test]
fn pubkey_derive_to_proper_ss58() {
ExtBuilder::default().build().execute_with(|| {
ExtBuilder.build().execute_with(|| {
// Transfer balance to Alice
let call = RuntimeCall::Balances(pallet_balances::Call::transfer_keep_alive {
dest: ALICE,
Expand Down Expand Up @@ -187,7 +187,7 @@ fn pubkey_derive_to_proper_ss58() {

#[test]
fn decode_limit_too_high() {
ExtBuilder::default().build().execute_with(|| {
ExtBuilder.build().execute_with(|| {
let mut nested_call =
RuntimeCall::System(frame_system::Call::remark { remark: Vec::new() });

Expand Down Expand Up @@ -224,7 +224,7 @@ fn decode_limit_too_high() {

#[test]
fn decode_limit_bounded() {
ExtBuilder::default().build().execute_with(|| {
ExtBuilder.build().execute_with(|| {
let calls: Vec<_> = (0..681)
.map(|_| RuntimeCall::System(frame_system::Call::remark { remark: Vec::new() }))
.collect();
Expand Down Expand Up @@ -273,7 +273,7 @@ fn decode_limit_bounded() {

#[test]
fn decode_limit_ok() {
ExtBuilder::default().build().execute_with(|| {
ExtBuilder.build().execute_with(|| {
let mut nested_call =
RuntimeCall::System(frame_system::Call::remark { remark: Vec::new() });

Expand Down Expand Up @@ -309,7 +309,7 @@ fn decode_limit_ok() {

#[test]
fn only_whitelisted_calls_can_be_dispatched() {
ExtBuilder::default().build().execute_with(|| {
ExtBuilder.build().execute_with(|| {
// Transfer balance to Alice
let call = RuntimeCall::System(frame_system::Call::remark_with_event {
remark: b"Hello World".to_vec(),
Expand Down
6 changes: 3 additions & 3 deletions precompiles/sr25519/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn precompiles() -> TestPrecompileSet<Runtime> {

#[test]
fn wrong_signature_length_returns_false() {
ExtBuilder::default().build().execute_with(|| {
ExtBuilder.build().execute_with(|| {
let pair = sr25519::Pair::from_seed(b"12345678901234567890123456789012");
let public = pair.public();
let signature = hex!["0042"];
Expand All @@ -52,7 +52,7 @@ fn wrong_signature_length_returns_false() {

#[test]
fn bad_signature_returns_false() {
ExtBuilder::default().build().execute_with(|| {
ExtBuilder.build().execute_with(|| {
let pair = sr25519::Pair::from_seed(b"12345678901234567890123456789012");
let public = pair.public();
let message = hex!("2f8c6129d816cf51c374bc7f08c3e63ed156cf78aefb4a6550d97b87997977ee00000000000000000200d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a4500000000000000");
Expand All @@ -78,7 +78,7 @@ fn bad_signature_returns_false() {

#[test]
fn substrate_test_vector_works() {
ExtBuilder::default().build().execute_with(|| {
ExtBuilder.build().execute_with(|| {
let pair = sr25519::Pair::from_seed(b"12345678901234567890123456789012");
let public = pair.public();
assert_eq!(
Expand Down
6 changes: 3 additions & 3 deletions precompiles/substrate-ecdsa/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn precompiles() -> TestPrecompileSet<Runtime> {

#[test]
fn wrong_signature_length_returns_false() {
ExtBuilder::default().build().execute_with(|| {
ExtBuilder.build().execute_with(|| {
let pair = ecdsa::Pair::from_seed(b"12345678901234567890123456789012");
let public = pair.public();
let signature = hex!["0042"];
Expand All @@ -52,7 +52,7 @@ fn wrong_signature_length_returns_false() {

#[test]
fn bad_signature_returns_false() {
ExtBuilder::default().build().execute_with(|| {
ExtBuilder.build().execute_with(|| {
let pair = ecdsa::Pair::from_seed(b"12345678901234567890123456789012");
let public = pair.public();
let message = hex!("2f8c6129d816cf51c374bc7f08c3e63ed156cf78aefb4a6550d97b87997977ee00000000000000000200d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a4500000000000000");
Expand All @@ -78,7 +78,7 @@ fn bad_signature_returns_false() {

#[test]
fn substrate_test_vector_works() {
ExtBuilder::default().build().execute_with(|| {
ExtBuilder.build().execute_with(|| {
let pair = ecdsa::Pair::from_seed(&hex!(
"1d2187216832d1ee14be2e677f9e3ebceca715510ba1460a20d6fce07ba36b1e"
));
Expand Down
8 changes: 4 additions & 4 deletions precompiles/unified-accounts/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn precompiles() -> TestPrecompileSet<TestRuntime> {
#[test]
fn test_get_evm_address() {
// Case 1 : Address Not Mapped
ExtBuilder::default().build().execute_with(|| {
ExtBuilder.build().execute_with(|| {
let alice_default_evm =
<TestRuntime as pallet_unified_accounts::Config>::DefaultMappings::to_default_h160(
&ALICE,
Expand All @@ -49,7 +49,7 @@ fn test_get_evm_address() {
});

// Case 2 : Address Mapped
ExtBuilder::default().build().execute_with(|| {
ExtBuilder.build().execute_with(|| {
let alice_eth = UnifiedAccounts::eth_address(&alice_secret());
let signature = get_evm_signature(&ALICE, &alice_secret());

Expand Down Expand Up @@ -77,7 +77,7 @@ fn test_get_evm_address() {
#[test]
fn test_get_native_address() {
// Case 1: not mapped native address (default address)
ExtBuilder::default().build().execute_with(|| {
ExtBuilder.build().execute_with(|| {
let alice_eth = UnifiedAccounts::eth_address(&alice_secret());
let alice_eth_address: Address = alice_eth.into();

Expand All @@ -101,7 +101,7 @@ fn test_get_native_address() {
});

// Case 2 : mapped address
ExtBuilder::default().build().execute_with(|| {
ExtBuilder.build().execute_with(|| {
// claiming address
let alice_eth: Address = UnifiedAccounts::eth_address(&alice_secret()).into();
let signature = get_evm_signature(&ALICE, &alice_secret());
Expand Down
32 changes: 16 additions & 16 deletions precompiles/xcm/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ mod xcm_old_interface_test {
use super::*;
#[test]
fn wrong_assets_len_or_fee_index_reverts() {
ExtBuilder::default().build().execute_with(|| {
ExtBuilder.build().execute_with(|| {
precompiles()
.prepare_test(
TestAccount::Alice,
Expand Down Expand Up @@ -74,7 +74,7 @@ mod xcm_old_interface_test {

#[test]
fn sanity_checks_for_parameters() {
ExtBuilder::default().build().execute_with(|| {
ExtBuilder.build().execute_with(|| {
// parachain id resolution failure
precompiles()
.prepare_test(
Expand Down Expand Up @@ -128,7 +128,7 @@ mod xcm_old_interface_test {

#[test]
fn assets_withdraw_works() {
ExtBuilder::default().build().execute_with(|| {
ExtBuilder.build().execute_with(|| {
// SS58
precompiles()
.prepare_test(
Expand Down Expand Up @@ -184,7 +184,7 @@ mod xcm_old_interface_test {

#[test]
fn remote_transact_works() {
ExtBuilder::default().build().execute_with(|| {
ExtBuilder.build().execute_with(|| {
// SS58
precompiles()
.prepare_test(
Expand All @@ -206,7 +206,7 @@ mod xcm_old_interface_test {

#[test]
fn reserve_transfer_assets_works() {
ExtBuilder::default().build().execute_with(|| {
ExtBuilder.build().execute_with(|| {
// SS58
precompiles()
.prepare_test(
Expand Down Expand Up @@ -283,7 +283,7 @@ mod xcm_old_interface_test {

#[test]
fn reserve_transfer_currency_works() {
ExtBuilder::default().build().execute_with(|| {
ExtBuilder.build().execute_with(|| {
precompiles()
.prepare_test(
TestAccount::Alice,
Expand Down Expand Up @@ -358,7 +358,7 @@ mod xcm_old_interface_test {

#[test]
fn test_send_clear_origin() {
ExtBuilder::default().build().execute_with(|| {
ExtBuilder.build().execute_with(|| {
let dest: Location = Location {
parents: 1,
interior: AccountId32 {
Expand Down Expand Up @@ -396,7 +396,7 @@ mod xcm_new_interface_test {
fn xtokens_transfer_works() {
let weight = WeightV2::from(3_000_000_000u64, 1024);

ExtBuilder::default().build().execute_with(|| {
ExtBuilder.build().execute_with(|| {
let parent_destination = Location {
parents: 1,
interior: Junctions::from(Junction::AccountId32 {
Expand Down Expand Up @@ -489,7 +489,7 @@ mod xcm_new_interface_test {
}),
};

ExtBuilder::default().build().execute_with(|| {
ExtBuilder.build().execute_with(|| {
// sending native token to relay
precompiles()
.prepare_test(
Expand Down Expand Up @@ -525,7 +525,7 @@ mod xcm_new_interface_test {
#[test]
fn xtokens_transfer_with_fee_works() {
let weight = WeightV2::from(3_000_000_000u64, 1024);
ExtBuilder::default().build().execute_with(|| {
ExtBuilder.build().execute_with(|| {
let parent_destination = Location {
parents: 1,
interior: Junctions::from(Junction::AccountId32 {
Expand Down Expand Up @@ -582,7 +582,7 @@ mod xcm_new_interface_test {
}),
};

ExtBuilder::default().build().execute_with(|| {
ExtBuilder.build().execute_with(|| {
// sending native token to relay
precompiles()
.prepare_test(
Expand Down Expand Up @@ -622,7 +622,7 @@ mod xcm_new_interface_test {
#[test]
fn transfer_multiasset_works() {
let weight = WeightV2::from(3_000_000_000u64, 1024);
ExtBuilder::default().build().execute_with(|| {
ExtBuilder.build().execute_with(|| {
let relay_token_location = Location {
parents: 1,
interior: Junctions::Here,
Expand Down Expand Up @@ -771,7 +771,7 @@ mod xcm_new_interface_test {
]
.into();

ExtBuilder::default().build().execute_with(|| {
ExtBuilder.build().execute_with(|| {
precompiles()
.prepare_test(
TestAccount::Alice,
Expand Down Expand Up @@ -837,7 +837,7 @@ mod xcm_new_interface_test {
]
.into();

ExtBuilder::default().build().execute_with(|| {
ExtBuilder.build().execute_with(|| {
precompiles()
.prepare_test(
TestAccount::Alice,
Expand Down Expand Up @@ -887,7 +887,7 @@ mod xcm_new_interface_test {
])
.unwrap();

ExtBuilder::default().build().execute_with(|| {
ExtBuilder.build().execute_with(|| {
precompiles()
.prepare_test(
TestAccount::Alice,
Expand Down Expand Up @@ -944,7 +944,7 @@ mod xcm_new_interface_test {
]
.into();

ExtBuilder::default().build().execute_with(|| {
ExtBuilder.build().execute_with(|| {
precompiles()
.prepare_test(
TestAccount::Alice,
Expand Down
2 changes: 1 addition & 1 deletion tests/xcm-simulator/src/mocks/msg_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ pub mod mock_msg_queue {
let _ = XcmpMessageFormat::decode(&mut data_ref)
.expect("Simulator encodes with versioned xcm format; qed");

let mut remaining_fragments = &data_ref[..];
let mut remaining_fragments = data_ref;
while !remaining_fragments.is_empty() {
if let Ok(xcm) =
VersionedXcm::<T::RuntimeCall>::decode(&mut remaining_fragments)
Expand Down

0 comments on commit 393b50b

Please sign in to comment.