Add lockouts to vote program (#2944)
* Add lockouts to vote program * Rename MAX_VOTE_HISTORY TO MAX_LOCKOUT_HISTORY, change process_vote() to only pop votes after MAX_LOCKOUT_HISTORY + 1 votes have arrived * Correctly calculate serialized size of an Option, rename root_block to root_slot
This commit is contained in:
@ -131,15 +131,15 @@ mod tests {
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
for _ in 0..vote_program::MAX_VOTE_HISTORY {
|
||||
let vote = Vote::new(1);
|
||||
for i in 0..vote_program::MAX_LOCKOUT_HISTORY {
|
||||
let vote = Vote::new(i as u64);
|
||||
let vote_state =
|
||||
vote_program::vote_and_deserialize(&vote_id, &mut vote_account, vote.clone())
|
||||
.unwrap();
|
||||
assert_eq!(vote_state.credits(), 0);
|
||||
}
|
||||
|
||||
let vote = Vote::new(1);
|
||||
let vote = Vote::new(vote_program::MAX_LOCKOUT_HISTORY as u64 + 1);
|
||||
let vote_state =
|
||||
vote_program::vote_and_deserialize(&vote_id, &mut vote_account, vote.clone()).unwrap();
|
||||
assert_eq!(vote_state.credits(), 1);
|
||||
|
@ -86,11 +86,13 @@ fn test_redeem_vote_credits_via_bank() {
|
||||
.unwrap();
|
||||
|
||||
// The validator submits votes to accumulate credits.
|
||||
for _ in 0..vote_program::MAX_VOTE_HISTORY {
|
||||
let vote_state = rewards_bank.submit_vote(&vote_keypair, 1).unwrap();
|
||||
for i in 0..vote_program::MAX_LOCKOUT_HISTORY {
|
||||
let vote_state = rewards_bank.submit_vote(&vote_keypair, i as u64).unwrap();
|
||||
assert_eq!(vote_state.credits(), 0);
|
||||
}
|
||||
let vote_state = rewards_bank.submit_vote(&vote_keypair, 1).unwrap();
|
||||
let vote_state = rewards_bank
|
||||
.submit_vote(&vote_keypair, vote_program::MAX_LOCKOUT_HISTORY as u64 + 1)
|
||||
.unwrap();
|
||||
assert_eq!(vote_state.credits(), 1);
|
||||
|
||||
// TODO: Add VoteInstruction::RegisterStakerId so that we don't need to point the "to"
|
||||
|
Reference in New Issue
Block a user