stake-pool: Add reserve stake check on update pool balance (#1866)

This commit is contained in:
Jon Cinque 2021-06-04 23:08:32 +02:00 committed by GitHub
parent 454c75c711
commit ba99e44bff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 0 deletions

View File

@ -1429,6 +1429,7 @@ impl Processor {
}
stake_pool.check_mint(pool_mint_info)?;
stake_pool.check_authority_withdraw(withdraw_info.key, program_id, stake_pool_info.key)?;
stake_pool.check_reserve_stake(reserve_stake_info)?;
if stake_pool.manager_fee_account != *manager_fee_info.key {
return Err(StakePoolError::InvalidFeeAccount.into());
}

View File

@ -223,6 +223,32 @@ async fn fail_with_wrong_pool_fee_account() {
}
}
#[tokio::test]
async fn fail_with_wrong_reserve() {
let (mut banks_client, payer, recent_blockhash) = program_test().start().await;
let mut stake_pool_accounts = StakePoolAccounts::new();
stake_pool_accounts
.initialize_stake_pool(&mut banks_client, &payer, &recent_blockhash, 1)
.await
.unwrap();
let wrong_reserve_stake = Keypair::new();
stake_pool_accounts.reserve_stake = wrong_reserve_stake;
let error = stake_pool_accounts
.update_stake_pool_balance(&mut banks_client, &payer, &recent_blockhash)
.await
.unwrap()
.unwrap();
assert_eq!(
error,
TransactionError::InstructionError(
0,
InstructionError::Custom(StakePoolError::InvalidProgramAddress as u32),
)
);
}
#[tokio::test]
async fn test_update_stake_pool_balance_with_uninitialized_validator_list() {} // TODO