Skip to content

Commit 966a1a9

Browse files
committed
Add test for staking too litle
1 parent adb344c commit 966a1a9

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

pallets/subtensor/src/tests/staking.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1901,3 +1901,30 @@ fn test_mining_emission_distribution_validator_valiminer_miner() {
19011901
assert_eq!(miner_emission, total_emission / 4);
19021902
});
19031903
}
1904+
1905+
// Verify staking too low amount is impossible
1906+
#[test]
1907+
fn test_staking_too_little_fails() {
1908+
new_test_ext(1).execute_with(|| {
1909+
let hotkey_account_id = U256::from(533453);
1910+
let coldkey_account_id = U256::from(55453);
1911+
let amount = 10_000;
1912+
1913+
//add network
1914+
let netuid: u16 = add_dynamic_network(&hotkey_account_id, &coldkey_account_id);
1915+
1916+
// Give it some $$$ in his coldkey balance
1917+
SubtensorModule::add_balance_to_coldkey_account(&coldkey_account_id, amount);
1918+
1919+
// Coldkey / hotkey 0 decreases take to 5%. This should fail as the minimum take is 9%
1920+
assert_err!(
1921+
SubtensorModule::add_stake(
1922+
RuntimeOrigin::signed(coldkey_account_id),
1923+
hotkey_account_id,
1924+
netuid,
1925+
1
1926+
),
1927+
Error::<Test>::AmountTooLow
1928+
);
1929+
});
1930+
}

0 commit comments

Comments
 (0)