Add new error if stake delegation is below the minimum (#25709)

This commit is contained in:
Brooks Prumo 2022-06-01 20:29:57 -05:00 committed by GitHub
parent 369ff0858d
commit 0b2d5291f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 3 deletions

View File

@ -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]

View File

@ -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 })
}

View File

@ -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 {