Fix Clippy (#2522)

* Import Clippy config from Polkadot

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Auto clippy fix

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* No tabs in comments

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Prefer matches

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Dont drop references

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Trivial

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Refactor

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* fmt

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* add clippy to ci

* Clippy reborrow

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Update client/pov-recovery/src/lib.rs

Co-authored-by: Bastian Köcher <git@kchr.de>

* Update client/pov-recovery/src/lib.rs

Co-authored-by: Bastian Köcher <git@kchr.de>

* Partially revert 'Prefer matches'

Using matches! instead of match does give less compiler
checks as per review from @chevdor.

Partially reverts 8c0609677f3ea040f77fffd5be6facf7c3fec95c

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Update .cargo/config.toml

Co-authored-by: Chevdor <chevdor@users.noreply.github.com>

* Revert revert 💩

Should be fine to use matches! macro since it is an explicit whitelist,
not wildcard matching.

---------

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: alvicsam <alvicsam@gmail.com>
Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: Chevdor <chevdor@users.noreply.github.com>
Co-authored-by: parity-processbot <>
This commit is contained in:
Oliver Tale-Yazdi
2023-05-06 08:01:03 +02:00
committed by GitHub
parent b72ae577a0
commit 299d25ba4b
92 changed files with 910 additions and 967 deletions
@@ -134,12 +134,12 @@ impl<
.unwrap();
}
pallet_balances::GenesisConfig::<Runtime> { balances: self.balances.into() }
pallet_balances::GenesisConfig::<Runtime> { balances: self.balances }
.assimilate_storage(&mut t)
.unwrap();
pallet_collator_selection::GenesisConfig::<Runtime> {
invulnerables: self.collators.clone().into(),
invulnerables: self.collators.clone(),
candidacy_bond: Default::default(),
desired_candidates: Default::default(),
}
@@ -303,11 +303,10 @@ impl<Runtime: frame_system::Config + pallet_xcm::Config> RuntimeHelper<Runtime>
.find_map(|e| match e {
pallet_xcm::Event::Attempted(outcome) => Some(outcome),
_ => None,
});
match outcome {
Some(outcome) => assert_outcome(outcome),
None => assert!(false, "No `pallet_xcm::Event::Attempted(outcome)` event found!"),
}
})
.expect("No `pallet_xcm::Event::Attempted(outcome)` event found!");
assert_outcome(outcome);
}
}
@@ -362,8 +361,11 @@ pub fn mock_open_hrmp_channel<
recipient: ParaId,
) {
let n = 1_u32;
let mut sproof_builder = RelayStateSproofBuilder::default();
sproof_builder.para_id = sender;
let mut sproof_builder = RelayStateSproofBuilder {
para_id: sender,
hrmp_egress_channel_index: Some(vec![recipient]),
..Default::default()
};
sproof_builder.hrmp_channels.insert(
HrmpChannelId { sender, recipient },
AbridgedHrmpChannel {
@@ -375,7 +377,6 @@ pub fn mock_open_hrmp_channel<
mqc_head: None,
},
);
sproof_builder.hrmp_egress_channel_index = Some(vec![recipient]);
let (relay_parent_storage_root, relay_chain_state) = sproof_builder.into_state_root_and_proof();
let vfp = PersistedValidationData {
@@ -388,7 +389,7 @@ pub fn mock_open_hrmp_channel<
let inherent_data = {
let mut inherent_data = InherentData::default();
let system_inherent_data = ParachainInherentData {
validation_data: vfp.clone(),
validation_data: vfp,
relay_chain_state,
downward_messages: Default::default(),
horizontal_messages: Default::default(),
@@ -134,7 +134,7 @@ pub fn teleports_for_native_asset_works<
BuyExecution {
fees: MultiAsset {
id: Concrete(native_asset_id),
fun: Fungible(buy_execution_fee_amount_eta.into()),
fun: Fungible(buy_execution_fee_amount_eta),
},
weight_limit: Limited(Weight::from_parts(303531000, 65536)),
},
@@ -190,7 +190,7 @@ pub fn teleports_for_native_asset_works<
RuntimeHelper::<Runtime>::origin_of(target_account.clone()),
dest,
dest_beneficiary,
(native_asset_id, native_asset_to_teleport_away.clone().into()),
(native_asset_id, native_asset_to_teleport_away.into()),
None,
));
// check balances
@@ -235,7 +235,7 @@ pub fn teleports_for_native_asset_works<
RuntimeHelper::<Runtime>::origin_of(target_account.clone()),
dest,
dest_beneficiary,
(native_asset_id, native_asset_to_teleport_away.clone().into()),
(native_asset_id, native_asset_to_teleport_away.into()),
Some((runtime_para_id, other_para_id)),
));
@@ -366,7 +366,7 @@ pub fn teleports_for_foreign_assets_works<
WeightToFee::weight_to_fee(&Weight::from_parts(90_000_000_000, 0));
let buy_execution_fee = MultiAsset {
id: Concrete(MultiLocation::parent()),
fun: Fungible(buy_execution_fee_amount.into()),
fun: Fungible(buy_execution_fee_amount),
};
let teleported_foreign_asset_amount = 10000000000000;
@@ -376,7 +376,7 @@ pub fn teleports_for_foreign_assets_works<
.with_session_keys(collator_session_keys.session_keys())
.with_balances(vec![
(
foreign_creator_as_account_id.clone(),
foreign_creator_as_account_id,
existential_deposit + (buy_execution_fee_amount * 2).into(),
),
(target_account.clone(), existential_deposit),
@@ -441,7 +441,7 @@ pub fn teleports_for_foreign_assets_works<
BuyExecution {
fees: MultiAsset {
id: Concrete(MultiLocation::parent()),
fun: Fungible(buy_execution_fee_amount.into()),
fun: Fungible(buy_execution_fee_amount),
},
weight_limit: Limited(Weight::from_parts(403531000, 65536)),
},
@@ -536,7 +536,7 @@ pub fn teleports_for_foreign_assets_works<
RuntimeHelper::<Runtime>::origin_of(target_account.clone()),
dest,
dest_beneficiary,
(foreign_asset_id_multilocation, asset_to_teleport_away.clone().into()),
(foreign_asset_id_multilocation, asset_to_teleport_away),
Some((runtime_para_id, foreign_para_id)),
));
@@ -788,7 +788,7 @@ pub fn asset_transactor_transfer_with_pallet_assets_instance_works<
.execute_with(|| {
// create some asset class
let asset_minimum_asset_balance = 3333333_u128;
let asset_id_as_multilocation = AssetIdConverter::reverse_ref(&asset_id).unwrap();
let asset_id_as_multilocation = AssetIdConverter::reverse_ref(asset_id).unwrap();
assert_ok!(<pallet_assets::Pallet<Runtime, AssetsPalletInstance>>::force_create(
RuntimeHelper::<Runtime>::root_origin(),
asset_id.into(),
@@ -869,7 +869,7 @@ pub fn asset_transactor_transfer_with_pallet_assets_instance_works<
id: charlie_account.clone().into()
}),
},
(asset_id_as_multilocation, 1 * asset_minimum_asset_balance),
(asset_id_as_multilocation, asset_minimum_asset_balance),
),
XcmError::FailedToTransactAsset(Into::<&str>::into(
sp_runtime::TokenError::CannotCreate
@@ -890,7 +890,7 @@ pub fn asset_transactor_transfer_with_pallet_assets_instance_works<
parents: 0,
interior: X1(AccountId32 { network: None, id: bob_account.clone().into() }),
},
(asset_id_as_multilocation, 1 * asset_minimum_asset_balance),
(asset_id_as_multilocation, asset_minimum_asset_balance),
),
Ok(_)
));
@@ -908,7 +908,7 @@ pub fn asset_transactor_transfer_with_pallet_assets_instance_works<
asset_id.into(),
&bob_account
),
(1 * asset_minimum_asset_balance).into()
asset_minimum_asset_balance.into()
);
assert_eq!(
<pallet_assets::Pallet<Runtime, AssetsPalletInstance>>::balance(
@@ -1130,7 +1130,7 @@ pub fn create_and_manage_foreign_assets_for_local_consensus_parachain_assets_wor
// lets simulate this was triggered by relay chain from local consensus sibling parachain
let xcm = Xcm(vec![
WithdrawAsset(buy_execution_fee.clone().into()),
BuyExecution { fees: buy_execution_fee.clone().into(), weight_limit: Unlimited },
BuyExecution { fees: buy_execution_fee.clone(), weight_limit: Unlimited },
Transact {
origin_kind: OriginKind::Xcm,
require_weight_at_most: Weight::from_parts(40_000_000_000, 8000),
@@ -1247,7 +1247,7 @@ pub fn create_and_manage_foreign_assets_for_local_consensus_parachain_assets_wor
});
let xcm = Xcm(vec![
WithdrawAsset(buy_execution_fee.clone().into()),
BuyExecution { fees: buy_execution_fee.clone().into(), weight_limit: Unlimited },
BuyExecution { fees: buy_execution_fee.clone(), weight_limit: Unlimited },
Transact {
origin_kind: OriginKind::Xcm,
require_weight_at_most: Weight::from_parts(20_000_000_000, 8000),