Skip to content

Commit 93c3f9c

Browse files
committed
expand test
1 parent ba7e34c commit 93c3f9c

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

pallets/subtensor/tests/weights.rs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4127,5 +4127,64 @@ fn test_commit_weights_rate_limit() {
41274127
netuid,
41284128
new_commit_hash
41294129
));
4130+
4131+
SubtensorModule::set_commit_reveal_weights_enabled(netuid, false);
4132+
let weights_keys: Vec<u16> = vec![0];
4133+
let weight_values: Vec<u16> = vec![1];
4134+
4135+
assert_err!(
4136+
SubtensorModule::set_weights(
4137+
RuntimeOrigin::signed(hotkey),
4138+
netuid,
4139+
weights_keys.clone(),
4140+
weight_values.clone(),
4141+
0
4142+
),
4143+
Error::<Test>::SettingWeightsTooFast
4144+
);
4145+
4146+
step_block(10);
4147+
4148+
assert_ok!(SubtensorModule::set_weights(
4149+
RuntimeOrigin::signed(hotkey),
4150+
netuid,
4151+
weights_keys.clone(),
4152+
weight_values.clone(),
4153+
0
4154+
));
4155+
4156+
assert_err!(
4157+
SubtensorModule::set_weights(
4158+
RuntimeOrigin::signed(hotkey),
4159+
netuid,
4160+
weights_keys.clone(),
4161+
weight_values.clone(),
4162+
0
4163+
),
4164+
Error::<Test>::SettingWeightsTooFast
4165+
);
4166+
4167+
step_block(5);
4168+
4169+
assert_err!(
4170+
SubtensorModule::set_weights(
4171+
RuntimeOrigin::signed(hotkey),
4172+
netuid,
4173+
weights_keys.clone(),
4174+
weight_values.clone(),
4175+
0
4176+
),
4177+
Error::<Test>::SettingWeightsTooFast
4178+
);
4179+
4180+
step_block(5);
4181+
4182+
assert_ok!(SubtensorModule::set_weights(
4183+
RuntimeOrigin::signed(hotkey),
4184+
netuid,
4185+
weights_keys.clone(),
4186+
weight_values.clone(),
4187+
0
4188+
));
41304189
});
41314190
}

0 commit comments

Comments
 (0)