diff --git a/pallets/subtensor/src/tests/children.rs b/pallets/subtensor/src/tests/children.rs index 529fc082d..60631bc33 100644 --- a/pallets/subtensor/src/tests/children.rs +++ b/pallets/subtensor/src/tests/children.rs @@ -2737,83 +2737,82 @@ fn test_childkey_set_weights_single_parent() { fn test_set_weights_no_parent() { // Verify that a regular key without a parent delegation is effected by the minimum stake requirements new_test_ext(1).execute_with(|| { - assert!(false); + let netuid: u16 = 1; + add_network(netuid, 1, 0); - // let netuid: u16 = 1; - // add_network(netuid, 1, 0); + let hotkey: U256 = U256::from(2); + let spare_hk: U256 = U256::from(3); - // let hotkey: U256 = U256::from(2); - // let spare_hk: U256 = U256::from(3); + let coldkey: U256 = U256::from(101); + let spare_ck = U256::from(102); - // let coldkey: U256 = U256::from(101); - // let spare_ck = U256::from(102); + let stake_to_give_child = 109_999; - // let stake_to_give_child = 109_999; + SubtensorModule::add_balance_to_coldkey_account(&coldkey, stake_to_give_child + 10); - // SubtensorModule::add_balance_to_coldkey_account(&coldkey, stake_to_give_child + 10); + // Is registered + register_ok_neuron(netuid, hotkey, coldkey, 1); + // Register a spare key + register_ok_neuron(netuid, spare_hk, spare_ck, 1); - // // Is registered - // register_ok_neuron(netuid, hotkey, coldkey, 1); - // // Register a spare key - // register_ok_neuron(netuid, spare_hk, spare_ck, 1); + SubtensorModule::increase_stake_for_hotkey_and_coldkey_on_subnet( + &hotkey, + &coldkey, + netuid, + stake_to_give_child, + ); - // SubtensorModule::increase_stake_on_coldkey_hotkey_account( - // &coldkey, - // &hotkey, - // stake_to_give_child, - // ); + SubtensorModule::set_weights_set_rate_limit(netuid, 0); - // SubtensorModule::set_weights_set_rate_limit(netuid, 0); + // Has stake and no parent + step_block(7200 + 1); - // // Has stake and no parent - // step_block(7200 + 1); + let uids: Vec = vec![1]; // Set weights on the other hotkey + let values: Vec = vec![u16::MAX]; // Use maximum value for u16 + let version_key = SubtensorModule::get_weights_version_key(netuid); - // let uids: Vec = vec![1]; // Set weights on the other hotkey - // let values: Vec = vec![u16::MAX]; // Use maximum value for u16 - // let version_key = SubtensorModule::get_weights_version_key(netuid); + // Set the min stake very high + SubtensorModule::set_stake_threshold(stake_to_give_child * 5); - // // Set the min stake very high - // SubtensorModule::set_stake_threshold(stake_to_give_child * 5); - - // // Check the key has less stake than required - // assert!( - // SubtensorModule::get_stake_for_hotkey_on_subnet(&hotkey, netuid) - // < SubtensorModule::get_stake_threshold() - // ); + // Check the key has less stake than required + assert!( + SubtensorModule::get_stake_for_hotkey_on_subnet(&hotkey, netuid) + < SubtensorModule::get_stake_threshold() + ); - // // Check the hotkey cannot set weights - // assert_noop!( - // SubtensorModule::set_weights( - // RuntimeOrigin::signed(hotkey), - // netuid, - // uids.clone(), - // values.clone(), - // version_key - // ), - // Error::::NotEnoughStakeToSetWeights - // ); + // Check the hotkey cannot set weights + assert_noop!( + SubtensorModule::set_weights( + RuntimeOrigin::signed(hotkey), + netuid, + uids.clone(), + values.clone(), + version_key + ), + Error::::NotEnoughStakeToSetWeights + ); - // assert!(!SubtensorModule::check_weights_min_stake(&hotkey, netuid)); + assert!(!SubtensorModule::check_weights_min_stake(&hotkey, netuid)); - // // Set a minimum stake to set weights - // SubtensorModule::set_stake_threshold(stake_to_give_child - 5); + // Set a minimum stake to set weights + SubtensorModule::set_stake_threshold(stake_to_give_child - 5); - // // Check if the stake for the hotkey is above - // assert!( - // SubtensorModule::get_stake_for_hotkey_on_subnet(&hotkey, netuid) - // >= SubtensorModule::get_stake_threshold() - // ); + // Check if the stake for the hotkey is above + assert!( + SubtensorModule::get_stake_for_hotkey_on_subnet(&hotkey, netuid) + >= SubtensorModule::get_stake_threshold() + ); - // // Check the hotkey can set weights - // assert_ok!(SubtensorModule::set_weights( - // RuntimeOrigin::signed(hotkey), - // netuid, - // uids, - // values, - // version_key - // )); + // Check the hotkey can set weights + assert_ok!(SubtensorModule::set_weights( + RuntimeOrigin::signed(hotkey), + netuid, + uids, + values, + version_key + )); - // assert!(SubtensorModule::check_weights_min_stake(&hotkey, netuid)); + assert!(SubtensorModule::check_weights_min_stake(&hotkey, netuid)); }); }