Add tests

This commit is contained in:
Sagar Dhawan 2019-04-10 15:26:23 -07:00 committed by Grimes
parent 7fd5e51168
commit c0808d01f8
1 changed files with 27 additions and 0 deletions

View File

@ -1910,4 +1910,31 @@ mod tests {
assert_eq!(vote_accounts.len(), 1);
}
#[test]
fn test_bank_0_votable() {
let (genesis_block, _) = GenesisBlock::new(500);
let bank = Arc::new(Bank::new(&genesis_block));
//set tick height to max
let max_tick_height = ((bank.slot + 1) * bank.ticks_per_slot - 1) as usize;
bank.tick_height.store(max_tick_height, Ordering::Relaxed);
assert!(bank.is_votable());
}
#[test]
fn test_genesis_vote_processing() {
let bootstrap_leader = Keypair::new();
let voting_keypair = Keypair::new();
let (mut genesis_block, _) =
GenesisBlock::new_with_leader(500, &bootstrap_leader.pubkey(), 100);
genesis_block.bootstrap_leader_vote_account_id = voting_keypair.pubkey();
let bank = Bank::new(&genesis_block);
let instructions = vote_instruction::vote(&voting_keypair.pubkey(), Vote::new(1));
let transaction = Transaction::new_signed_instructions(
&[&voting_keypair],
vec![instructions],
bank.last_blockhash(),
);
bank.process_transaction(&transaction).unwrap()
}
}