Skip to content

Commit

Permalink
expand test
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnReedV committed Oct 31, 2024
1 parent ba7e34c commit 93c3f9c
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions pallets/subtensor/tests/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4127,5 +4127,64 @@ fn test_commit_weights_rate_limit() {
netuid,
new_commit_hash
));

SubtensorModule::set_commit_reveal_weights_enabled(netuid, false);
let weights_keys: Vec<u16> = vec![0];
let weight_values: Vec<u16> = vec![1];

assert_err!(
SubtensorModule::set_weights(
RuntimeOrigin::signed(hotkey),
netuid,
weights_keys.clone(),
weight_values.clone(),
0
),
Error::<Test>::SettingWeightsTooFast
);

step_block(10);

assert_ok!(SubtensorModule::set_weights(
RuntimeOrigin::signed(hotkey),
netuid,
weights_keys.clone(),
weight_values.clone(),
0
));

assert_err!(
SubtensorModule::set_weights(
RuntimeOrigin::signed(hotkey),
netuid,
weights_keys.clone(),
weight_values.clone(),
0
),
Error::<Test>::SettingWeightsTooFast
);

step_block(5);

assert_err!(
SubtensorModule::set_weights(
RuntimeOrigin::signed(hotkey),
netuid,
weights_keys.clone(),
weight_values.clone(),
0
),
Error::<Test>::SettingWeightsTooFast
);

step_block(5);

assert_ok!(SubtensorModule::set_weights(
RuntimeOrigin::signed(hotkey),
netuid,
weights_keys.clone(),
weight_values.clone(),
0
));
});
}

0 comments on commit 93c3f9c

Please sign in to comment.