22
33use frame_support:: {
44 assert_ok, derive_impl, parameter_types,
5- traits:: { Everything , Hooks } ,
5+ traits:: { Everything , Hooks , PrivilegeCmp } ,
66 weights,
77} ;
88use frame_system as system;
9- use frame_system:: { limits, EnsureNever } ;
9+ use frame_system:: { limits, EnsureNever , EnsureRoot } ;
1010use sp_consensus_aura:: sr25519:: AuthorityId as AuraId ;
1111use sp_core:: U256 ;
1212use sp_core:: { ConstU64 , H256 } ;
1313use sp_runtime:: {
1414 traits:: { BlakeTwo256 , ConstU32 , IdentityLookup } ,
15- BuildStorage ,
15+ BuildStorage , Perbill ,
1616} ;
17+ use sp_std:: cmp:: Ordering ;
18+ use sp_weights:: Weight ;
1719
1820type Block = frame_system:: mocking:: MockBlock < Test > ;
1921
@@ -25,6 +27,7 @@ frame_support::construct_runtime!(
2527 Balances : pallet_balances,
2628 AdminUtils : pallet_admin_utils,
2729 SubtensorModule : pallet_subtensor:: { Pallet , Call , Storage , Event <T >, Error <T >} ,
30+ Scheduler : pallet_scheduler:: { Pallet , Call , Storage , Event <T >} ,
2831 }
2932) ;
3033
@@ -81,6 +84,7 @@ parameter_types! {
8184 pub const InitialMinDelegateTake : u16 = 5_898 ; // 9%;
8285 pub const InitialDefaultChildKeyTake : u16 = 0 ; // Allow 0 %
8386 pub const InitialMinChildKeyTake : u16 = 0 ; // Allow 0 %
87+ pub const InitialMaxChildKeyTake : u16 = 11_796 ; // 18 %;
8488 pub const InitialWeightsVersionKey : u16 = 0 ;
8589 pub const InitialServingRateLimit : u64 = 0 ; // No limit.
8690 pub const InitialTxRateLimit : u64 = 0 ; // Disable rate limit for testing
@@ -119,17 +123,20 @@ parameter_types! {
119123 pub const InitialLiquidAlphaOn : bool = false ; // Default value for LiquidAlphaOn
120124 pub const InitialHotkeyEmissionTempo : u64 = 1 ;
121125 pub const InitialNetworkMaxStake : u64 = u64 :: MAX ; // Maximum possible value for u64, this make the make stake infinity
126+ pub const InitialColdkeySwapScheduleDuration : u64 = 5 * 24 * 60 * 60 / 12 ; // 5 days
127+ pub const InitialDissolveNetworkScheduleDuration : u64 = 5 * 24 * 60 * 60 / 12 ; // 5 days
122128}
123129
124130impl pallet_subtensor:: Config for Test {
125131 type RuntimeEvent = RuntimeEvent ;
132+ type RuntimeCall = RuntimeCall ;
126133 type Currency = Balances ;
127134 type InitialIssuance = InitialIssuance ;
128135 type SudoRuntimeCall = TestRuntimeCall ;
129136 type CouncilOrigin = EnsureNever < AccountId > ;
130137 type SenateMembers = ( ) ;
131138 type TriumvirateInterface = ( ) ;
132-
139+ type Scheduler = Scheduler ;
133140 type InitialMinAllowedWeights = InitialMinAllowedWeights ;
134141 type InitialEmissionValue = InitialEmissionValue ;
135142 type InitialMaxWeightsLimit = InitialMaxWeightsLimit ;
@@ -153,6 +160,7 @@ impl pallet_subtensor::Config for Test {
153160 type InitialMinDelegateTake = InitialMinDelegateTake ;
154161 type InitialDefaultChildKeyTake = InitialDefaultChildKeyTake ;
155162 type InitialMinChildKeyTake = InitialMinChildKeyTake ;
163+ type InitialMaxChildKeyTake = InitialMaxChildKeyTake ;
156164 type InitialWeightsVersionKey = InitialWeightsVersionKey ;
157165 type InitialMaxDifficulty = InitialMaxDifficulty ;
158166 type InitialMinDifficulty = InitialMinDifficulty ;
@@ -179,6 +187,9 @@ impl pallet_subtensor::Config for Test {
179187 type LiquidAlphaOn = InitialLiquidAlphaOn ;
180188 type InitialHotkeyEmissionTempo = InitialHotkeyEmissionTempo ;
181189 type InitialNetworkMaxStake = InitialNetworkMaxStake ;
190+ type Preimages = ( ) ;
191+ type InitialColdkeySwapScheduleDuration = InitialColdkeySwapScheduleDuration ;
192+ type InitialDissolveNetworkScheduleDuration = InitialDissolveNetworkScheduleDuration ;
182193}
183194
184195#[ derive_impl( frame_system:: config_preludes:: TestDefaultConfig ) ]
@@ -224,6 +235,14 @@ impl pallet_balances::Config for Test {
224235 type RuntimeHoldReason = ( ) ;
225236}
226237
238+ pub struct OriginPrivilegeCmp ;
239+
240+ impl PrivilegeCmp < OriginCaller > for OriginPrivilegeCmp {
241+ fn cmp_privilege ( _left : & OriginCaller , _right : & OriginCaller ) -> Option < Ordering > {
242+ None
243+ }
244+ }
245+
227246impl pallet_admin_utils:: Config for Test {
228247 type RuntimeEvent = RuntimeEvent ;
229248 type AuthorityId = AuraId ;
@@ -233,6 +252,26 @@ impl pallet_admin_utils::Config for Test {
233252 type WeightInfo = ( ) ;
234253}
235254
255+ parameter_types ! {
256+ pub MaximumSchedulerWeight : Weight = Perbill :: from_percent( 80 ) *
257+ BlockWeights :: get( ) . max_block;
258+ pub const MaxScheduledPerBlock : u32 = 50 ;
259+ pub const NoPreimagePostponement : Option <u32 > = Some ( 10 ) ;
260+ }
261+
262+ impl pallet_scheduler:: Config for Test {
263+ type RuntimeOrigin = RuntimeOrigin ;
264+ type RuntimeEvent = RuntimeEvent ;
265+ type PalletsOrigin = OriginCaller ;
266+ type RuntimeCall = RuntimeCall ;
267+ type MaximumWeight = MaximumSchedulerWeight ;
268+ type ScheduleOrigin = EnsureRoot < AccountId > ;
269+ type MaxScheduledPerBlock = MaxScheduledPerBlock ;
270+ type WeightInfo = pallet_scheduler:: weights:: SubstrateWeight < Test > ;
271+ type OriginPrivilegeCmp = OriginPrivilegeCmp ;
272+ type Preimages = ( ) ;
273+ }
274+
236275// Build genesis storage according to the mock runtime.
237276pub fn new_test_ext ( ) -> sp_io:: TestExternalities {
238277 sp_tracing:: try_init_simple ( ) ;
0 commit comments