Skip to content

Commit

Permalink
Add test for staking too litle
Browse files Browse the repository at this point in the history
  • Loading branch information
gztensor committed Jan 15, 2025
1 parent adb344c commit 966a1a9
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions pallets/subtensor/src/tests/staking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1901,3 +1901,30 @@ fn test_mining_emission_distribution_validator_valiminer_miner() {
assert_eq!(miner_emission, total_emission / 4);
});
}

// Verify staking too low amount is impossible
#[test]
fn test_staking_too_little_fails() {
new_test_ext(1).execute_with(|| {
let hotkey_account_id = U256::from(533453);
let coldkey_account_id = U256::from(55453);
let amount = 10_000;

//add network
let netuid: u16 = add_dynamic_network(&hotkey_account_id, &coldkey_account_id);

// Give it some $$$ in his coldkey balance
SubtensorModule::add_balance_to_coldkey_account(&coldkey_account_id, amount);

// Coldkey / hotkey 0 decreases take to 5%. This should fail as the minimum take is 9%
assert_err!(
SubtensorModule::add_stake(
RuntimeOrigin::signed(coldkey_account_id),
hotkey_account_id,
netuid,
1
),
Error::<Test>::AmountTooLow
);
});
}

0 comments on commit 966a1a9

Please sign in to comment.