Skip to content

Commit

Permalink
Fix unit tests involving root_register for new func args
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayden Brewer committed Oct 30, 2023
1 parent c3975d0 commit 4e769aa
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
9 changes: 8 additions & 1 deletion pallets/subtensor/tests/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ fn test_root_register_network_exist() {
assert_ok!(SubtensorModule::root_register(
<<Test as Config>::RuntimeOrigin>::signed(coldkey_account_id),
hotkey_account_id,
11_796
));
});
}
Expand Down Expand Up @@ -124,6 +125,7 @@ fn test_root_register_stake_based_pruning_works() {
assert_ok!(SubtensorModule::root_register(
<<Test as Config>::RuntimeOrigin>::signed(cold),
hot,
11_796
));
// Check succesfull registration.
assert!(SubtensorModule::get_uid_for_net_and_hotkey(root_netuid, &hot).is_ok());
Expand All @@ -139,6 +141,7 @@ fn test_root_register_stake_based_pruning_works() {
assert_ok!(SubtensorModule::root_register(
<<Test as Config>::RuntimeOrigin>::signed(cold),
hot,
11_796
));
// Check succesfull registration.
assert!(SubtensorModule::get_uid_for_net_and_hotkey(root_netuid, &hot).is_ok());
Expand All @@ -153,6 +156,7 @@ fn test_root_register_stake_based_pruning_works() {
SubtensorModule::root_register(
<<Test as Config>::RuntimeOrigin>::signed(cold),
hot,
11_796
),
Err(Error::<Test>::StakeTooLowForRoot.into())
);
Expand Down Expand Up @@ -184,6 +188,7 @@ fn test_root_set_weights() {
assert_ok!(SubtensorModule::root_register(
<<Test as Config>::RuntimeOrigin>::signed(coldkey_account_id),
hotkey_account_id,
11_796
));
assert_ok!(SubtensorModule::add_stake(
<<Test as Config>::RuntimeOrigin>::signed(coldkey_account_id),
Expand Down Expand Up @@ -278,6 +283,7 @@ fn test_root_set_weights_out_of_order_netuids() {
assert_ok!(SubtensorModule::root_register(
<<Test as Config>::RuntimeOrigin>::signed(coldkey_account_id),
hotkey_account_id,
11_796
));
assert_ok!(SubtensorModule::add_stake(
<<Test as Config>::RuntimeOrigin>::signed(coldkey_account_id),
Expand Down Expand Up @@ -469,7 +475,8 @@ fn test_network_pruning() {
SubtensorModule::add_balance_to_coldkey_account(&cold, 1_000_000_000_000_000);
assert_ok!(SubtensorModule::root_register(
<<Test as Config>::RuntimeOrigin>::signed(cold),
hot
hot,
11_796
));
assert_ok!(SubtensorModule::add_stake(
<<Test as Config>::RuntimeOrigin>::signed(cold),
Expand Down
16 changes: 11 additions & 5 deletions pallets/subtensor/tests/senate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ fn test_senate_join_works() {

assert_ok!(SubtensorModule::root_register(
<<Test as Config>::RuntimeOrigin>::signed(coldkey_account_id),
hotkey_account_id
hotkey_account_id,
11_796
));
assert_eq!(Senate::is_member(&hotkey_account_id), true);
});
Expand Down Expand Up @@ -181,7 +182,8 @@ fn test_senate_vote_works() {

assert_ok!(SubtensorModule::root_register(
<<Test as Config>::RuntimeOrigin>::signed(coldkey_account_id),
hotkey_account_id
hotkey_account_id,
11_796
));
assert_eq!(Senate::is_member(&hotkey_account_id), true);

Expand Down Expand Up @@ -351,7 +353,8 @@ fn test_senate_leave_works() {

assert_ok!(SubtensorModule::root_register(
<<Test as Config>::RuntimeOrigin>::signed(coldkey_account_id),
hotkey_account_id
hotkey_account_id,
11_796
));
assert_eq!(Senate::is_member(&hotkey_account_id), true);
});
Expand Down Expand Up @@ -421,7 +424,8 @@ fn test_senate_leave_vote_removal() {

assert_ok!(SubtensorModule::root_register(
coldkey_origin.clone(),
hotkey_account_id
hotkey_account_id,
11_796
));
assert_eq!(Senate::is_member(&hotkey_account_id), true);

Expand Down Expand Up @@ -476,6 +480,7 @@ fn test_senate_leave_vote_removal() {
assert_ok!(SubtensorModule::root_register(
<<Test as Config>::RuntimeOrigin>::signed(cold),
hot,
11_796
));
// Check succesfull registration.
assert!(SubtensorModule::get_uid_for_net_and_hotkey(other_netuid, &hot).is_ok());
Expand Down Expand Up @@ -557,7 +562,8 @@ fn test_senate_not_leave_when_stake_removed() {

assert_ok!(SubtensorModule::root_register(
<<Test as Config>::RuntimeOrigin>::signed(coldkey_account_id),
hotkey_account_id
hotkey_account_id,
11_796
));
assert_eq!(Senate::is_member(&hotkey_account_id), true);

Expand Down

0 comments on commit 4e769aa

Please sign in to comment.