File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
pallets/admin-utils/src/tests Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -224,6 +224,45 @@ fn test_sudo_set_weights_version_key_rate_limit() {
224
224
} ) ;
225
225
}
226
226
227
+ #[ test]
228
+ fn test_sudo_set_weights_version_key_rate_limit_root ( ) {
229
+ // root should not be effected by rate limit
230
+ new_test_ext ( ) . execute_with ( || {
231
+ let netuid: u16 = 1 ;
232
+ let to_be_set: u64 = 10 ;
233
+
234
+ let sn_owner = U256 :: from ( 1 ) ;
235
+ add_network ( netuid, 10 ) ;
236
+ // Set the Subnet Owner
237
+ SubnetOwner :: < Test > :: insert ( netuid, sn_owner) ;
238
+
239
+ let rate_limit = WeightsVersionKeyRateLimit :: < Test > :: get ( ) ;
240
+ let tempo: u16 = Tempo :: < Test > :: get ( netuid) ;
241
+
242
+ let rate_limit_period = rate_limit * ( tempo as u64 ) ;
243
+ // Verify the rate limit is more than 0 blocks
244
+ assert ! ( rate_limit_period > 0 ) ;
245
+
246
+ assert_ok ! ( AdminUtils :: sudo_set_weights_version_key(
247
+ <<Test as Config >:: RuntimeOrigin >:: root( ) ,
248
+ netuid,
249
+ to_be_set
250
+ ) ) ;
251
+ assert_eq ! ( SubtensorModule :: get_weights_version_key( netuid) , to_be_set) ;
252
+
253
+ // Try transaction
254
+ assert_ok ! ( AdminUtils :: sudo_set_weights_version_key(
255
+ <<Test as Config >:: RuntimeOrigin >:: signed( sn_owner) ,
256
+ netuid,
257
+ to_be_set + 1
258
+ ) ) ;
259
+ assert_eq ! (
260
+ SubtensorModule :: get_weights_version_key( netuid) ,
261
+ to_be_set + 1
262
+ ) ;
263
+ } ) ;
264
+ }
265
+
227
266
#[ test]
228
267
fn test_sudo_set_weights_set_rate_limit ( ) {
229
268
new_test_ext ( ) . execute_with ( || {
You can’t perform that action at this time.
0 commit comments