git.delta.rocks / unique-network / refs/commits / 9b836649cc42

difftreelog

fix unit tests

Trubnikov Sergey2023-05-10parent: #008dfe4.patch.diff
in: master

6 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -12926,8 +12926,8 @@
  "frame-support",
  "frame-system",
  "pallet-balances",
+ "pallet-balances-adapter",
  "pallet-common",
- "pallet-configuration",
  "pallet-ethereum",
  "pallet-evm",
  "pallet-evm-coder-substrate",
@@ -12938,7 +12938,6 @@
  "pallet-timestamp",
  "pallet-transaction-payment",
  "pallet-unique",
- "pallet-xcm",
  "parity-scale-codec",
  "scale-info",
  "sp-core",
modifiedpallets/balances-adapter/src/common.rsdiffbeforeafterboth
--- a/pallets/balances-adapter/src/common.rs
+++ b/pallets/balances-adapter/src/common.rs
@@ -249,6 +249,7 @@
 
 	fn account_tokens(&self, account: <T>::CrossAccountId) -> Vec<TokenId> {
 		let balance = <T as Config>::Currency::total_balance(account.as_sub());
+		let balance: u128 = balance.into();
 		if balance != 0 {
 			vec![TokenId::default()]
 		} else {
modifiedpallets/balances-adapter/src/lib.rsdiffbeforeafterboth
--- a/pallets/balances-adapter/src/lib.rs
+++ b/pallets/balances-adapter/src/lib.rs
@@ -76,7 +76,7 @@
 			Balance = Self::CurrencyBalance,
 		>;
 		/// Balance type of chain
-		type CurrencyBalance: Into<U256> + TryFrom<U256> + PartialEq<u128> + From<u128> + Into<u128>;
+		type CurrencyBalance: Into<U256> + TryFrom<U256> + TryFrom<u128> + Into<u128>;
 
 		/// Decimals of balance
 		type Decimals: Get<u8>;
@@ -144,7 +144,9 @@
 				<T as Config>::Currency::transfer(
 					from.as_sub(),
 					to.as_sub(),
-					amount.into(),
+					amount
+						.try_into()
+						.map_err(|_| sp_runtime::ArithmeticError::Overflow)?,
 					ExistenceRequirement::KeepAlive,
 				)?;
 
modifiedruntime/common/config/pallets/mod.rsdiffbeforeafterboth
--- a/runtime/common/config/pallets/mod.rs
+++ b/runtime/common/config/pallets/mod.rs
@@ -54,10 +54,7 @@
 
 parameter_types! {
 	pub const CollectionCreationPrice: Balance = 2 * UNIQUE;
-	pub const Decimals: u8 = DECIMALS;
 	pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account_truncating();
-	pub Name: String = RUNTIME_NAME.to_string();
-	pub Symbol: String = TOKEN_SYMBOL.to_string();
 }
 
 impl pallet_common::Config for Runtime {
@@ -88,6 +85,12 @@
 impl pallet_nonfungible::Config for Runtime {
 	type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;
 }
+
+parameter_types! {
+	pub const Decimals: u8 = DECIMALS;
+	pub Name: String = RUNTIME_NAME.to_string();
+	pub Symbol: String = TOKEN_SYMBOL.to_string();
+}
 impl pallet_balances_adapter::Config for Runtime {
 	type Currency = Balances;
 	type CurrencyBalance = <Balances as Currency<Self::AccountId>>::Balance;
modifiedruntime/tests/Cargo.tomldiffbeforeafterboth
before · runtime/tests/Cargo.toml
1[package]2edition = "2021"3name = "tests"4version = "0.1.1"56[features]7default = ['refungible']89refungible = []1011[dependencies]12up-data-structs = { workspace = true }1314sp-core = { workspace = true }15sp-io = { workspace = true }16sp-runtime = { workspace = true }17sp-std = { workspace = true }1819frame-support = { workspace = true }20frame-system = { workspace = true }2122pallet-balances = { features = ["insecure_zero_ed"], workspace = true }23pallet-timestamp = { workspace = true }24pallet-transaction-payment = { workspace = true }2526pallet-ethereum = { workspace = true }27pallet-evm = { workspace = true }2829pallet-common = { workspace = true }30pallet-fungible = { workspace = true }31pallet-nonfungible = { workspace = true }32pallet-refungible = { workspace = true }33pallet-structure = { workspace = true }34pallet-unique = { workspace = true }3536pallet-evm-coder-substrate = { workspace = true }3738codec = { workspace = true }39scale-info = { workspace = true }4041evm-coder = { workspace = true }42up-sponsorship = { workspace = true }43xcm = { workspace = true }44pallet-xcm = { workspace = true }45pallet-configuration = { workspace = true }
modifiedruntime/tests/src/lib.rsdiffbeforeafterboth
--- a/runtime/tests/src/lib.rs
+++ b/runtime/tests/src/lib.rs
@@ -19,7 +19,7 @@
 use sp_core::{H160, H256, U256};
 use frame_support::{
 	parameter_types,
-	traits::{Everything, ConstU32, ConstU64},
+	traits::{Everything, ConstU32, ConstU64, Currency},
 	weights::IdentityFee,
 	pallet_prelude::Weight,
 };
@@ -266,6 +266,19 @@
 impl pallet_nonfungible::Config for Test {
 	type WeightInfo = ();
 }
+parameter_types! {
+	pub const Decimals: u8 = 18;
+	pub Name: String = "Test".to_string();
+	pub Symbol: String = "TST".to_string();
+}
+impl pallet_balances_adapter::Config for Test {
+	type Currency = Balances;
+	type CurrencyBalance = <Balances as Currency<Self::AccountId>>::Balance;
+	type Decimals = Decimals;
+	type Name = Name;
+	type Symbol = Symbol;
+	type WeightInfo = ();
+}
 
 parameter_types! {
 	// 0x6c4e9fe1ae37a41e93cee429e8e1881abdcbb54f