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
--- a/pallets/scheduler/src/lib.rs
+++ b/pallets/scheduler/src/lib.rs
@@ -674,7 +674,9 @@
 	use super::*;
 
 	use frame_support::{
-		ord_parameter_types, parameter_types, traits::Contains, weights::constants::RocksDbWeight,
+		ord_parameter_types, parameter_types,
+		traits::{Contains, ConstU32, EnsureOneOf},
+		weights::constants::RocksDbWeight,
 	};
 	use sp_core::H256;
 	use sp_runtime::{
@@ -682,7 +684,7 @@
 		testing::Header,
 		traits::{BlakeTwo256, IdentityLookup},
 	};
-	use frame_system::{EnsureOneOf, EnsureRoot, EnsureSignedBy};
+	use frame_system::{EnsureRoot, EnsureSignedBy};
 	use crate as scheduler;
 
 	mod logger {
@@ -779,6 +781,7 @@
 		type SystemWeightInfo = ();
 		type SS58Prefix = ();
 		type OnSetCode = ();
+		type MaxConsumers = ConstU32<16>;
 	}
 	impl logger::Config for Test {
 		type Event = Event;
@@ -797,7 +800,7 @@
 		type PalletsOrigin = OriginCaller;
 		type Call = Call;
 		type MaximumWeight = MaximumSchedulerWeight;
-		type ScheduleOrigin = EnsureOneOf<u64, EnsureRoot<u64>, EnsureSignedBy<One, u64>>;
+		type ScheduleOrigin = EnsureOneOf<EnsureRoot<u64>, EnsureSignedBy<One, u64>>;
 		type MaxScheduledPerBlock = MaxScheduledPerBlock;
 		type WeightInfo = ();
 		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
41 let origin1 = Origin::signed(owner);41 let origin1 = Origin::signed(owner);
42 assert_ok!(TemplateModule::create_collection(42 assert_ok!(TemplateModule::create_collection(
43 origin1,43 origin1,
44 col_name1,44 col_name1.try_into().unwrap(),
45 col_desc1,45 col_desc1.try_into().unwrap(),
46 token_prefix1,46 token_prefix1.try_into().unwrap(),
47 mode.clone()47 mode.clone()
48 ));48 ));
4949
131 assert_noop!(131 assert_noop!(
132 TemplateModule::create_collection(132 TemplateModule::create_collection(
133 origin1,133 origin1,
134 col_name1,134 col_name1.try_into().unwrap(),
135 col_desc1,135 col_desc1.try_into().unwrap(),
136 token_prefix1,136 token_prefix1.try_into().unwrap(),
137 CollectionMode::Fungible(MAX_DECIMAL_POINTS + 1)137 CollectionMode::Fungible(MAX_DECIMAL_POINTS + 1)
138 ),138 ),
139 Error::<Test>::CollectionDecimalPointLimitExceeded139 Error::<Test>::CollectionDecimalPointLimitExceeded
2271 assert_noop!(2271 assert_noop!(
2272 TemplateModule::create_collection(2272 TemplateModule::create_collection(
2273 origin1,2273 origin1,
2274 col_name1,2274 col_name1.try_into().unwrap(),
2275 col_desc1,2275 col_desc1.try_into().unwrap(),
2276 token_prefix1,2276 token_prefix1.try_into().unwrap(),
2277 CollectionMode::NFT2277 CollectionMode::NFT
2278 ),2278 ),
2279 CommonError::<Test>::TotalCollectionsLimitExceeded2279 CommonError::<Test>::TotalCollectionsLimitExceeded
2372 assert_ok!(TemplateModule::set_const_on_chain_schema(2372 assert_ok!(TemplateModule::set_const_on_chain_schema(
2373 origin1,2373 origin1,
2374 collection_id,2374 collection_id,
2375 b"test const on chain schema".to_vec()2375 b"test const on chain schema".to_vec().try_into().unwrap()
2376 ));2376 ));
23772377
2378 assert_eq!(2378 assert_eq!(
2401 collection_id,2401 collection_id,
2402 b"test variable on chain schema".to_vec()2402 b"test variable on chain schema"
2403 .to_vec()
2404 .try_into()
2405 .unwrap()
2403 ));2406 ));
24042407
2405 assert_eq!(2408 assert_eq!(
2432 origin1,2435 origin1,
2433 collection_id,2436 collection_id,
2434 TokenId(1),2437 TokenId(1),
2435 variable_data.clone()2438 variable_data.clone().try_into().unwrap()
2436 ));2439 ));
24372440
2438 assert_eq!(2441 assert_eq!(
2459 origin1,2462 origin1,
2460 collection_id,2463 collection_id,
2461 TokenId(1),2464 TokenId(1),
2462 variable_data.clone()2465 variable_data.clone().try_into().unwrap()
2463 ));2466 ));
24642467
2465 assert_eq!(2468 assert_eq!(
2485 origin1,2488 origin1,
2486 collection_id,2489 collection_id,
2487 TokenId(0),2490 TokenId(0),
2488 variable_data2491 variable_data.try_into().unwrap()
2489 )2492 )
2490 .map_err(|e| e.error),2493 .map_err(|e| e.error),
2491 <pallet_fungible::Error<Test>>::FungibleItemsDontHaveData2494 <pallet_fungible::Error<Test>>::FungibleItemsDontHaveData
2492 );2495 );
2493 });2496 });
2494}2497}
2495
2496#[test]
2497fn set_variable_meta_data_on_nft_token_fails_for_big_data() {
2498 new_test_ext().execute_with(|| {
2499 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));
2500
2501 let origin1 = Origin::signed(1);
2502
2503 let data = default_nft_data();
2504 create_test_item(collection_id, &data.into());
2505
2506 let variable_data = b"test set_variable_meta_data method, bigger than limits.".to_vec();
2507 assert_noop!(
2508 TemplateModule::set_variable_meta_data(
2509 origin1,
2510 collection_id,
2511 TokenId(1),
2512 variable_data
2513 )
2514 .map_err(|e| e.error),
2515 CommonError::<Test>::TokenVariableDataLimitExceeded
2516 );
2517 });
2518}
2519
2520#[test]
2521fn set_variable_meta_data_on_re_fungible_token_fails_for_big_data() {
2522 new_test_ext().execute_with(|| {
2523 let collection_id = create_test_collection(&CollectionMode::ReFungible, CollectionId(1));
2524
2525 let origin1 = Origin::signed(1);
2526
2527 let data = default_re_fungible_data();
2528 create_test_item(collection_id, &data.into());
2529
2530 let variable_data = b"test set_variable_meta_data method, bigger than limits.".to_vec();
2531 assert_noop!(
2532 TemplateModule::set_variable_meta_data(
2533 origin1,
2534 collection_id,
2535 TokenId(1),
2536 variable_data
2537 )
2538 .map_err(|e| e.error),
2539 CommonError::<Test>::TokenVariableDataLimitExceeded
2540 );
2541 });
2542}
25432498
2544#[test]2499#[test]
2545fn set_variable_meta_data_on_nft_with_item_owner_permission_flag() {2500fn set_variable_meta_data_on_nft_with_item_owner_permission_flag() {
2564 origin1,2519 origin1,
2565 collection_id,2520 collection_id,
2566 TokenId(1),2521 TokenId(1),
2567 variable_data.clone()2522 variable_data.clone().try_into().unwrap()
2568 ));2523 ));
25692524
2570 assert_eq!(2525 assert_eq!(
2576 });2531 });
2577}2532}
2578
2579#[test]
2580fn set_variable_meta_data_on_nft_with_item_owner_permission_flag_neg() {
2581 new_test_ext().execute_with(|| {
2582 let collection_id =
2583 create_test_collection_for_owner(&CollectionMode::NFT, 1, CollectionId(1));
2584
2585 let origin1 = Origin::signed(1);
2586
2587 assert_ok!(TemplateModule::set_mint_permission(
2588 origin1.clone(),
2589 collection_id,
2590 true
2591 ));
2592 assert_ok!(TemplateModule::add_to_allow_list(
2593 origin1.clone(),
2594 collection_id,
2595 account(1)
2596 ));
2597
2598 let data = default_nft_data();
2599 create_test_item(collection_id, &data.into());
2600
2601 assert_ok!(TemplateModule::set_meta_update_permission_flag(
2602 origin1.clone(),
2603 collection_id,
2604 MetaUpdatePermission::ItemOwner,
2605 ));
2606
2607 let variable_data = b"1234567890123".to_vec();
2608 assert_noop!(
2609 TemplateModule::set_variable_meta_data(
2610 origin1,
2611 collection_id,
2612 TokenId(1),
2613 variable_data.clone()
2614 )
2615 .map_err(|e| e.error),
2616 CommonError::<Test>::TokenVariableDataLimitExceeded
2617 );
2618 })
2619}
26202533
2621#[test]2534#[test]
2622fn collection_transfer_flag_works() {2535fn collection_transfer_flag_works() {
2712 origin1,2625 origin1,
2713 collection_id,2626 collection_id,
2714 TokenId(1),2627 TokenId(1),
2715 variable_data.clone()2628 variable_data.clone().try_into().unwrap()
2716 ));2629 ));
27172630
2718 assert_eq!(2631 assert_eq!(
2761 origin1,2674 origin1,
2762 collection_id,2675 collection_id,
2763 TokenId(1),2676 TokenId(1),
2764 variable_data.clone()2677 variable_data.try_into().unwrap()
2765 )2678 )
2766 .map_err(|e| e.error),2679 .map_err(|e| e.error),
2767 CommonError::<Test>::NoPermission2680 CommonError::<Test>::NoPermission
2819 origin1.clone(),2732 origin1.clone(),
2820 collection_id,2733 collection_id,
2821 TokenId(1),2734 TokenId(1),
2822 variable_data.clone()2735 variable_data.try_into().unwrap()
2823 )2736 )
2824 .map_err(|e| e.error),2737 .map_err(|e| e.error),
2825 CommonError::<Test>::NoPermission2738 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,