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

Remove unrequired check #14298

Merged
merged 2 commits into from
Jun 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions frame/asset-conversion/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

//! Asset Conversion pallet benchmarking.

#![cfg(feature = "runtime-benchmarks")]

gilescope marked this conversation as resolved.
Show resolved Hide resolved
use super::*;
use frame_benchmarking::{benchmarks, whitelisted_caller};
use frame_support::{
Expand Down
28 changes: 2 additions & 26 deletions frame/asset-conversion/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ pub mod pallet {
type WeightInfo: WeightInfo;

/// The benchmarks need a way to create asset ids from u32s.
#[cfg(any(test, feature = "runtime-benchmarks"))]
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper: BenchmarkHelper<Self::AssetId>;
}

Expand Down Expand Up @@ -349,30 +349,6 @@ pub mod pallet {
NonUniquePath,
}

#[pallet::hooks]
impl<T: Config> Hooks<T::BlockNumber> for Pallet<T> {
fn integrity_test() {
#[cfg(test)]
sp_io::TestExternalities::new_empty().execute_with(|| {
// ensure that the `AccountId` is set properly and doesn't generate the same
// pool account for different pool ids.
let native = T::MultiAssetIdConverter::get_native();
let asset_1 =
T::MultiAssetIdConverter::into_multiasset_id(&T::BenchmarkHelper::asset_id(1));
let asset_2 =
T::MultiAssetIdConverter::into_multiasset_id(&T::BenchmarkHelper::asset_id(2));
assert!(asset_1 != asset_2, "must return different assets for different ids.");
let pool_account_1 = Self::get_pool_account(&(native.clone(), asset_1));
let pool_account_2 = Self::get_pool_account(&(native, asset_2));
assert!(sp_std::mem::size_of::<T::AccountId>() >= sp_std::mem::size_of::<u128>());
assert!(
pool_account_1 != pool_account_2,
"AccountId should be set at least to u128"
);
});
}
}

/// Pallet's callable functions.
#[pallet::call]
impl<T: Config> Pallet<T> {
Expand Down Expand Up @@ -1107,8 +1083,8 @@ pub mod pallet {
Ok(())
}

#[cfg(any(test, feature = "runtime-benchmarks"))]
/// Returns the next pool asset id for benchmark purposes only.
#[cfg(any(test, feature = "runtime-benchmarks"))]
pub fn get_next_pool_asset_id() -> T::PoolAssetId {
NextPoolAssetId::<T>::get().unwrap_or(T::PoolAssetId::initial_value())
}
Expand Down
2 changes: 1 addition & 1 deletion frame/asset-conversion/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ impl Config for Test {
type MultiAssetId = NativeOrAssetId<u32>;
type MultiAssetIdConverter = NativeOrAssetIdConverter<u32>;

#[cfg(any(test, feature = "runtime-benchmarks"))]
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = ();
}

Expand Down
4 changes: 2 additions & 2 deletions frame/asset-conversion/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ pub trait MultiAssetIdConverter<MultiAssetId, AssetId> {
}

/// Benchmark Helper
#[cfg(any(test, feature = "runtime-benchmarks"))]
#[cfg(feature = "runtime-benchmarks")]
pub trait BenchmarkHelper<AssetId> {
/// Returns an asset id from a given integer.
fn asset_id(asset_id: u32) -> AssetId;
}

#[cfg(any(test, feature = "runtime-benchmarks"))]
#[cfg(feature = "runtime-benchmarks")]
impl<AssetId> BenchmarkHelper<AssetId> for ()
where
AssetId: From<u32>,
Expand Down