diff --git a/pallets/subtensor/src/tests/staking.rs b/pallets/subtensor/src/tests/staking.rs index 3e5fe721f..4aaaed053 100644 --- a/pallets/subtensor/src/tests/staking.rs +++ b/pallets/subtensor/src/tests/staking.rs @@ -911,22 +911,51 @@ fn test_has_enough_stake_yes() { #[test] fn test_has_enough_stake_no() { new_test_ext(1).execute_with(|| { - assert!(false); + let hotkey_id = U256::from(4334); + let coldkey_id = U256::from(87989); + let intial_amount = 10_000; + let netuid = add_dynamic_network(&hotkey_id, &coldkey_id); + SubtensorModule::increase_stake_for_hotkey_and_coldkey_on_subnet(&hotkey_id, &coldkey_id, netuid, intial_amount); - // let hotkey_id = U256::from(4334); - // let coldkey_id = U256::from(87989); - // let intial_amount = 0; - // let netuid = 1; - // let tempo: u16 = 13; - // let start_nonce: u64 = 0; - // add_network(netuid, tempo, 0); - // register_ok_neuron(netuid, hotkey_id, coldkey_id, start_nonce); - // SubtensorModule::increase_stake_on_hotkey_account(&hotkey_id, intial_amount); - // assert!(!SubtensorModule::has_enough_stake( - // &coldkey_id, - // &hotkey_id, - // 5000 - // )); + assert_eq!( + SubtensorModule::get_total_stake_for_hotkey(&hotkey_id), + intial_amount + ); + assert_eq!( + SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet(&hotkey_id, &coldkey_id, netuid), + intial_amount + ); + assert!(!SubtensorModule::has_enough_stake_on_subnet( + &hotkey_id, + &coldkey_id, + netuid, + intial_amount * 2 + )); + }); +} + +#[test] +fn test_has_enough_stake_no_for_zero() { + new_test_ext(1).execute_with(|| { + let hotkey_id = U256::from(4334); + let coldkey_id = U256::from(87989); + let intial_amount = 0; + let netuid = add_dynamic_network(&hotkey_id, &coldkey_id); + + assert_eq!( + SubtensorModule::get_total_stake_for_hotkey(&hotkey_id), + intial_amount + ); + assert_eq!( + SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet(&hotkey_id, &coldkey_id, netuid), + intial_amount + ); + assert!(!SubtensorModule::has_enough_stake_on_subnet( + &hotkey_id, + &coldkey_id, + netuid, + 1_000 + )); }); }