Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions pallets/admin-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1689,11 +1689,7 @@ pub mod pallet {
netuid: NetUid,
hotkey: <T as frame_system::Config>::AccountId,
) -> DispatchResult {
pallet_subtensor::Pallet::<T>::ensure_subnet_owner(origin.clone(), netuid)?;
pallet_subtensor::Pallet::<T>::set_subnet_owner_hotkey(netuid, &hotkey);

log::debug!("SubnetOwnerHotkeySet( netuid: {netuid:?}, hotkey: {hotkey:?} )");
Ok(())
pallet_subtensor::Pallet::<T>::do_set_sn_owner_hotkey(origin, netuid, &hotkey)
}

///
Expand Down
84 changes: 42 additions & 42 deletions pallets/admin-utils/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1745,48 +1745,48 @@ fn test_sets_a_lower_value_clears_small_nominations() {
});
}

#[test]
fn test_sudo_set_subnet_owner_hotkey() {
new_test_ext().execute_with(|| {
let netuid = NetUid::from(1);

let coldkey: U256 = U256::from(1);
let hotkey: U256 = U256::from(2);
let new_hotkey: U256 = U256::from(3);

let coldkey_origin = <<Test as Config>::RuntimeOrigin>::signed(coldkey);
let root = RuntimeOrigin::root();
let random_account = RuntimeOrigin::signed(U256::from(123456));

pallet_subtensor::SubnetOwner::<Test>::insert(netuid, coldkey);
pallet_subtensor::SubnetOwnerHotkey::<Test>::insert(netuid, hotkey);
assert_eq!(
pallet_subtensor::SubnetOwnerHotkey::<Test>::get(netuid),
hotkey
);

assert_ok!(AdminUtils::sudo_set_subnet_owner_hotkey(
coldkey_origin,
netuid,
new_hotkey
));

assert_eq!(
pallet_subtensor::SubnetOwnerHotkey::<Test>::get(netuid),
new_hotkey
);

assert_noop!(
AdminUtils::sudo_set_subnet_owner_hotkey(random_account, netuid, new_hotkey),
DispatchError::BadOrigin
);

assert_noop!(
AdminUtils::sudo_set_subnet_owner_hotkey(root, netuid, new_hotkey),
DispatchError::BadOrigin
);
});
}
// #[test]
// fn test_sudo_set_subnet_owner_hotkey() {
// new_test_ext().execute_with(|| {
// let netuid = NetUid::from(1);

// let coldkey: U256 = U256::from(1);
// let hotkey: U256 = U256::from(2);
// let new_hotkey: U256 = U256::from(3);

// let coldkey_origin = <<Test as Config>::RuntimeOrigin>::signed(coldkey);
// let root = RuntimeOrigin::root();
// let random_account = RuntimeOrigin::signed(U256::from(123456));

// pallet_subtensor::SubnetOwner::<Test>::insert(netuid, coldkey);
// pallet_subtensor::SubnetOwnerHotkey::<Test>::insert(netuid, hotkey);
// assert_eq!(
// pallet_subtensor::SubnetOwnerHotkey::<Test>::get(netuid),
// hotkey
// );

// assert_ok!(AdminUtils::sudo_set_subnet_owner_hotkey(
// coldkey_origin,
// netuid,
// new_hotkey
// ));

// assert_eq!(
// pallet_subtensor::SubnetOwnerHotkey::<Test>::get(netuid),
// new_hotkey
// );

// assert_noop!(
// AdminUtils::sudo_set_subnet_owner_hotkey(random_account, netuid, new_hotkey),
// DispatchError::BadOrigin
// );

// assert_noop!(
// AdminUtils::sudo_set_subnet_owner_hotkey(root, netuid, new_hotkey),
// DispatchError::BadOrigin
// );
// });
// }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// }

Trust VCS. If you'll ever need this code back, it will be in the repo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I commented it out instead of deleting it to make it more difficult for somebody to re-use the extrinsic index. Substrate doesn't like that.


// cargo test --package pallet-admin-utils --lib -- tests::test_sudo_set_ema_halving --exact --show-output
#[test]
Expand Down
Loading