From c0808d01f860697b93fd68ee61ab5bebbde122ce Mon Sep 17 00:00:00 2001 From: Sagar Dhawan Date: Wed, 10 Apr 2019 15:26:23 -0700 Subject: [PATCH] Add tests --- runtime/src/bank.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 784ffdeee1..bafd218f9b 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -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() + } + }