Skip to content

Commit 5b38c64

Browse files
The where clause of the enum when contructing a mock runtime has been deprecated, so this clause was removed for all pallet mocks.Nonce and Block types have been added to the system::Config, and the Index, BlockNumber and Header types have been removed, so all pallet implementations for the Test runtime have been updated accordingly. FreezeIdentifier, MaxFreezes, RuntimeHoldReason and MaxHolds types have been added for the balances pallet, so the test runtimes for pallets that use the balances pallet have been added accordingly. The GenesisConfig is now generic over the runtime, so the test build_storage for all pallets have been updated accordingly, also this is now behind the BuildStorage trait so it has been imported where required. The UnknownAsset error of the mapped assets pallet has been updated to be Unknown, so updated some of the tests accordingly. The tokens BalanceConversion trait has been replaced by ConversionToAssetBalance, so updated the mapped assets test pallet accordingly.
1 parent a15119d commit 5b38c64

File tree

11 files changed

+104
-154
lines changed

11 files changed

+104
-154
lines changed

pallets/afloat/src/mock.rs

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use crate as pallet_afloat;
22
use frame_support::{
33
parameter_types,
4-
traits::{AsEnsureOriginWithArg, ConstU32, ConstU64, Currency},
4+
traits::{AsEnsureOriginWithArg, ConstU128, ConstU32, ConstU64, Currency},
55
};
66
use frame_system as system;
77
use sp_core::H256;
88
use sp_runtime::{
9-
testing::Header,
109
traits::{BlakeTwo256, IdentityLookup},
10+
BuildStorage,
1111
};
1212
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
1313
type Block = frame_system::mocking::MockBlock<Test>;
@@ -25,12 +25,9 @@ parameter_types! {
2525

2626
// Configure a mock runtime to test the pallet.
2727
frame_support::construct_runtime!(
28-
pub enum Test where
29-
Block = Block,
30-
NodeBlock = Block,
31-
UncheckedExtrinsic = UncheckedExtrinsic,
28+
pub enum Test
3229
{
33-
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
30+
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
3431
GatedMarketplace: pallet_gated_marketplace::{Pallet, Call, Storage, Event<T>},
3532
Uniques: pallet_uniques::{Pallet, Call, Storage, Event<T>},
3633
Fruniques: pallet_fruniques::{Pallet, Call, Storage, Event<T>},
@@ -49,13 +46,12 @@ impl system::Config for Test {
4946
type DbWeight = ();
5047
type RuntimeOrigin = RuntimeOrigin;
5148
type RuntimeCall = RuntimeCall;
52-
type Index = u64;
53-
type BlockNumber = u64;
49+
type Nonce = u64;
5450
type Hash = H256;
5551
type Hashing = BlakeTwo256;
5652
type AccountId = u64;
5753
type Lookup = IdentityLookup<Self::AccountId>;
58-
type Header = Header;
54+
type Block = Block;
5955
type RuntimeEvent = RuntimeEvent;
6056
type BlockHashCount = BlockHashCount;
6157
type Version = ();
@@ -157,21 +153,20 @@ impl pallet_uniques::Config for Test {
157153
type Locker = ();
158154
}
159155

160-
parameter_types! {
161-
pub const ExistentialDeposit: u64 = 1;
162-
pub const MaxReserves: u32 = 50;
163-
}
164-
165156
impl pallet_balances::Config for Test {
166-
type Balance = u64;
157+
type Balance = u128;
167158
type DustRemoval = ();
168159
type RuntimeEvent = RuntimeEvent;
169-
type ExistentialDeposit = ExistentialDeposit;
160+
type ExistentialDeposit = ConstU128<100>;
170161
type AccountStore = System;
171162
type WeightInfo = ();
172163
type MaxLocks = ();
173-
type MaxReserves = MaxReserves;
164+
type MaxReserves = ConstU32<50>;
174165
type ReserveIdentifier = [u8; 8];
166+
type FreezeIdentifier = ();
167+
type MaxFreezes = ();
168+
type RuntimeHoldReason = ();
169+
type MaxHolds = ();
175170
}
176171

177172
parameter_types! {
@@ -236,16 +231,14 @@ impl pallet_mapped_assets::Config for Test {
236231
type CallbackHandle = AssetsCallbackHandle;
237232
type Extra = ();
238233
type RemoveItemsLimit = ConstU32<5>;
239-
type MaxReserves = MaxReserves;
240-
type ReserveIdentifier = u32;
241234
type Rbac = RBAC;
242235
}
243236

244237
// Build genesis storage according to the mock runtime.
245238
pub fn new_test_ext() -> sp_io::TestExternalities {
246239
// TODO: get initial conf?
247240
let mut t: sp_io::TestExternalities =
248-
frame_system::GenesisConfig::default().build_storage::<Test>().unwrap().into();
241+
frame_system::GenesisConfig::<Test>::default().build_storage().unwrap().into();
249242
t.execute_with(|| {
250243
Balances::make_free_balance_be(&1, 100);
251244
Balances::make_free_balance_be(&2, 100);

pallets/bitcoin-vaults/src/mock.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,39 +8,40 @@ use frame_system::EnsureRoot;
88
use pallet_balances;
99
use sp_core::H256;
1010
//use sp_keystore::{testing::KeyStore, KeystoreExt, SyncCryptoStore};
11+
use sp_runtime::BuildStorage;
1112
use sp_runtime::{
12-
testing::{Header, TestXt},
13+
testing::TestXt,
1314
traits::{BlakeTwo256, Extrinsic as ExtrinsicT, IdentifyAccount, IdentityLookup, Verify},
1415
//RuntimeAppPublic,
1516
};
16-
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
1717
type Block = frame_system::mocking::MockBlock<Test>;
1818
//use sp_runtime::generic::SignedPayload;
1919
use sp_core::sr25519::Signature;
2020

2121
// Configure a mock runtime to test the pallet.
2222
frame_support::construct_runtime!(
23-
pub enum Test where
24-
Block = Block,
25-
NodeBlock = Block,
26-
UncheckedExtrinsic = UncheckedExtrinsic,
23+
pub enum Test
2724
{
28-
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
25+
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
2926
BitcoinVaults: pallet_bitcoin_vaults::{Pallet, Call, Storage, Event<T>, ValidateUnsigned},
3027
Balances: pallet_balances::{Pallet, Call, Storage, Event<T>},
3128
}
3229
);
3330

3431
impl pallet_balances::Config for Test {
35-
type MaxLocks = ();
36-
type MaxReserves = ();
37-
type ReserveIdentifier = [u8; 8];
3832
type Balance = u64;
39-
type RuntimeEvent = RuntimeEvent;
4033
type DustRemoval = ();
34+
type RuntimeEvent = RuntimeEvent;
4135
type ExistentialDeposit = ConstU64<1>;
4236
type AccountStore = System;
4337
type WeightInfo = ();
38+
type MaxLocks = ();
39+
type MaxReserves = ();
40+
type ReserveIdentifier = [u8; 8];
41+
type RuntimeHoldReason = ();
42+
type FreezeIdentifier = ();
43+
type MaxHolds = ();
44+
type MaxFreezes = ();
4445
}
4546

4647
parameter_types! {
@@ -106,14 +107,13 @@ impl frame_system::Config for Test {
106107
type BlockWeights = ();
107108
type BlockLength = ();
108109
type RuntimeOrigin = RuntimeOrigin;
109-
type Index = u64;
110-
type BlockNumber = u64;
111110
type Hash = H256;
112111
type RuntimeCall = RuntimeCall;
112+
type Nonce = u64;
113113
type Hashing = BlakeTwo256;
114114
type AccountId = sp_core::sr25519::Public;
115115
type Lookup = IdentityLookup<Self::AccountId>;
116-
type Header = Header;
116+
type Block = Block;
117117
type RuntimeEvent = RuntimeEvent;
118118
type BlockHashCount = ConstU64<250>;
119119
type DbWeight = ();
@@ -134,7 +134,7 @@ pub fn test_pub(n: u8) -> sp_core::sr25519::Public {
134134

135135
// Build genesis storage according to the mock runtime.
136136
pub fn new_test_ext() -> sp_io::TestExternalities {
137-
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
137+
let mut t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
138138
pallet_balances::GenesisConfig::<Test> {
139139
balances: vec![(test_pub(1), 10000), (test_pub(2), 1000), (test_pub(3), 1000)],
140140
}

pallets/confidential-docs/src/mock.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
11
use crate as pallet_confidential_docs;
2-
use frame_support::parameter_types;
2+
use frame_support::{construct_runtime, parameter_types};
33
use frame_system as system;
44
use frame_system::EnsureRoot;
55
use sp_core::H256;
66
use sp_runtime::{
7-
testing::Header,
87
traits::{BlakeTwo256, IdentityLookup},
8+
BuildStorage,
99
};
10-
11-
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
1210
type Block = frame_system::mocking::MockBlock<Test>;
1311

1412
// Configure a mock runtime to test the pallet.
15-
frame_support::construct_runtime!(
16-
pub enum Test where
17-
Block = Block,
18-
NodeBlock = Block,
19-
UncheckedExtrinsic = UncheckedExtrinsic,
13+
construct_runtime!(
14+
pub enum Test
2015
{
21-
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
16+
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
2217
ConfidentialDocs: pallet_confidential_docs::{Pallet, Call, Storage, Event<T>},
2318
}
2419
);
@@ -35,13 +30,12 @@ impl system::Config for Test {
3530
type DbWeight = ();
3631
type RuntimeOrigin = RuntimeOrigin;
3732
type RuntimeCall = RuntimeCall;
38-
type Index = u64;
39-
type BlockNumber = u64;
33+
type Nonce = u64;
4034
type Hash = H256;
4135
type Hashing = BlakeTwo256;
4236
type AccountId = u64;
4337
type Lookup = IdentityLookup<Self::AccountId>;
44-
type Header = Header;
38+
type Block = Block;
4539
type RuntimeEvent = RuntimeEvent;
4640
type BlockHashCount = BlockHashCount;
4741
type Version = ();
@@ -85,7 +79,7 @@ impl pallet_confidential_docs::Config for Test {
8579

8680
// Build genesis storage according to the mock runtime.
8781
pub fn new_test_ext() -> sp_io::TestExternalities {
88-
let storage = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
82+
let storage = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
8983
let mut ext: sp_io::TestExternalities = storage.into();
9084
ext.execute_with(|| System::set_block_number(1));
9185
ext

pallets/fruniques/src/mock.rs

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,18 @@ use crate as pallet_fruniques;
22
use frame_support::{construct_runtime, parameter_types, traits::AsEnsureOriginWithArg};
33
use frame_system::{EnsureRoot, EnsureSigned};
44
use pallet_balances;
5-
use sp_core::H256;
5+
use sp_core::{ConstU64, H256};
66
use sp_runtime::{
7-
testing::Header,
87
traits::{BlakeTwo256, IdentityLookup},
8+
BuildStorage,
99
};
1010

11-
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
1211
type Block = frame_system::mocking::MockBlock<Test>;
1312

1413
construct_runtime!(
15-
pub enum Test where
16-
Block = Block,
17-
NodeBlock = Block,
18-
UncheckedExtrinsic = UncheckedExtrinsic,
14+
pub enum Test
1915
{
20-
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
16+
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
2117
Uniques: pallet_uniques::{Pallet, Call, Storage, Event<T>},
2218
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
2319
Fruniques: pallet_fruniques::{Pallet, Call, Storage, Event<T>},
@@ -36,13 +32,12 @@ impl frame_system::Config for Test {
3632
type BlockLength = ();
3733
type RuntimeOrigin = RuntimeOrigin;
3834
type RuntimeCall = RuntimeCall;
39-
type Index = u64;
40-
type BlockNumber = u64;
35+
type Nonce = u64;
4136
type Hash = H256;
4237
type Hashing = BlakeTwo256;
4338
type AccountId = u64;
4439
type Lookup = IdentityLookup<Self::AccountId>;
45-
type Header = Header;
40+
type Block = Block;
4641
type RuntimeEvent = RuntimeEvent;
4742
type BlockHashCount = BlockHashCount;
4843
type DbWeight = ();
@@ -97,21 +92,20 @@ impl pallet_uniques::Config for Test {
9792
type Locker = ();
9893
}
9994

100-
parameter_types! {
101-
pub const ExistentialDeposit: u64 = 1;
102-
pub const MaxReserves: u32 = 50;
103-
}
104-
10595
impl pallet_balances::Config for Test {
10696
type Balance = u64;
10797
type DustRemoval = ();
10898
type RuntimeEvent = RuntimeEvent;
109-
type ExistentialDeposit = ExistentialDeposit;
99+
type ExistentialDeposit = ConstU64<1>;
110100
type AccountStore = System;
111101
type WeightInfo = ();
112102
type MaxLocks = ();
113-
type MaxReserves = MaxReserves;
103+
type MaxReserves = ();
114104
type ReserveIdentifier = [u8; 8];
105+
type RuntimeHoldReason = ();
106+
type FreezeIdentifier = ();
107+
type MaxHolds = ();
108+
type MaxFreezes = ();
115109
}
116110

117111
parameter_types! {
@@ -142,7 +136,7 @@ impl pallet_rbac::Config for Test {
142136

143137
pub fn new_test_ext() -> sp_io::TestExternalities {
144138
let balance_amount = 1_000_000 as u64;
145-
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
139+
let mut t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
146140
pallet_balances::GenesisConfig::<Test> {
147141
balances: vec![(1, balance_amount), (2, balance_amount), (3, balance_amount)],
148142
}

pallets/fruniques/src/tests.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
use crate::{mock::*, Error};
1+
use crate::{mock::*, types::ParentInfoCall, Error};
22
use codec::Encode;
33
use core::convert::TryFrom;
4-
5-
use crate::types::ParentInfoCall;
64
use frame_support::{assert_noop, assert_ok, BoundedVec};
5+
use sp_runtime::BuildStorage;
76
pub struct ExtBuilder;
87

98
// helper function to set BoundedVec
@@ -21,7 +20,7 @@ impl Default for ExtBuilder {
2120

2221
impl ExtBuilder {
2322
pub fn build(self) -> sp_io::TestExternalities {
24-
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
23+
let mut t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
2524
pallet_balances::GenesisConfig::<Test> {
2625
balances: vec![(1, 100), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)],
2726
}

pallets/fund-admin-records/src/mock.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,18 @@ use frame_support::parameter_types;
33
use frame_system as system;
44
use sp_core::H256;
55
use sp_runtime::{
6-
testing::Header,
76
traits::{BlakeTwo256, IdentityLookup},
7+
BuildStorage,
88
};
99

10-
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
1110
type Block = frame_system::mocking::MockBlock<Test>;
1211
use frame_system::EnsureRoot;
1312

1413
// Configure a mock runtime to test the pallet.
1514
frame_support::construct_runtime!(
16-
pub enum Test where
17-
Block = Block,
18-
NodeBlock = Block,
19-
UncheckedExtrinsic = UncheckedExtrinsic,
15+
pub enum Test
2016
{
21-
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
17+
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
2218
FundAdminRecords: pallet_fund_admin_records::{Pallet, Call, Storage, Event<T>},
2319
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},
2420
}
@@ -36,13 +32,12 @@ impl system::Config for Test {
3632
type DbWeight = ();
3733
type RuntimeOrigin = RuntimeOrigin;
3834
type RuntimeCall = RuntimeCall;
39-
type Index = u64;
40-
type BlockNumber = u64;
35+
type Nonce = u64;
4136
type Hash = H256;
4237
type Hashing = BlakeTwo256;
4338
type AccountId = u64;
4439
type Lookup = IdentityLookup<Self::AccountId>;
45-
type Header = Header;
40+
type Block = Block;
4641
type RuntimeEvent = RuntimeEvent;
4742
type BlockHashCount = BlockHashCount;
4843
type Version = ();
@@ -79,5 +74,5 @@ impl pallet_timestamp::Config for Test {
7974

8075
// Build genesis storage according to the mock runtime.
8176
pub fn new_test_ext() -> sp_io::TestExternalities {
82-
system::GenesisConfig::default().build_storage::<Test>().unwrap().into()
77+
system::GenesisConfig::<Test>::default().build_storage().unwrap().into()
8378
}

0 commit comments

Comments
 (0)