Skip to content

Commit

Permalink
Use set_balance() instead of write_balance() in benchmark (paritytech…
Browse files Browse the repository at this point in the history
…#14497)

* Use set_balance instead of write_balance in benchmark

* Another approach

* Use BalanceOf::<T>::max_value() / 1000

* use a regular div instead of a checked one
  • Loading branch information
jsidorenko authored and nathanwhit committed Jul 19, 2023
1 parent f5a23b0 commit a897bf2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions frame/asset-conversion/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ use frame_support::{
assert_ok,
storage::bounded_vec::BoundedVec,
traits::{
fungible::{Inspect as InspectFungible, Unbalanced},
fungible::{Inspect as InspectFungible, Mutate as MutateFungible, Unbalanced},
fungibles::{Create, Inspect, Mutate},
},
};
use frame_system::RawOrigin as SystemOrigin;
use sp_runtime::traits::{Bounded, StaticLookup};
use sp_std::prelude::*;
use sp_std::{ops::Div, prelude::*};

use crate::Pallet as AssetConversion;

Expand All @@ -55,7 +55,7 @@ where
let caller: T::AccountId = whitelisted_caller();
let caller_lookup = T::Lookup::unlookup(caller.clone());
if let Ok(asset_id) = T::MultiAssetIdConverter::try_convert(asset) {
assert_ok!(T::Currency::write_balance(&caller, BalanceOf::<T>::max_value()));
T::Currency::set_balance(&caller, BalanceOf::<T>::max_value().div(1000u32.into()));
assert_ok!(T::Assets::create(asset_id.clone(), caller.clone(), true, 1.into()));
assert_ok!(T::Assets::mint_into(asset_id, &caller, INITIAL_ASSET_BALANCE.into()));
}
Expand Down

0 comments on commit a897bf2

Please sign in to comment.