git.delta.rocks / unique-network / refs/commits / e5f149d8dd11

difftreelog

test fix unit tests

Yaroslav Bolyukin2022-02-08parent: #b8e9f67.patch.diff
in: master

5 files changed

modifiedpallets/inflation/src/tests.rsdiffbeforeafterboth
--- a/pallets/inflation/src/tests.rs
+++ b/pallets/inflation/src/tests.rs
@@ -4,7 +4,7 @@
 
 use frame_support::{
 	assert_ok, parameter_types,
-	traits::{Currency, OnInitialize, Everything},
+	traits::{Currency, OnInitialize, Everything, ConstU32},
 };
 use frame_system::RawOrigin;
 use sp_core::H256;
@@ -81,6 +81,7 @@
 	type SystemWeightInfo = ();
 	type SS58Prefix = SS58Prefix;
 	type OnSetCode = ();
+	type MaxConsumers = ConstU32<16>;
 }
 
 parameter_types! {
modifiedpallets/scheduler/src/lib.rsdiffbeforeafterboth
675675
676 use frame_support::{676 use frame_support::{
677 ord_parameter_types, parameter_types, traits::Contains, weights::constants::RocksDbWeight,677 ord_parameter_types, parameter_types,
678 traits::{Contains, ConstU32, EnsureOneOf},
679 weights::constants::RocksDbWeight,
678 };680 };
679 use sp_core::H256;681 use sp_core::H256;
680 use sp_runtime::{682 use sp_runtime::{
681 Perbill,683 Perbill,
682 testing::Header,684 testing::Header,
683 traits::{BlakeTwo256, IdentityLookup},685 traits::{BlakeTwo256, IdentityLookup},
684 };686 };
685 use frame_system::{EnsureOneOf, EnsureRoot, EnsureSignedBy};687 use frame_system::{EnsureRoot, EnsureSignedBy};
686 use crate as scheduler;688 use crate as scheduler;
687689
688 mod logger {690 mod logger {
779 type SystemWeightInfo = ();781 type SystemWeightInfo = ();
780 type SS58Prefix = ();782 type SS58Prefix = ();
781 type OnSetCode = ();783 type OnSetCode = ();
784 type MaxConsumers = ConstU32<16>;
782 }785 }
783 impl logger::Config for Test {786 impl logger::Config for Test {
784 type Event = Event;787 type Event = Event;
797 type PalletsOrigin = OriginCaller;800 type PalletsOrigin = OriginCaller;
798 type Call = Call;801 type Call = Call;
799 type MaximumWeight = MaximumSchedulerWeight;802 type MaximumWeight = MaximumSchedulerWeight;
800 type ScheduleOrigin = EnsureOneOf<u64, EnsureRoot<u64>, EnsureSignedBy<One, u64>>;803 type ScheduleOrigin = EnsureOneOf<EnsureRoot<u64>, EnsureSignedBy<One, u64>>;
801 type MaxScheduledPerBlock = MaxScheduledPerBlock;804 type MaxScheduledPerBlock = MaxScheduledPerBlock;
802 type WeightInfo = ();805 type WeightInfo = ();
803 type SponsorshipHandler = ();806 type SponsorshipHandler = ();
modifiedpallets/unique/src/mock.rsdiffbeforeafterboth
--- a/pallets/unique/src/mock.rs
+++ b/pallets/unique/src/mock.rs
@@ -9,10 +9,11 @@
 };
 use pallet_transaction_payment::{CurrencyAdapter};
 use frame_system as system;
-use pallet_evm::AddressMapping;
+use pallet_evm::{AddressMapping, runner::stack::MaybeMirroredLog};
 use pallet_common::account::{EvmBackwardsAddressMapping, CrossAccountId};
-use codec::{Encode, Decode};
+use codec::{Encode, Decode, MaxEncodedLen};
 use scale_info::TypeInfo;
+use up_data_structs::ConstU32;
 
 type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
 type Block = frame_system::mocking::MockBlock<Test>;
@@ -63,6 +64,7 @@
 	type SystemWeightInfo = ();
 	type SS58Prefix = SS58Prefix;
 	type OnSetCode = ();
+	type MaxConsumers = ConstU32<16>;
 }
 
 parameter_types! {
@@ -125,7 +127,7 @@
 	}
 }
 
-#[derive(Encode, Decode, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, TypeInfo)]
+#[derive(Encode, Decode, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, TypeInfo, MaxEncodedLen)]
 pub struct TestCrossAccountId(u64, sp_core::H160);
 impl CrossAccountId<u64> for TestCrossAccountId {
 	fn as_sub(&self) -> &u64 {
@@ -161,7 +163,7 @@
 	fn submit_logs_transaction(
 		_source: H160,
 		_tx: pallet_ethereum::Transaction,
-		_logs: Vec<pallet_ethereum::Log>,
+		_logs: Vec<MaybeMirroredLog>,
 	) {
 	}
 }
modifiedpallets/unique/src/tests.rsdiffbeforeafterboth
--- a/pallets/unique/src/tests.rs
+++ b/pallets/unique/src/tests.rs
@@ -41,9 +41,9 @@
 	let origin1 = Origin::signed(owner);
 	assert_ok!(TemplateModule::create_collection(
 		origin1,
-		col_name1,
-		col_desc1,
-		token_prefix1,
+		col_name1.try_into().unwrap(),
+		col_desc1.try_into().unwrap(),
+		token_prefix1.try_into().unwrap(),
 		mode.clone()
 	));
 
@@ -131,9 +131,9 @@
 		assert_noop!(
 			TemplateModule::create_collection(
 				origin1,
-				col_name1,
-				col_desc1,
-				token_prefix1,
+				col_name1.try_into().unwrap(),
+				col_desc1.try_into().unwrap(),
+				token_prefix1.try_into().unwrap(),
 				CollectionMode::Fungible(MAX_DECIMAL_POINTS + 1)
 			),
 			Error::<Test>::CollectionDecimalPointLimitExceeded
@@ -2271,9 +2271,9 @@
 		assert_noop!(
 			TemplateModule::create_collection(
 				origin1,
-				col_name1,
-				col_desc1,
-				token_prefix1,
+				col_name1.try_into().unwrap(),
+				col_desc1.try_into().unwrap(),
+				token_prefix1.try_into().unwrap(),
 				CollectionMode::NFT
 			),
 			CommonError::<Test>::TotalCollectionsLimitExceeded
@@ -2372,7 +2372,7 @@
 		assert_ok!(TemplateModule::set_const_on_chain_schema(
 			origin1,
 			collection_id,
-			b"test const on chain schema".to_vec()
+			b"test const on chain schema".to_vec().try_into().unwrap()
 		));
 
 		assert_eq!(
@@ -2399,7 +2399,10 @@
 		assert_ok!(TemplateModule::set_variable_on_chain_schema(
 			origin1,
 			collection_id,
-			b"test variable on chain schema".to_vec()
+			b"test variable on chain schema"
+				.to_vec()
+				.try_into()
+				.unwrap()
 		));
 
 		assert_eq!(
@@ -2432,7 +2435,7 @@
 			origin1,
 			collection_id,
 			TokenId(1),
-			variable_data.clone()
+			variable_data.clone().try_into().unwrap()
 		));
 
 		assert_eq!(
@@ -2459,7 +2462,7 @@
 			origin1,
 			collection_id,
 			TokenId(1),
-			variable_data.clone()
+			variable_data.clone().try_into().unwrap()
 		));
 
 		assert_eq!(
@@ -2485,7 +2488,7 @@
 				origin1,
 				collection_id,
 				TokenId(0),
-				variable_data
+				variable_data.try_into().unwrap()
 			)
 			.map_err(|e| e.error),
 			<pallet_fungible::Error<Test>>::FungibleItemsDontHaveData
@@ -2494,54 +2497,6 @@
 }
 
 #[test]
-fn set_variable_meta_data_on_nft_token_fails_for_big_data() {
-	new_test_ext().execute_with(|| {
-		let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));
-
-		let origin1 = Origin::signed(1);
-
-		let data = default_nft_data();
-		create_test_item(collection_id, &data.into());
-
-		let variable_data = b"test set_variable_meta_data method, bigger than limits.".to_vec();
-		assert_noop!(
-			TemplateModule::set_variable_meta_data(
-				origin1,
-				collection_id,
-				TokenId(1),
-				variable_data
-			)
-			.map_err(|e| e.error),
-			CommonError::<Test>::TokenVariableDataLimitExceeded
-		);
-	});
-}
-
-#[test]
-fn set_variable_meta_data_on_re_fungible_token_fails_for_big_data() {
-	new_test_ext().execute_with(|| {
-		let collection_id = create_test_collection(&CollectionMode::ReFungible, CollectionId(1));
-
-		let origin1 = Origin::signed(1);
-
-		let data = default_re_fungible_data();
-		create_test_item(collection_id, &data.into());
-
-		let variable_data = b"test set_variable_meta_data method, bigger than limits.".to_vec();
-		assert_noop!(
-			TemplateModule::set_variable_meta_data(
-				origin1,
-				collection_id,
-				TokenId(1),
-				variable_data
-			)
-			.map_err(|e| e.error),
-			CommonError::<Test>::TokenVariableDataLimitExceeded
-		);
-	});
-}
-
-#[test]
 fn set_variable_meta_data_on_nft_with_item_owner_permission_flag() {
 	new_test_ext().execute_with(|| {
 		//default_limits();
@@ -2564,7 +2519,7 @@
 			origin1,
 			collection_id,
 			TokenId(1),
-			variable_data.clone()
+			variable_data.clone().try_into().unwrap()
 		));
 
 		assert_eq!(
@@ -2574,48 +2529,6 @@
 			variable_data
 		);
 	});
-}
-
-#[test]
-fn set_variable_meta_data_on_nft_with_item_owner_permission_flag_neg() {
-	new_test_ext().execute_with(|| {
-		let collection_id =
-			create_test_collection_for_owner(&CollectionMode::NFT, 1, CollectionId(1));
-
-		let origin1 = Origin::signed(1);
-
-		assert_ok!(TemplateModule::set_mint_permission(
-			origin1.clone(),
-			collection_id,
-			true
-		));
-		assert_ok!(TemplateModule::add_to_allow_list(
-			origin1.clone(),
-			collection_id,
-			account(1)
-		));
-
-		let data = default_nft_data();
-		create_test_item(collection_id, &data.into());
-
-		assert_ok!(TemplateModule::set_meta_update_permission_flag(
-			origin1.clone(),
-			collection_id,
-			MetaUpdatePermission::ItemOwner,
-		));
-
-		let variable_data = b"1234567890123".to_vec();
-		assert_noop!(
-			TemplateModule::set_variable_meta_data(
-				origin1,
-				collection_id,
-				TokenId(1),
-				variable_data.clone()
-			)
-			.map_err(|e| e.error),
-			CommonError::<Test>::TokenVariableDataLimitExceeded
-		);
-	})
 }
 
 #[test]
@@ -2712,7 +2625,7 @@
 			origin1,
 			collection_id,
 			TokenId(1),
-			variable_data.clone()
+			variable_data.clone().try_into().unwrap()
 		));
 
 		assert_eq!(
@@ -2761,7 +2674,7 @@
 				origin1,
 				collection_id,
 				TokenId(1),
-				variable_data.clone()
+				variable_data.try_into().unwrap()
 			)
 			.map_err(|e| e.error),
 			CommonError::<Test>::NoPermission
@@ -2819,7 +2732,7 @@
 				origin1.clone(),
 				collection_id,
 				TokenId(1),
-				variable_data.clone()
+				variable_data.try_into().unwrap()
 			)
 			.map_err(|e| e.error),
 			CommonError::<Test>::NoPermission
modifiedruntime/src/lib.rsdiffbeforeafterboth
--- a/runtime/src/lib.rs
+++ b/runtime/src/lib.rs
@@ -68,7 +68,6 @@
 use codec::{Encode, Decode};
 use pallet_evm::{Account as EVMAccount, FeeCalculator, GasWeightMapping, OnMethodCall};
 use fp_rpc::TransactionStatus;
-use sp_core::crypto::Public;
 use sp_runtime::{
 	traits::{BlockNumberProvider, Dispatchable, PostDispatchInfoOf},
 	transaction_validity::TransactionValidityError,