Repository: paritytech/substrate
File: frame/asset-conversion/src/lib.rs (Rust)

Code before:
		ProvidedMinimumNotSufficientForSwap,
		/// Provided maximum amount is not sufficient for swap.
		ProvidedMaximumNotSufficientForSwap,
		/// Only pools with native on one side are valid.
		PoolMustContainNativeCurrency,
		/// The provided path must consists of 2 assets at least.
		InvalidPath,
		/// It was not possible to calculate path data.
		PathError,
		/// The provided path must consists of unique assets.
		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, "unfortunatly decoded to be the same asset.");
				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> {
		/// Creates an empty liquidity pool and an associated new `lp_token` asset
		/// (the id of which is returned in the `Event::PoolCreated` event).
		///
		/// Once a pool is created, someone may [`Pallet::add_liquidity`] to it.
		#[pallet::call_index(0)]
		#[pallet::weight(T::WeightInfo::create_pool())]
		pub fn create_pool(
			origin: OriginFor<T>,
			asset1: T::MultiAssetId,
			asset2: T::MultiAssetId,
		) -> DispatchResult {

Review comment (suggestion):
```suggestion
				assert!(asset_1 != asset_2, "must return different assets for different ids.");
```

Code after:
		ProvidedMinimumNotSufficientForSwap,
		/// Provided maximum amount is not sufficient for swap.
		ProvidedMaximumNotSufficientForSwap,
		/// Only pools with native on one side are valid.
		PoolMustContainNativeCurrency,
		/// The provided path must consists of 2 assets at least.
		InvalidPath,
		/// It was not possible to calculate path data.
		PathError,
		/// The provided path must consists of unique assets.
		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> {
		/// Creates an empty liquidity pool and an associated new `lp_token` asset
		/// (the id of which is returned in the `Event::PoolCreated` event).
		///
		/// Once a pool is created, someone may [`Pallet::add_liquidity`] to it.
		#[pallet::call_index(0)]
		#[pallet::weight(T::WeightInfo::create_pool())]
		pub fn create_pool(
			origin: OriginFor<T>,
			asset1: T::MultiAssetId,
			asset2: T::MultiAssetId,
		) -> DispatchResult {