Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Use set_balance() instead of write_balance() in benchmark (#14497)
Browse files Browse the repository at this point in the history
* 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 Jul 5, 2023
1 parent 67b14ad commit 8c823ec
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 8c823ec

Please sign in to comment.