| 
									
										
										
										
											2021-04-07 01:47:15 -07:00
										 |  |  | use solana_bpf_rust_sysvar::process_instruction;
 | 
					
						
							|  |  |  | use solana_program_test::*;
 | 
					
						
							| 
									
										
										
										
											2021-08-02 10:45:55 -06:00
										 |  |  | use solana_sdk::sysvar::recent_blockhashes;
 | 
					
						
							| 
									
										
										
										
											2021-04-07 01:47:15 -07:00
										 |  |  | use solana_sdk::{
 | 
					
						
							|  |  |  |     instruction::{AccountMeta, Instruction},
 | 
					
						
							|  |  |  |     pubkey::Pubkey,
 | 
					
						
							|  |  |  |     signature::Signer,
 | 
					
						
							| 
									
										
										
										
											2021-07-29 10:48:14 -07:00
										 |  |  |     sysvar::{clock, epoch_schedule, instructions, rent, slot_hashes, slot_history, stake_history},
 | 
					
						
							| 
									
										
										
										
											2021-04-07 01:47:15 -07:00
										 |  |  |     transaction::Transaction,
 | 
					
						
							|  |  |  | };
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #[tokio::test]
 | 
					
						
							| 
									
										
										
										
											2021-06-01 15:33:17 -07:00
										 |  |  | async fn test_sysvars() {
 | 
					
						
							| 
									
										
										
										
											2021-04-07 01:47:15 -07:00
										 |  |  |     let program_id = Pubkey::new_unique();
 | 
					
						
							|  |  |  |     let program_test = ProgramTest::new(
 | 
					
						
							|  |  |  |         "solana_bpf_rust_sysvar",
 | 
					
						
							|  |  |  |         program_id,
 | 
					
						
							|  |  |  |         processor!(process_instruction),
 | 
					
						
							|  |  |  |     );
 | 
					
						
							|  |  |  |     let (mut banks_client, payer, recent_blockhash) = program_test.start().await;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     let mut transaction = Transaction::new_with_payer(
 | 
					
						
							|  |  |  |         &[Instruction::new_with_bincode(
 | 
					
						
							|  |  |  |             program_id,
 | 
					
						
							|  |  |  |             &(),
 | 
					
						
							|  |  |  |             vec![
 | 
					
						
							|  |  |  |                 AccountMeta::new(payer.pubkey(), true),
 | 
					
						
							|  |  |  |                 AccountMeta::new(Pubkey::new_unique(), false),
 | 
					
						
							|  |  |  |                 AccountMeta::new_readonly(clock::id(), false),
 | 
					
						
							|  |  |  |                 AccountMeta::new_readonly(epoch_schedule::id(), false),
 | 
					
						
							|  |  |  |                 AccountMeta::new_readonly(instructions::id(), false),
 | 
					
						
							| 
									
										
										
										
											2021-07-29 10:48:14 -07:00
										 |  |  |                 #[allow(deprecated)]
 | 
					
						
							| 
									
										
										
										
											2021-04-07 01:47:15 -07:00
										 |  |  |                 AccountMeta::new_readonly(recent_blockhashes::id(), false),
 | 
					
						
							|  |  |  |                 AccountMeta::new_readonly(rent::id(), false),
 | 
					
						
							|  |  |  |                 AccountMeta::new_readonly(slot_hashes::id(), false),
 | 
					
						
							|  |  |  |                 AccountMeta::new_readonly(slot_history::id(), false),
 | 
					
						
							|  |  |  |                 AccountMeta::new_readonly(stake_history::id(), false),
 | 
					
						
							|  |  |  |             ],
 | 
					
						
							|  |  |  |         )],
 | 
					
						
							|  |  |  |         Some(&payer.pubkey()),
 | 
					
						
							|  |  |  |     );
 | 
					
						
							|  |  |  |     transaction.sign(&[&payer], recent_blockhash);
 | 
					
						
							|  |  |  |     banks_client.process_transaction(transaction).await.unwrap();
 | 
					
						
							|  |  |  | }
 |