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
@@ -77,19 +77,16 @@ fn test_asset_xcm_trader() {
// Lets pay with: asset_amount_needed + asset_amount_extra
let asset_amount_extra = 100_u128;
let asset: MultiAsset =
(asset_multilocation.clone(), asset_amount_needed + asset_amount_extra).into();
(asset_multilocation, asset_amount_needed + asset_amount_extra).into();
let mut trader = <XcmConfig as xcm_executor::Config>::Trader::new();
// Lets buy_weight and make sure buy_weight does not return an error
match trader.buy_weight(bought, asset.into()) {
Ok(unused_assets) => {
// Check whether a correct amount of unused assets is returned
assert_ok!(unused_assets
.ensure_contains(&(asset_multilocation, asset_amount_extra).into()));
},
Err(e) => assert!(false, "Expected Ok(_). Got {:#?}", e),
}
let unused_assets = trader.buy_weight(bought, asset.into()).expect("Expected Ok");
// Check whether a correct amount of unused assets is returned
assert_ok!(
unused_assets.ensure_contains(&(asset_multilocation, asset_amount_extra).into())
);
// Drop trader
drop(trader);
@@ -150,7 +147,7 @@ fn test_asset_xcm_trader_with_refund() {
// lets calculate amount needed
let amount_bought = WeightToFee::weight_to_fee(&bought);
let asset: MultiAsset = (asset_multilocation.clone(), amount_bought).into();
let asset: MultiAsset = (asset_multilocation, amount_bought).into();
// Make sure buy_weight does not return an error
assert_ok!(trader.buy_weight(bought, asset.clone().into()));
@@ -224,7 +221,7 @@ fn test_asset_xcm_trader_refund_not_possible_since_amount_less_than_ed() {
"we are testing what happens when the amount does not exceed ED"
);
let asset: MultiAsset = (asset_multilocation.clone(), amount_bought).into();
let asset: MultiAsset = (asset_multilocation, amount_bought).into();
// Buy weight should return an error
assert_noop!(trader.buy_weight(bought, asset.into()), XcmError::TooExpensive);
@@ -277,11 +274,11 @@ fn test_that_buying_ed_refund_does_not_refund() {
// We know we will have to buy at least ED, so lets make sure first it will
// fail with a payment of less than ED
let asset: MultiAsset = (asset_multilocation.clone(), amount_bought).into();
let asset: MultiAsset = (asset_multilocation, amount_bought).into();
assert_noop!(trader.buy_weight(bought, asset.into()), XcmError::TooExpensive);
// Now lets buy ED at least
let asset: MultiAsset = (asset_multilocation.clone(), ExistentialDeposit::get()).into();
let asset: MultiAsset = (asset_multilocation, ExistentialDeposit::get()).into();
// Buy weight should work
assert_ok!(trader.buy_weight(bought, asset.into()));
@@ -416,7 +413,7 @@ fn test_assets_balances_api_works() {
let foreign_asset_minimum_asset_balance = 3333333_u128;
assert_ok!(ForeignAssets::force_create(
RuntimeHelper::<Runtime>::root_origin(),
foreign_asset_id_multilocation.clone().into(),
foreign_asset_id_multilocation,
AccountId::from(SOME_ASSET_ADMIN).into(),
false,
foreign_asset_minimum_asset_balance
@@ -425,7 +422,7 @@ fn test_assets_balances_api_works() {
// We first mint enough asset for the account to exist for assets
assert_ok!(ForeignAssets::mint(
RuntimeHelper::<Runtime>::origin_of(AccountId::from(SOME_ASSET_ADMIN)),
foreign_asset_id_multilocation.clone().into(),
foreign_asset_id_multilocation,
AccountId::from(ALICE).into(),
6 * foreign_asset_minimum_asset_balance
));