Add new error if stake delegation is below the minimum (#25709)
This commit is contained in:
parent
369ff0858d
commit
0b2d5291f8
|
@ -3886,7 +3886,10 @@ mod tests {
|
|||
];
|
||||
for (stake_delegation, expected_result) in &[
|
||||
(minimum_delegation, Ok(())),
|
||||
(minimum_delegation - 1, Err(StakeError::InsufficientStake)),
|
||||
(
|
||||
minimum_delegation - 1,
|
||||
Err(StakeError::InsufficientDelegation),
|
||||
),
|
||||
] {
|
||||
for stake_state in &[
|
||||
StakeState::Initialized(meta),
|
||||
|
@ -7029,7 +7032,7 @@ mod tests {
|
|||
fn test_behavior_withdrawal_then_redelegate_with_less_than_minimum_stake_delegation() {
|
||||
do_test_behavior_withdrawal_then_redelegate_with_less_than_minimum_stake_delegation(
|
||||
new_feature_set(),
|
||||
Err(StakeError::InsufficientStake.into()),
|
||||
Err(StakeError::InsufficientDelegation.into()),
|
||||
);
|
||||
}
|
||||
#[test]
|
||||
|
|
|
@ -1034,7 +1034,7 @@ fn validate_delegated_amount(
|
|||
|| feature_set.is_active(&feature_set::stake_raise_minimum_delegation_to_1_sol::id()))
|
||||
&& stake_amount < crate::get_minimum_delegation(feature_set)
|
||||
{
|
||||
return Err(StakeError::InsufficientStake.into());
|
||||
return Err(StakeError::InsufficientDelegation.into());
|
||||
}
|
||||
Ok(ValidatedDelegatedInfo { stake_amount })
|
||||
}
|
||||
|
|
|
@ -57,6 +57,9 @@ pub enum StakeError {
|
|||
"stake account has not been delinquent for the minimum epochs required for deactivation"
|
||||
)]
|
||||
MinimumDelinquentEpochsForDeactivationNotMet,
|
||||
|
||||
#[error("delegation amount is less than the minimum")]
|
||||
InsufficientDelegation,
|
||||
}
|
||||
|
||||
impl<E> DecodeError<E> for StakeError {
|
||||
|
|
Loading…
Reference in New Issue