Skip to content

Commit

Permalink
finalize
Browse files Browse the repository at this point in the history
  • Loading branch information
saraswatpuneet committed Nov 21, 2024
1 parent 1abd5e5 commit 01fd579
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pallets/capacity/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ impl<T: Config> Pallet<T> {
let account_balance =
T::Currency::reducible_balance(&staker, Preservation::Preserve, Fortitude::Polite);
let stakable_amount = account_balance.saturating_sub(T::MinimumTokenBalance::get());
if stakable_amount > proposed_amount {
if stakable_amount >= proposed_amount {
proposed_amount
} else {
Zero::zero()
Expand Down
8 changes: 6 additions & 2 deletions pallets/capacity/src/tests/stake_and_deposit_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,19 @@ fn stake_an_account_can_stake_to_multiple_targets() {
}

#[test]
fn stake_when_staking_amount_is_greater_than_free_balance_it_stakes_maximum() {
fn stake_when_staking_amount_is_greater_than_free_balance_it_stakes_zero() {
new_test_ext().execute_with(|| {
let target: MessageSourceId = 1;
register_provider(target, String::from("Foo"));
let account = 200;
// An amount greater than the free balance
let amount = 230;

assert_ok!(Capacity::stake(RuntimeOrigin::signed(account), target, amount));
assert_noop!(
Capacity::stake(RuntimeOrigin::signed(account), target, amount),
Error::<Test>::BalanceTooLowtoStake
);
assert_ok!(Capacity::stake(RuntimeOrigin::signed(account), target, 189));

// Check that StakingAccountLedger is updated.
assert_eq!(StakingAccountLedger::<Test>::get(account).unwrap().active, 189);
Expand Down

0 comments on commit 01fd579

Please sign in to comment.