Skip to content

Commit

Permalink
Fix test_has_enough_stake_no
Browse files Browse the repository at this point in the history
  • Loading branch information
gztensor committed Jan 8, 2025
1 parent 0960565 commit 8f02483
Showing 1 changed file with 44 additions and 15 deletions.
59 changes: 44 additions & 15 deletions pallets/subtensor/src/tests/staking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
));
});
}

Expand Down

0 comments on commit 8f02483

Please sign in to comment.