Skip to content

Commit 55aef29

Browse files
committed
add test for root no rate limit
1 parent d819d09 commit 55aef29

File tree

1 file changed

+39
-0
lines changed
  • pallets/admin-utils/src/tests

1 file changed

+39
-0
lines changed

pallets/admin-utils/src/tests/mod.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,45 @@ fn test_sudo_set_weights_version_key_rate_limit() {
224224
});
225225
}
226226

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+
227266
#[test]
228267
fn test_sudo_set_weights_set_rate_limit() {
229268
new_test_ext().execute_with(|| {

0 commit comments

Comments
 (0)