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.rsdiffbeforeafterboth9};9};10use pallet_transaction_payment::{CurrencyAdapter};10use pallet_transaction_payment::{CurrencyAdapter};11use frame_system as system;11use frame_system as system;12use pallet_evm::AddressMapping;12use pallet_evm::{AddressMapping, runner::stack::MaybeMirroredLog};13use pallet_common::account::{EvmBackwardsAddressMapping, CrossAccountId};13use pallet_common::account::{EvmBackwardsAddressMapping, CrossAccountId};14use codec::{Encode, Decode};14use codec::{Encode, Decode, MaxEncodedLen};15use scale_info::TypeInfo;15use scale_info::TypeInfo;16use up_data_structs::ConstU32;161717type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;18type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;18type Block = frame_system::mocking::MockBlock<Test>;19type Block = frame_system::mocking::MockBlock<Test>;63 type SystemWeightInfo = ();64 type SystemWeightInfo = ();64 type SS58Prefix = SS58Prefix;65 type SS58Prefix = SS58Prefix;65 type OnSetCode = ();66 type OnSetCode = ();67 type MaxConsumers = ConstU32<16>;66}68}676968parameter_types! {70parameter_types! {125 }127 }126}128}127129128#[derive(Encode, Decode, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, TypeInfo)]130#[derive(Encode, Decode, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, TypeInfo, MaxEncodedLen)]129pub struct TestCrossAccountId(u64, sp_core::H160);131pub struct TestCrossAccountId(u64, sp_core::H160);130impl CrossAccountId<u64> for TestCrossAccountId {132impl CrossAccountId<u64> for TestCrossAccountId {131 fn as_sub(&self) -> &u64 {133 fn as_sub(&self) -> &u64 {161 fn submit_logs_transaction(163 fn submit_logs_transaction(162 _source: H160,164 _source: H160,163 _tx: pallet_ethereum::Transaction,165 _tx: pallet_ethereum::Transaction,164 _logs: Vec<pallet_ethereum::Log>,166 _logs: Vec<MaybeMirroredLog>,165 ) {167 ) {166 }168 }167}169}pallets/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
runtime/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,