From 98dfd7abf9b4cc5781afeeb24dd6686f3da63274 Mon Sep 17 00:00:00 2001 From: Malte Kliemann Date: Mon, 26 Feb 2024 23:06:53 +0100 Subject: [PATCH] Fix formatting and linter errors --- node/src/benchmarking.rs | 2 +- node/src/chain_spec/mod.rs | 2 +- node/src/command.rs | 10 +-- primitives/src/math/fixed.rs | 2 +- zrml/court/src/lib.rs | 9 +-- zrml/global-disputes/src/lib.rs | 4 +- zrml/neo-swaps/src/benchmarking.rs | 18 ++---- zrml/neo-swaps/src/mock.rs | 3 +- zrml/neo-swaps/src/tests/buy.rs | 2 +- .../src/tests/liquidity_tree_interactions.rs | 2 +- zrml/neo-swaps/src/tests/mod.rs | 2 +- zrml/neo-swaps/src/tests/sell.rs | 2 +- zrml/orderbook/src/benchmarks.rs | 2 +- zrml/orderbook/src/lib.rs | 2 +- zrml/orderbook/src/tests.rs | 2 +- zrml/parimutuel/src/benchmarking.rs | 2 +- zrml/parimutuel/src/lib.rs | 17 ++--- zrml/parimutuel/src/tests/buy.rs | 8 +-- zrml/prediction-markets/src/benchmarks.rs | 19 ++---- zrml/prediction-markets/src/lib.rs | 14 ++-- .../src/tests/schedule_early_close.rs | 2 +- zrml/rikiddo/src/tests/pallet.rs | 64 +++++++------------ zrml/swaps/src/benchmarks.rs | 11 +--- zrml/swaps/src/lib.rs | 2 +- zrml/swaps/src/tests.rs | 2 +- 25 files changed, 84 insertions(+), 121 deletions(-) diff --git a/node/src/benchmarking.rs b/node/src/benchmarking.rs index 0c5288e77..1231e629c 100644 --- a/node/src/benchmarking.rs +++ b/node/src/benchmarking.rs @@ -283,7 +283,7 @@ pub fn inherent_benchmark_data() -> Result { let timestamp = sp_timestamp::InherentDataProvider::new(d.into()); futures::executor::block_on(timestamp.provide_inherent_data(&mut inherent_data)) - .map_err(|e| format!("creating inherent data: {:?}", e))?; + .map_err(|e| format!("creating inherent data: {e:?}"))?; Ok(inherent_data) } diff --git a/node/src/chain_spec/mod.rs b/node/src/chain_spec/mod.rs index 4d9849948..c893a6d07 100644 --- a/node/src/chain_spec/mod.rs +++ b/node/src/chain_spec/mod.rs @@ -207,7 +207,7 @@ where #[cfg(feature = "with-battery-station-runtime")] fn get_from_seed(seed: &str) -> ::Public { - TPublic::Pair::from_string(&format!("//{}", seed), None) + TPublic::Pair::from_string(&format!("//{seed}"), None) .expect("static values are valid; qed") .public() } diff --git a/node/src/command.rs b/node/src/command.rs index 2491aa822..4bffe2ff0 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -299,7 +299,7 @@ pub fn run() -> sc_cli::Result<()> { BlockId::Number(number) => match client.block_hash(number) { Ok(Some(hash)) => hash, Ok(None) => return Err("Unknown block".into()), - Err(e) => return Err(format!("Error reading block: {:?}", e).into()), + Err(e) => return Err(format!("Error reading block: {e:?}").into()), }, }; @@ -309,7 +309,7 @@ pub fn run() -> sc_cli::Result<()> { Ok(()) } Ok(None) => Err("Unknown block".into()), - Err(e) => Err(format!("Error reading block: {:?}", e).into()), + Err(e) => Err(format!("Error reading block: {e:?}").into()), } }) } @@ -414,7 +414,7 @@ pub fn run() -> sc_cli::Result<()> { &polkadot_cli, config.tokio_handle.clone(), ) - .map_err(|err| format!("Relay chain argument error: {}", err))?; + .map_err(|err| format!("Relay chain argument error: {err}"))?; cmd.run(config, polkadot_config) }) @@ -521,13 +521,13 @@ fn none_command(cli: Cli) -> sc_cli::Result<()> { let state_version = Cli::native_runtime_version(chain_spec).state_version(); let block: zeitgeist_runtime::Block = cumulus_client_cli::generate_genesis_block(&**chain_spec, state_version) - .map_err(|e| format!("{:?}", e))?; + .map_err(|e| format!("{e:?}"))?; let genesis_state = format!("0x{:?}", HexDisplay::from(&block.header().encode())); let tokio_handle = parachain_config.tokio_handle.clone(); let polkadot_config = SubstrateCli::create_configuration(&polkadot_cli, &polkadot_cli, tokio_handle) - .map_err(|err| format!("Relay chain argument error: {}", err))?; + .map_err(|err| format!("Relay chain argument error: {err}"))?; log::info!("Parachain id: {:?}", parachain_id); log::info!("Parachain Account: {}", parachain_account); diff --git a/primitives/src/math/fixed.rs b/primitives/src/math/fixed.rs index eff7434d5..ad527f4d5 100644 --- a/primitives/src/math/fixed.rs +++ b/primitives/src/math/fixed.rs @@ -303,7 +303,7 @@ impl> FromFixedToDecimal for N { Ordering::Equal => frac_part.to_string(), }; - let mut fixed_decimal: u128 = format!("{}{}", int_part, new_frac_part) + let mut fixed_decimal: u128 = format!("{int_part}{new_frac_part}") .parse::() .map_err(|_| "Failed to parse the fixed decimal representation into u128")?; if increment_int_part { diff --git a/zrml/court/src/lib.rs b/zrml/court/src/lib.rs index bfcc95600..48f16e4da 100644 --- a/zrml/court/src/lib.rs +++ b/zrml/court/src/lib.rs @@ -1068,8 +1068,7 @@ mod pallet { let (imbalance, missing) = T::Currency::slash(ai, slashable); debug_assert!( missing.is_zero(), - "Could not slash all of the amount for juror {:?}.", - ai + "Could not slash all of the amount for juror {ai:?}.", ); T::Currency::resolve_creating(&reward_pot, imbalance); }; @@ -2018,8 +2017,7 @@ mod pallet { total_imb.subsume(imb); debug_assert!( missing.is_zero(), - "Could not slash all of the amount for delegator {:?}.", - delegator + "Could not slash all of the amount for delegator {delegator:?}.", ); } total_imb @@ -2047,8 +2045,7 @@ mod pallet { total_incentives.subsume(imb); debug_assert!( missing.is_zero(), - "Could not slash all of the amount for juror {:?}.", - juror + "Could not slash all of the amount for juror {juror:?}.", ); let imb = slash_all_delegators(delegations.as_slice()); diff --git a/zrml/global-disputes/src/lib.rs b/zrml/global-disputes/src/lib.rs index 4ac07e4c0..46226525e 100644 --- a/zrml/global-disputes/src/lib.rs +++ b/zrml/global-disputes/src/lib.rs @@ -733,8 +733,8 @@ mod pallet { } else { log::error!( target: LOG_TARGET, - "There should be always at least one owner for a voting \ - outcome. This can also happen if reward is smaller than owners_len." + "There should be always at least one owner for a voting outcome. This can \ + also happen if reward is smaller than owners_len." ); debug_assert!(false); } diff --git a/zrml/neo-swaps/src/benchmarking.rs b/zrml/neo-swaps/src/benchmarking.rs index fde8b8c01..57686d785 100644 --- a/zrml/neo-swaps/src/benchmarking.rs +++ b/zrml/neo-swaps/src/benchmarking.rs @@ -268,7 +268,7 @@ where complete_set_amount, )); assert_ok!(NeoSwaps::::join( - RawOrigin::Signed(caller.clone()).into(), + RawOrigin::Signed(caller).into(), market_id, pool_shares_amount, vec![u128::MAX.saturated_into(); pool.assets().len()] @@ -334,7 +334,7 @@ mod benchmarks { let base_asset = Asset::Ztg; let asset_count = n.try_into().unwrap(); let market_id = create_market_and_deploy_pool::( - alice.clone(), + alice, base_asset, asset_count, _10.saturated_into(), @@ -366,7 +366,7 @@ mod benchmarks { let base_asset = Asset::Ztg; let asset_count = n.try_into().unwrap(); let market_id = create_market_and_deploy_pool::( - alice.clone(), + alice, base_asset, asset_count, _10.saturated_into(), @@ -398,7 +398,7 @@ mod benchmarks { let base_asset = Asset::Ztg; let asset_count = n.try_into().unwrap(); let market_id = create_market_and_deploy_pool::( - alice.clone(), + alice, base_asset, asset_count, _10.saturated_into(), @@ -436,7 +436,7 @@ mod benchmarks { let base_asset = Asset::Ztg; let asset_count = n.try_into().unwrap(); let market_id = create_market_and_deploy_pool::( - alice.clone(), + alice, base_asset, asset_count, _10.saturated_into(), @@ -460,12 +460,8 @@ mod benchmarks { #[benchmark] fn withdraw_fees() { let alice: T::AccountId = whitelisted_caller(); - let market_id = create_market_and_deploy_pool::( - alice.clone(), - Asset::Ztg, - 2u16, - _10.saturated_into(), - ); + let market_id = + create_market_and_deploy_pool::(alice, Asset::Ztg, 2u16, _10.saturated_into()); let helper = BenchmarkHelper::::new(); let bob = helper.accounts().next().unwrap(); helper.populate_liquidity_tree_until_full(market_id, bob.clone()); diff --git a/zrml/neo-swaps/src/mock.rs b/zrml/neo-swaps/src/mock.rs index a6d519fd8..ef3f02fe9 100644 --- a/zrml/neo-swaps/src/mock.rs +++ b/zrml/neo-swaps/src/mock.rs @@ -24,7 +24,7 @@ )] use crate as zrml_neo_swaps; -use crate::{consts::*, AssetOf, MarketIdOf}; +use crate::{consts::*, AssetOf, BalanceOf, MarketIdOf}; use core::marker::PhantomData; use frame_support::{ construct_runtime, ord_parameter_types, parameter_types, @@ -65,7 +65,6 @@ use zeitgeist_primitives::{ Hash, Index, MarketId, Moment, UncheckedExtrinsicTest, }, }; -use zrml_neo_swaps::BalanceOf; pub const ALICE: AccountIdTest = 0; #[allow(unused)] diff --git a/zrml/neo-swaps/src/tests/buy.rs b/zrml/neo-swaps/src/tests/buy.rs index a6babc2df..0ecbcd528 100644 --- a/zrml/neo-swaps/src/tests/buy.rs +++ b/zrml/neo-swaps/src/tests/buy.rs @@ -31,7 +31,7 @@ fn buy_works() { BASE_ASSET, MarketType::Categorical(2), liquidity, - spot_prices.clone(), + spot_prices, swap_fee, ); let pool = Pools::::get(market_id).unwrap(); diff --git a/zrml/neo-swaps/src/tests/liquidity_tree_interactions.rs b/zrml/neo-swaps/src/tests/liquidity_tree_interactions.rs index b2a0c6920..af46a1066 100644 --- a/zrml/neo-swaps/src/tests/liquidity_tree_interactions.rs +++ b/zrml/neo-swaps/src/tests/liquidity_tree_interactions.rs @@ -27,7 +27,7 @@ fn withdraw_fees_interacts_correctly_with_join() { BASE_ASSET, MarketType::Categorical(category_count), _10, - spot_prices.clone(), + spot_prices, CENT, ); diff --git a/zrml/neo-swaps/src/tests/mod.rs b/zrml/neo-swaps/src/tests/mod.rs index efbf95964..5ac6b59ad 100644 --- a/zrml/neo-swaps/src/tests/mod.rs +++ b/zrml/neo-swaps/src/tests/mod.rs @@ -92,7 +92,7 @@ fn create_market_and_deploy_pool( RuntimeOrigin::signed(ALICE), market_id, amount, - spot_prices.clone(), + spot_prices, swap_fee, )); market_id diff --git a/zrml/neo-swaps/src/tests/sell.rs b/zrml/neo-swaps/src/tests/sell.rs index ae6aa501f..97af34ad0 100644 --- a/zrml/neo-swaps/src/tests/sell.rs +++ b/zrml/neo-swaps/src/tests/sell.rs @@ -29,7 +29,7 @@ fn sell_works() { BASE_ASSET, MarketType::Scalar(0..=1), liquidity, - spot_prices.clone(), + spot_prices, swap_fee, ); let pool = Pools::::get(market_id).unwrap(); diff --git a/zrml/orderbook/src/benchmarks.rs b/zrml/orderbook/src/benchmarks.rs index b3075b678..0cc6d1486 100644 --- a/zrml/orderbook/src/benchmarks.rs +++ b/zrml/orderbook/src/benchmarks.rs @@ -52,7 +52,7 @@ fn order_common_parameters( let acc = generate_funded_account::(seed, maker_asset)?; let maker_amount: BalanceOf = BASE.saturating_mul(1_000).saturated_into(); let taker_amount: BalanceOf = BASE.saturating_mul(1_000).saturated_into(); - T::MarketCommons::push_market(market.clone()).unwrap(); + T::MarketCommons::push_market(market).unwrap(); let market_id: MarketIdOf = 0u32.into(); Ok((market_id, acc, maker_asset, maker_amount, taker_amount)) } diff --git a/zrml/orderbook/src/lib.rs b/zrml/orderbook/src/lib.rs index d6ab8b7c9..cdac555e7 100644 --- a/zrml/orderbook/src/lib.rs +++ b/zrml/orderbook/src/lib.rs @@ -443,7 +443,7 @@ mod pallet { Self::deposit_event(Event::OrderFilled { order_id, maker, - taker: taker.clone(), + taker, filled_maker_amount: taker_fill, filled_taker_amount: maker_fill, unfilled_maker_amount: order_data.maker_amount, diff --git a/zrml/orderbook/src/tests.rs b/zrml/orderbook/src/tests.rs index e5b46e42d..4cb833c9d 100644 --- a/zrml/orderbook/src/tests.rs +++ b/zrml/orderbook/src/tests.rs @@ -375,7 +375,7 @@ fn place_order_fails_if_market_base_asset_not_present() { ExtBuilder::default().build().execute_with(|| { let market_id = 0u128; let market = market_mock::(); - Markets::::insert(market_id, market.clone()); + Markets::::insert(market_id, market); let maker_asset = Asset::CategoricalOutcome(0, 1); let taker_asset = Asset::CategoricalOutcome(0, 2); diff --git a/zrml/parimutuel/src/benchmarking.rs b/zrml/parimutuel/src/benchmarking.rs index 2aec79bbb..b43a2697e 100644 --- a/zrml/parimutuel/src/benchmarking.rs +++ b/zrml/parimutuel/src/benchmarking.rs @@ -36,7 +36,7 @@ fn setup_market(market_type: MarketType) -> MarketIdOf { let mut market = market_mock::(market_creator); market.market_type = market_type; market.status = MarketStatus::Active; - T::MarketCommons::push_market(market.clone()).unwrap(); + T::MarketCommons::push_market(market).unwrap(); market_id } diff --git a/zrml/parimutuel/src/lib.rs b/zrml/parimutuel/src/lib.rs index 3bbcbd441..0c280f4a2 100644 --- a/zrml/parimutuel/src/lib.rs +++ b/zrml/parimutuel/src/lib.rs @@ -276,15 +276,16 @@ mod pallet { if payoff < winning_balance { log::debug!( target: LOG_TARGET, - "The payoff in base asset should be greater than or equal to the winning outcome \ - balance." + "The payoff in base asset should be greater than or equal to the winning \ + outcome balance." ); debug_assert!(false); } if pot_total < payoff { log::debug!( target: LOG_TARGET, - "The payoff in base asset should not exceed the total amount of the base asset!" + "The payoff in base asset should not exceed the total amount of the base \ + asset!" ); debug_assert!(false); } @@ -415,7 +416,7 @@ mod pallet { asset: winning_asset, withdrawn_asset_balance, base_asset_payoff, - sender: who.clone(), + sender: who, }); Ok(()) @@ -439,9 +440,9 @@ mod pallet { if refund_asset == winning_asset { log::debug!( target: LOG_TARGET, - "Since we were checking the total issuance of the winning asset to be zero, if \ - the refund balance is non-zero, then the winning asset can't be the refund \ - asset!" + "Since we were checking the total issuance of the winning asset to be zero, \ + if the refund balance is non-zero, then the winning asset can't be the \ + refund asset!" ); debug_assert!(false); } @@ -465,7 +466,7 @@ mod pallet { market_id, asset: refund_asset, refunded_balance: refund_balance, - sender: who.clone(), + sender: who, }); Ok(()) diff --git a/zrml/parimutuel/src/tests/buy.rs b/zrml/parimutuel/src/tests/buy.rs index 1ca6b13b5..20858cd97 100644 --- a/zrml/parimutuel/src/tests/buy.rs +++ b/zrml/parimutuel/src/tests/buy.rs @@ -90,7 +90,7 @@ fn buy_fails_if_asset_not_parimutuel_share() { let market_id = 0; let mut market = market_mock::(MARKET_CREATOR); market.status = MarketStatus::Active; - Markets::::insert(market_id, market.clone()); + Markets::::insert(market_id, market); let asset = Asset::CategoricalOutcome(market_id, 0u16); let amount = ::MinBetSize::get(); @@ -110,7 +110,7 @@ fn buy_fails_if_invalid_scoring_rule(scoring_rule: ScoringRule) { market.status = MarketStatus::Active; market.scoring_rule = scoring_rule; - Markets::::insert(market_id, market.clone()); + Markets::::insert(market_id, market); let asset = Asset::ParimutuelShare(market_id, 0u16); let amount = ::MinBetSize::get(); @@ -132,7 +132,7 @@ fn buy_fails_if_market_status_is_not_active(status: MarketStatus) { market.status = status; market.scoring_rule = ScoringRule::Parimutuel; - Markets::::insert(market_id, market.clone()); + Markets::::insert(market_id, market); let asset = Asset::ParimutuelShare(market_id, 0u16); let amount = ::MinBetSize::get(); @@ -189,7 +189,7 @@ fn buy_fails_if_below_minimum_bet_size() { let market_id = 0; let mut market = market_mock::(MARKET_CREATOR); market.status = MarketStatus::Active; - Markets::::insert(market_id, market.clone()); + Markets::::insert(market_id, market); let asset = Asset::ParimutuelShare(market_id, 0u16); let amount = ::MinBetSize::get() - 1; diff --git a/zrml/prediction-markets/src/benchmarks.rs b/zrml/prediction-markets/src/benchmarks.rs index f5cb54eb8..69b889938 100644 --- a/zrml/prediction-markets/src/benchmarks.rs +++ b/zrml/prediction-markets/src/benchmarks.rs @@ -1083,7 +1083,7 @@ benchmarks! { )?; Pallet::::dispute_early_close( - RawOrigin::Signed(caller.clone()).into(), + RawOrigin::Signed(caller).into(), market_id, )?; @@ -1106,7 +1106,6 @@ benchmarks! { )?; let market = zrml_market_commons::Pallet::::market(&market_id)?; - let market_creator = market.creator.clone(); for i in 0..o { MarketIdsPerCloseTimeFrame::::try_mutate( @@ -1125,7 +1124,7 @@ benchmarks! { ).unwrap(); } - let origin = RawOrigin::Signed(market_creator).into(); + let origin = RawOrigin::Signed(market.creator).into(); let call = Call::::schedule_early_close { market_id }; }: { call.dispatch_bypass_filter(origin)? } @@ -1143,10 +1142,8 @@ benchmarks! { Some(MarketDisputeMechanism::Court), )?; - let market_creator = caller.clone(); - Pallet::::schedule_early_close( - RawOrigin::Signed(market_creator.clone()).into(), + RawOrigin::Signed(caller.clone()).into(), market_id, )?; @@ -1176,7 +1173,7 @@ benchmarks! { ).unwrap(); } - let origin = RawOrigin::Signed(market_creator).into(); + let origin = RawOrigin::Signed(caller).into(); let call = Call::::dispute_early_close { market_id }; }: { call.dispatch_bypass_filter(origin)? } @@ -1194,8 +1191,6 @@ benchmarks! { Some(MarketDisputeMechanism::Court), )?; - let market_creator = caller.clone(); - let close_origin = T::CloseMarketEarlyOrigin::try_successful_origin().unwrap(); Pallet::::schedule_early_close( close_origin.clone(), @@ -1242,15 +1237,13 @@ benchmarks! { Some(MarketDisputeMechanism::Court), )?; - let market_creator = caller.clone(); - Pallet::::schedule_early_close( - RawOrigin::Signed(market_creator.clone()).into(), + RawOrigin::Signed(caller.clone()).into(), market_id, )?; Pallet::::dispute_early_close( - RawOrigin::Signed(caller.clone()).into(), + RawOrigin::Signed(caller).into(), market_id, )?; diff --git a/zrml/prediction-markets/src/lib.rs b/zrml/prediction-markets/src/lib.rs index fd5766af5..b47745494 100644 --- a/zrml/prediction-markets/src/lib.rs +++ b/zrml/prediction-markets/src/lib.rs @@ -130,10 +130,12 @@ mod pallet { debug_assert!(false, "{}", warning); return Ok(()); } - let missing = T::Currency::unreserve_named(&Self::reserve_id(), &bond.who, bond.value); + let missing = + T::Currency::unreserve_named(&Self::reserve_id(), &bond.who, bond.value); debug_assert!( missing.is_zero(), - "Could not unreserve all of the amount. reserve_id: {:?}, who: {:?}, value: {:?}.", + "Could not unreserve all of the amount. reserve_id: {:?}, who: {:?}, value: \ + {:?}.", &Self::reserve_id(), &bond.who, bond.value, @@ -204,8 +206,8 @@ mod pallet { ); debug_assert!( missing.is_zero(), - "Could not unreserve all of the amount. reserve_id: {:?}, \ - who: {:?}, amount: {:?}, missing: {:?}", + "Could not unreserve all of the amount. reserve_id: {:?}, who: {:?}, \ + amount: {:?}, missing: {:?}", Self::reserve_id(), &bond.who, unreserve_amount, @@ -890,7 +892,7 @@ mod pallet { ) -> DispatchResultWithPostInfo { let sender = ensure_signed(origin.clone())?; let current_block = >::block_number(); - let market_report = Report { at: current_block, by: sender.clone(), outcome }; + let market_report = Report { at: current_block, by: sender, outcome }; let market = >::market(&market_id)?; ensure!(market.report.is_none(), Error::::MarketAlreadyReported); Self::ensure_market_is_closed(&market)?; @@ -2112,7 +2114,7 @@ mod pallet { period, deadlines, metadata, - creation.clone(), + creation, market_type, dispute_mechanism, scoring_rule, diff --git a/zrml/prediction-markets/src/tests/schedule_early_close.rs b/zrml/prediction-markets/src/tests/schedule_early_close.rs index cb8d83145..e4bb6747d 100644 --- a/zrml/prediction-markets/src/tests/schedule_early_close.rs +++ b/zrml/prediction-markets/src/tests/schedule_early_close.rs @@ -54,7 +54,7 @@ fn schedule_early_close_emits_event() { System::assert_last_event( Event::MarketEarlyCloseScheduled { market_id, - new_period: new_period.clone(), + new_period, state: EarlyCloseState::ScheduledAsOther, } .into(), diff --git a/zrml/rikiddo/src/tests/pallet.rs b/zrml/rikiddo/src/tests/pallet.rs index c734068d2..73a136a5a 100644 --- a/zrml/rikiddo/src/tests/pallet.rs +++ b/zrml/rikiddo/src/tests/pallet.rs @@ -159,12 +159,9 @@ fn rikiddo_pallet_fee_return_correct_result() { let max_difference = max_balance_difference(frac_dec_places, 0.3); assert!( difference_abs <= max_difference, - "\nReference fee result (Balance): {}\nRikiddo pallet fee result (Balance): \ - {}\nDifference: {}\nMax_Allowed_Difference: {}", - fee_reference_balance, - fee_pallet_balance, - difference_abs, - max_difference, + "\nReference fee result (Balance): {fee_reference_balance}\nRikiddo pallet fee result \ + (Balance): {fee_pallet_balance}\nDifference: \ + {difference_abs}\nMax_Allowed_Difference: {max_difference}", ); // Now we check if the fee has changed, since enough volume data was collected @@ -193,12 +190,9 @@ fn rikiddo_pallet_cost_returns_correct_result() { let max_difference = max_balance_difference(frac_dec_places, 0.3); assert!( difference_abs <= max_difference, - "\nReference cost result (Balance): {}\nRikiddo pallet cost result (Balance): \ - {}\nDifference: {}\nMax_Allowed_Difference: {}", - cost_reference_balance, - cost_pallet_balance, - difference_abs, - max_difference, + "\nReference cost result (Balance): {cost_reference_balance}\nRikiddo pallet cost \ + result (Balance): {cost_pallet_balance}\nDifference: \ + {difference_abs}\nMax_Allowed_Difference: {difference_abs}", ); // The second part also compares the cost results, but uses the sigmoid fee. @@ -213,12 +207,9 @@ fn rikiddo_pallet_cost_returns_correct_result() { let max_difference_with_fee = max_balance_difference(frac_dec_places, 0.3); assert!( difference_abs_with_fee <= max_difference_with_fee, - "\nReference cost result (Balance): {}\nRikiddo pallet cost result (Balance): \ - {}\nDifference: {}\nMax_Allowed_Difference: {}", - cost_reference_balance_with_fee, - cost_pallet_balance_with_fee, - difference_abs_with_fee, - max_difference_with_fee, + "\nReference cost result (Balance): {cost_reference_balance_with_fee}\nRikiddo pallet \ + cost result (Balance): {cost_pallet_balance_with_fee}\nDifference: \ + {difference_abs_with_fee}\nMax_Allowed_Difference: {max_difference_with_fee}", ); }); } @@ -266,12 +257,9 @@ fn rikiddo_pallet_price_returns_correct_result() { let max_difference = max_balance_difference(frac_dec_places, 0.3); assert!( difference_abs <= max_difference, - "\nReference price result (Balance): {}\nRikiddo pallet price result (Balance): \ - {}\nDifference: {}\nMax_Allowed_Difference: {}", - price_reference_balance, - price_pallet_balance, - difference_abs, - max_difference, + "\nReference price result (Balance): {price_reference_balance}\nRikiddo pallet price \ + result (Balance): {price_pallet_balance}\nDifference: \ + {difference_abs}\nMax_Allowed_Difference: {max_difference}", ); // The second part also compares the price results, but uses the sigmoid fee. @@ -286,12 +274,9 @@ fn rikiddo_pallet_price_returns_correct_result() { let max_difference_fee = max_balance_difference(frac_dec_places, 0.3); assert!( difference_abs_fee <= max_difference_fee, - "\nReference price result (Balance): {}\nRikiddo pallet price result (Balance): \ - {}\nDifference: {}\nMax_Allowed_Difference: {}", - price_reference_balance_fee, - price_pallet_balance_fee, - difference_abs_fee, - max_difference_fee, + "\nReference price result (Balance): {price_reference_balance_fee}\nRikiddo pallet \ + price result (Balance): {price_pallet_balance_fee}\nDifference: \ + {difference_abs_fee}\nMax_Allowed_Difference: {max_difference_fee}", ); }); } @@ -321,12 +306,9 @@ fn rikiddo_pallet_all_prices_returns_correct_result() { asset_balances.len() as u128 * max_balance_difference(frac_dec_places, 0.3); assert!( difference_abs <= max_difference, - "\nReference all_prices result (Balance): {:?}\nRikiddo all_prices result (Balance): \ - {:?}\nDifference: {}\nMax_Allowed_Difference: {}", - all_prices_reference_balance, - all_prices_pallet_balance, - difference_abs, - max_difference, + "\nReference all_prices result (Balance): {all_prices_reference_balance:?}\nRikiddo \ + all_prices result (Balance): {all_prices_pallet_balance:?}\nDifference: \ + {difference_abs}\nMax_Allowed_Difference: {max_difference}", ); // The second part also compares the price results for all prices, but uses @@ -350,12 +332,10 @@ fn rikiddo_pallet_all_prices_returns_correct_result() { asset_balances.len() as u128 * max_balance_difference(frac_dec_places, 0.3); assert!( difference_abs_fee <= max_difference_fee, - "\nReference all_prices result (Balance): {:?}\nRikiddo pallet all_prices result \ - (Balance): {:?}\nDifference: {}\nMax_Allowed_Difference: {}", - all_prices_reference_balance_fee, - all_prices_pallet_balance_fee, - difference_abs_fee, - max_difference_fee, + "\nReference all_prices result (Balance): \ + {all_prices_reference_balance_fee:?}\nRikiddo pallet all_prices result (Balance): \ + {all_prices_pallet_balance_fee:?}\nDifference: \ + {difference_abs_fee}\nMax_Allowed_Difference: {max_difference_fee}", ); }); } diff --git a/zrml/swaps/src/benchmarks.rs b/zrml/swaps/src/benchmarks.rs index c7442491a..f6bd05b32 100644 --- a/zrml/swaps/src/benchmarks.rs +++ b/zrml/swaps/src/benchmarks.rs @@ -81,14 +81,9 @@ where { let (assets, asset_amount) = generate_assets::(&caller, asset_count, opt_asset_amount); let weights = opt_weights.unwrap_or_else(|| vec![T::MinWeight::get(); asset_count]); - let pool_id = Pallet::::create_pool( - caller.clone(), - assets.clone(), - Zero::zero(), - asset_amount, - weights, - ) - .unwrap(); + let pool_id = + Pallet::::create_pool(caller, assets.clone(), Zero::zero(), asset_amount, weights) + .unwrap(); if open { Pallet::::open_pool(pool_id).unwrap(); } diff --git a/zrml/swaps/src/lib.rs b/zrml/swaps/src/lib.rs index 33cee6776..2ab277b80 100644 --- a/zrml/swaps/src/lib.rs +++ b/zrml/swaps/src/lib.rs @@ -899,7 +899,7 @@ mod pallet { pool_account_id: &pool_account_id, pool_id, pool: &pool, - who: who.clone(), + who, }; swap_exact_amount::<_, _, T>(params) diff --git a/zrml/swaps/src/tests.rs b/zrml/swaps/src/tests.rs index b5e3e264e..ebd53962b 100644 --- a/zrml/swaps/src/tests.rs +++ b/zrml/swaps/src/tests.rs @@ -1623,7 +1623,7 @@ fn create_pool_fails_on_too_many_assets() { }); assert_noop!( - Swaps::create_pool(BOB, assets.clone(), 0, DEFAULT_LIQUIDITY, weights,), + Swaps::create_pool(BOB, assets, 0, DEFAULT_LIQUIDITY, weights), Error::::TooManyAssets ); });