difftreelog
test fix unit tests
in: master
5 files changed
pallets/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! {
pallets/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 = ();
pallets/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>,
) {
}
}
pallets/unique/src/tests.rsdiffbeforeafterboth41 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 ));4949131 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>::CollectionDecimalPointLimitExceeded2271 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::NFT2278 ),2278 ),2279 CommonError::<Test>::TotalCollectionsLimitExceeded2279 CommonError::<Test>::TotalCollectionsLimitExceeded2372 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 ));237723772378 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 ));240424072405 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 ));243724402438 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 ));246424672465 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>>::FungibleItemsDontHaveData2492 );2495 );2493 });2496 });2494}2497}24952496#[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));25002501 let origin1 = Origin::signed(1);25022503 let data = default_nft_data();2504 create_test_item(collection_id, &data.into());25052506 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_data2513 )2514 .map_err(|e| e.error),2515 CommonError::<Test>::TokenVariableDataLimitExceeded2516 );2517 });2518}25192520#[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));25242525 let origin1 = Origin::signed(1);25262527 let data = default_re_fungible_data();2528 create_test_item(collection_id, &data.into());25292530 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_data2537 )2538 .map_err(|e| e.error),2539 CommonError::<Test>::TokenVariableDataLimitExceeded2540 );2541 });2542}254324982544#[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 ));256925242570 assert_eq!(2525 assert_eq!(2576 });2531 });2577}2532}25782579#[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));25842585 let origin1 = Origin::signed(1);25862587 assert_ok!(TemplateModule::set_mint_permission(2588 origin1.clone(),2589 collection_id,2590 true2591 ));2592 assert_ok!(TemplateModule::add_to_allow_list(2593 origin1.clone(),2594 collection_id,2595 account(1)2596 ));25972598 let data = default_nft_data();2599 create_test_item(collection_id, &data.into());26002601 assert_ok!(TemplateModule::set_meta_update_permission_flag(2602 origin1.clone(),2603 collection_id,2604 MetaUpdatePermission::ItemOwner,2605 ));26062607 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>::TokenVariableDataLimitExceeded2617 );2618 })2619}262025332621#[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 ));271726302718 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>::NoPermission2819 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>::NoPermissionruntime/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,