| 
									
										
										
										
											2019-02-01 09:00:34 -08:00
										 |  |  | #[cfg(any(feature = "bpf_c", feature = "bpf_rust"))]
 | 
					
						
							| 
									
										
										
										
											2019-03-02 21:33:02 -08:00
										 |  |  | mod bpf {
 | 
					
						
							| 
									
										
										
										
											2020-01-28 17:03:37 -08:00
										 |  |  |     use solana_runtime::{
 | 
					
						
							|  |  |  |         bank::Bank,
 | 
					
						
							|  |  |  |         bank_client::BankClient,
 | 
					
						
							|  |  |  |         genesis_utils::{create_genesis_config, GenesisConfigInfo},
 | 
					
						
							|  |  |  |         loader_utils::load_program,
 | 
					
						
							|  |  |  |     };
 | 
					
						
							|  |  |  |     use std::{env, fs::File, path::PathBuf};
 | 
					
						
							| 
									
										
										
										
											2019-02-01 09:00:34 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-02 21:33:02 -08:00
										 |  |  |     /// BPF program file extension
 | 
					
						
							|  |  |  |     const PLATFORM_FILE_EXTENSION_BPF: &str = "so";
 | 
					
						
							| 
									
										
										
										
											2018-10-04 09:44:44 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-02 21:33:02 -08:00
										 |  |  |     /// Create a BPF program file name
 | 
					
						
							|  |  |  |     fn create_bpf_path(name: &str) -> PathBuf {
 | 
					
						
							|  |  |  |         let mut pathbuf = {
 | 
					
						
							|  |  |  |             let current_exe = env::current_exe().unwrap();
 | 
					
						
							|  |  |  |             PathBuf::from(current_exe.parent().unwrap().parent().unwrap())
 | 
					
						
							|  |  |  |         };
 | 
					
						
							|  |  |  |         pathbuf.push("bpf/");
 | 
					
						
							|  |  |  |         pathbuf.push(name);
 | 
					
						
							|  |  |  |         pathbuf.set_extension(PLATFORM_FILE_EXTENSION_BPF);
 | 
					
						
							|  |  |  |         pathbuf
 | 
					
						
							|  |  |  |     }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     #[cfg(feature = "bpf_c")]
 | 
					
						
							|  |  |  |     mod bpf_c {
 | 
					
						
							|  |  |  |         use super::*;
 | 
					
						
							| 
									
										
										
										
											2019-10-25 16:22:41 -07:00
										 |  |  |         use solana_runtime::loader_utils::create_invoke_instruction;
 | 
					
						
							| 
									
										
										
										
											2020-01-28 17:03:37 -08:00
										 |  |  |         use solana_sdk::{
 | 
					
						
							|  |  |  |             account::Account,
 | 
					
						
							|  |  |  |             bpf_loader,
 | 
					
						
							|  |  |  |             client::SyncClient,
 | 
					
						
							|  |  |  |             instruction::{AccountMeta, Instruction},
 | 
					
						
							|  |  |  |             pubkey::Pubkey,
 | 
					
						
							|  |  |  |             signature::KeypairUtil,
 | 
					
						
							|  |  |  |         };
 | 
					
						
							|  |  |  |         use std::{io::Read, sync::Arc};
 | 
					
						
							| 
									
										
										
										
											2019-03-02 21:33:02 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         #[test]
 | 
					
						
							|  |  |  |         fn test_program_bpf_c() {
 | 
					
						
							|  |  |  |             solana_logger::setup();
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             let programs = [
 | 
					
						
							| 
									
										
										
										
											2019-06-20 19:10:03 -07:00
										 |  |  |                 ("bpf_to_bpf", true),
 | 
					
						
							|  |  |  |                 ("multiple_static", true),
 | 
					
						
							|  |  |  |                 ("noop", true),
 | 
					
						
							|  |  |  |                 ("noop++", true),
 | 
					
						
							|  |  |  |                 ("panic", false),
 | 
					
						
							|  |  |  |                 ("relative_call", true),
 | 
					
						
							|  |  |  |                 ("struct_pass", true),
 | 
					
						
							|  |  |  |                 ("struct_ret", true),
 | 
					
						
							| 
									
										
										
										
											2019-03-02 21:33:02 -08:00
										 |  |  |             ];
 | 
					
						
							|  |  |  |             for program in programs.iter() {
 | 
					
						
							| 
									
										
										
										
											2019-06-20 19:10:03 -07:00
										 |  |  |                 println!("Test program: {:?}", program.0);
 | 
					
						
							|  |  |  |                 let mut file = File::open(create_bpf_path(program.0)).expect("file open failed");
 | 
					
						
							| 
									
										
										
										
											2019-03-02 21:33:02 -08:00
										 |  |  |                 let mut elf = Vec::new();
 | 
					
						
							|  |  |  |                 file.read_to_end(&mut elf).unwrap();
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-08 23:56:57 -05:00
										 |  |  |                 let GenesisConfigInfo {
 | 
					
						
							|  |  |  |                     genesis_config,
 | 
					
						
							| 
									
										
										
										
											2019-06-11 10:27:22 -07:00
										 |  |  |                     mint_keypair,
 | 
					
						
							|  |  |  |                     ..
 | 
					
						
							| 
									
										
										
										
											2019-11-08 23:56:57 -05:00
										 |  |  |                 } = create_genesis_config(50);
 | 
					
						
							|  |  |  |                 let bank = Bank::new(&genesis_config);
 | 
					
						
							| 
									
										
										
										
											2019-04-11 11:29:59 -07:00
										 |  |  |                 let bank_client = BankClient::new(bank);
 | 
					
						
							| 
									
										
										
										
											2019-03-02 21:33:02 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |                 // Call user program
 | 
					
						
							| 
									
										
										
										
											2019-06-12 08:49:59 -07:00
										 |  |  |                 let program_id = load_program(&bank_client, &mint_keypair, &bpf_loader::id(), elf);
 | 
					
						
							| 
									
										
										
										
											2019-10-25 16:22:41 -07:00
										 |  |  |                 let instruction =
 | 
					
						
							|  |  |  |                     create_invoke_instruction(mint_keypair.pubkey(), program_id, &1u8);
 | 
					
						
							|  |  |  |                 let result = bank_client.send_instruction(&mint_keypair, instruction);
 | 
					
						
							| 
									
										
										
										
											2019-06-20 19:10:03 -07:00
										 |  |  |                 if program.1 {
 | 
					
						
							|  |  |  |                     assert!(result.is_ok());
 | 
					
						
							|  |  |  |                 } else {
 | 
					
						
							|  |  |  |                     assert!(result.is_err());
 | 
					
						
							|  |  |  |                 }
 | 
					
						
							| 
									
										
										
										
											2019-03-02 21:33:02 -08:00
										 |  |  |             }
 | 
					
						
							|  |  |  |         }
 | 
					
						
							| 
									
										
										
										
											2020-01-24 10:54:26 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         #[test]
 | 
					
						
							|  |  |  |         fn test_program_bpf_c_duplicate_accounts() {
 | 
					
						
							|  |  |  |             solana_logger::setup();
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             let filename = create_bpf_path("dup_accounts");
 | 
					
						
							|  |  |  |             let mut file = File::open(filename).unwrap();
 | 
					
						
							|  |  |  |             let mut elf = Vec::new();
 | 
					
						
							|  |  |  |             file.read_to_end(&mut elf).unwrap();
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             let GenesisConfigInfo {
 | 
					
						
							|  |  |  |                 genesis_config,
 | 
					
						
							|  |  |  |                 mint_keypair,
 | 
					
						
							|  |  |  |                 ..
 | 
					
						
							|  |  |  |             } = create_genesis_config(50);
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             let bank = Arc::new(Bank::new(&genesis_config));
 | 
					
						
							|  |  |  |             let bank_client = BankClient::new_shared(&bank);
 | 
					
						
							|  |  |  |             let program_id = load_program(&bank_client, &mint_keypair, &bpf_loader::id(), elf);
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             let payee_account = Account::new(10, 1, &program_id);
 | 
					
						
							|  |  |  |             let payee_pubkey = Pubkey::new_rand();
 | 
					
						
							|  |  |  |             bank.store_account(&payee_pubkey, &payee_account);
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             let account = Account::new(10, 1, &program_id);
 | 
					
						
							|  |  |  |             let pubkey = Pubkey::new_rand();
 | 
					
						
							|  |  |  |             let account_metas = vec![
 | 
					
						
							|  |  |  |                 AccountMeta::new(mint_keypair.pubkey(), true),
 | 
					
						
							|  |  |  |                 AccountMeta::new(payee_pubkey, false),
 | 
					
						
							|  |  |  |                 AccountMeta::new(pubkey, false),
 | 
					
						
							|  |  |  |                 AccountMeta::new(pubkey, false),
 | 
					
						
							|  |  |  |             ];
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             bank.store_account(&pubkey, &account);
 | 
					
						
							|  |  |  |             let instruction = Instruction::new(program_id, &1u8, account_metas.clone());
 | 
					
						
							|  |  |  |             let result = bank_client.send_instruction(&mint_keypair, instruction);
 | 
					
						
							|  |  |  |             let data = bank_client.get_account_data(&pubkey).unwrap().unwrap();
 | 
					
						
							|  |  |  |             assert!(result.is_ok());
 | 
					
						
							|  |  |  |             assert_eq!(data[0], 1);
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             bank.store_account(&pubkey, &account);
 | 
					
						
							|  |  |  |             let instruction = Instruction::new(program_id, &2u8, account_metas.clone());
 | 
					
						
							|  |  |  |             let result = bank_client.send_instruction(&mint_keypair, instruction);
 | 
					
						
							|  |  |  |             let data = bank_client.get_account_data(&pubkey).unwrap().unwrap();
 | 
					
						
							|  |  |  |             assert!(result.is_ok());
 | 
					
						
							|  |  |  |             assert_eq!(data[0], 2);
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             bank.store_account(&pubkey, &account);
 | 
					
						
							|  |  |  |             let instruction = Instruction::new(program_id, &3u8, account_metas.clone());
 | 
					
						
							|  |  |  |             let result = bank_client.send_instruction(&mint_keypair, instruction);
 | 
					
						
							|  |  |  |             let data = bank_client.get_account_data(&pubkey).unwrap().unwrap();
 | 
					
						
							|  |  |  |             assert!(result.is_ok());
 | 
					
						
							|  |  |  |             assert_eq!(data[0], 3);
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             bank.store_account(&pubkey, &account);
 | 
					
						
							|  |  |  |             let instruction = Instruction::new(program_id, &4u8, account_metas.clone());
 | 
					
						
							|  |  |  |             let result = bank_client.send_instruction(&mint_keypair, instruction);
 | 
					
						
							|  |  |  |             let lamports = bank_client.get_balance(&pubkey).unwrap();
 | 
					
						
							|  |  |  |             assert!(result.is_ok());
 | 
					
						
							|  |  |  |             assert_eq!(lamports, 11);
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             bank.store_account(&pubkey, &account);
 | 
					
						
							|  |  |  |             let instruction = Instruction::new(program_id, &5u8, account_metas.clone());
 | 
					
						
							|  |  |  |             let result = bank_client.send_instruction(&mint_keypair, instruction);
 | 
					
						
							|  |  |  |             let lamports = bank_client.get_balance(&pubkey).unwrap();
 | 
					
						
							|  |  |  |             assert!(result.is_ok());
 | 
					
						
							|  |  |  |             assert_eq!(lamports, 12);
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             bank.store_account(&pubkey, &account);
 | 
					
						
							|  |  |  |             let instruction = Instruction::new(program_id, &6u8, account_metas.clone());
 | 
					
						
							|  |  |  |             let result = bank_client.send_instruction(&mint_keypair, instruction);
 | 
					
						
							|  |  |  |             let lamports = bank_client.get_balance(&pubkey).unwrap();
 | 
					
						
							|  |  |  |             assert!(result.is_ok());
 | 
					
						
							|  |  |  |             assert_eq!(lamports, 13);
 | 
					
						
							|  |  |  |         }
 | 
					
						
							| 
									
										
										
										
											2018-12-11 09:03:37 -08:00
										 |  |  |     }
 | 
					
						
							| 
									
										
										
										
											2019-01-02 15:12:42 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-02 21:33:02 -08:00
										 |  |  |     #[cfg(feature = "bpf_rust")]
 | 
					
						
							|  |  |  |     mod bpf_rust {
 | 
					
						
							|  |  |  |         use super::*;
 | 
					
						
							| 
									
										
										
										
											2020-01-28 17:03:37 -08:00
										 |  |  |         use solana_sdk::{
 | 
					
						
							|  |  |  |             account::Account,
 | 
					
						
							|  |  |  |             bpf_loader,
 | 
					
						
							|  |  |  |             client::SyncClient,
 | 
					
						
							|  |  |  |             clock::DEFAULT_SLOTS_PER_EPOCH,
 | 
					
						
							|  |  |  |             instruction::{AccountMeta, Instruction},
 | 
					
						
							|  |  |  |             pubkey::Pubkey,
 | 
					
						
							|  |  |  |             signature::{Keypair, KeypairUtil},
 | 
					
						
							|  |  |  |             sysvar::{clock, fees, rent, rewards, slot_hashes, stake_history},
 | 
					
						
							|  |  |  |         };
 | 
					
						
							| 
									
										
										
										
											2019-10-25 16:22:41 -07:00
										 |  |  |         use std::io::Read;
 | 
					
						
							| 
									
										
										
										
											2019-09-09 10:55:35 -07:00
										 |  |  |         use std::sync::Arc;
 | 
					
						
							| 
									
										
										
										
											2019-03-02 21:33:02 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         #[test]
 | 
					
						
							|  |  |  |         fn test_program_bpf_rust() {
 | 
					
						
							|  |  |  |             solana_logger::setup();
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-21 11:22:33 -07:00
										 |  |  |             let programs = [
 | 
					
						
							| 
									
										
										
										
											2019-06-21 02:43:50 -07:00
										 |  |  |                 ("solana_bpf_rust_128bit", true),
 | 
					
						
							| 
									
										
										
										
											2019-06-10 11:00:15 -07:00
										 |  |  |                 ("solana_bpf_rust_alloc", true),
 | 
					
						
							| 
									
										
										
										
											2019-06-20 16:07:12 -07:00
										 |  |  |                 ("solana_bpf_rust_dep_crate", true),
 | 
					
						
							| 
									
										
										
										
											2019-09-09 10:55:35 -07:00
										 |  |  |                 ("solana_bpf_rust_external_spend", false),
 | 
					
						
							| 
									
										
										
										
											2019-06-10 11:00:15 -07:00
										 |  |  |                 ("solana_bpf_rust_iter", true),
 | 
					
						
							| 
									
										
										
										
											2019-07-11 14:27:18 -08:00
										 |  |  |                 ("solana_bpf_rust_many_args", true),
 | 
					
						
							| 
									
										
										
										
											2019-06-10 11:00:15 -07:00
										 |  |  |                 ("solana_bpf_rust_noop", true),
 | 
					
						
							|  |  |  |                 ("solana_bpf_rust_panic", false),
 | 
					
						
							| 
									
										
										
										
											2019-08-29 11:25:22 -07:00
										 |  |  |                 ("solana_bpf_rust_param_passing", true),
 | 
					
						
							| 
									
										
										
										
											2019-09-10 18:53:02 -07:00
										 |  |  |                 ("solana_bpf_rust_sysval", true),
 | 
					
						
							| 
									
										
										
										
											2019-05-21 11:22:33 -07:00
										 |  |  |             ];
 | 
					
						
							| 
									
										
										
										
											2019-03-02 21:33:02 -08:00
										 |  |  |             for program in programs.iter() {
 | 
					
						
							| 
									
										
										
										
											2019-06-10 11:00:15 -07:00
										 |  |  |                 let filename = create_bpf_path(program.0);
 | 
					
						
							|  |  |  |                 println!("Test program: {:?} from {:?}", program.0, filename);
 | 
					
						
							| 
									
										
										
										
											2019-03-02 21:33:02 -08:00
										 |  |  |                 let mut file = File::open(filename).unwrap();
 | 
					
						
							|  |  |  |                 let mut elf = Vec::new();
 | 
					
						
							|  |  |  |                 file.read_to_end(&mut elf).unwrap();
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-08 23:56:57 -05:00
										 |  |  |                 let GenesisConfigInfo {
 | 
					
						
							|  |  |  |                     genesis_config,
 | 
					
						
							| 
									
										
										
										
											2019-06-11 10:27:22 -07:00
										 |  |  |                     mint_keypair,
 | 
					
						
							|  |  |  |                     ..
 | 
					
						
							| 
									
										
										
										
											2019-11-08 23:56:57 -05:00
										 |  |  |                 } = create_genesis_config(50);
 | 
					
						
							|  |  |  |                 let bank = Arc::new(Bank::new(&genesis_config));
 | 
					
						
							| 
									
										
										
										
											2019-09-10 18:53:02 -07:00
										 |  |  |                 // Create bank with specific slot, used by solana_bpf_rust_sysvar test
 | 
					
						
							|  |  |  |                 let bank =
 | 
					
						
							|  |  |  |                     Bank::new_from_parent(&bank, &Pubkey::default(), DEFAULT_SLOTS_PER_EPOCH + 1);
 | 
					
						
							| 
									
										
										
										
											2019-04-11 11:29:59 -07:00
										 |  |  |                 let bank_client = BankClient::new(bank);
 | 
					
						
							| 
									
										
										
										
											2019-03-21 08:14:14 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-02 21:33:02 -08:00
										 |  |  |                 // Call user program
 | 
					
						
							| 
									
										
										
										
											2019-06-12 08:49:59 -07:00
										 |  |  |                 let program_id = load_program(&bank_client, &mint_keypair, &bpf_loader::id(), elf);
 | 
					
						
							| 
									
										
										
										
											2019-05-21 11:22:33 -07:00
										 |  |  |                 let account_metas = vec![
 | 
					
						
							| 
									
										
										
										
											2019-06-10 11:00:15 -07:00
										 |  |  |                     AccountMeta::new(mint_keypair.pubkey(), true),
 | 
					
						
							| 
									
										
										
										
											2019-05-21 11:22:33 -07:00
										 |  |  |                     AccountMeta::new(Keypair::new().pubkey(), false),
 | 
					
						
							| 
									
										
										
										
											2019-09-09 10:55:35 -07:00
										 |  |  |                     AccountMeta::new(clock::id(), false),
 | 
					
						
							| 
									
										
										
										
											2019-09-10 18:53:02 -07:00
										 |  |  |                     AccountMeta::new(fees::id(), false),
 | 
					
						
							|  |  |  |                     AccountMeta::new(rewards::id(), false),
 | 
					
						
							|  |  |  |                     AccountMeta::new(slot_hashes::id(), false),
 | 
					
						
							|  |  |  |                     AccountMeta::new(stake_history::id(), false),
 | 
					
						
							| 
									
										
										
										
											2019-09-18 19:54:10 -07:00
										 |  |  |                     AccountMeta::new(rent::id(), false),
 | 
					
						
							| 
									
										
										
										
											2019-05-21 11:22:33 -07:00
										 |  |  |                 ];
 | 
					
						
							| 
									
										
										
										
											2019-10-25 16:22:41 -07:00
										 |  |  |                 let instruction = Instruction::new(program_id, &1u8, account_metas);
 | 
					
						
							|  |  |  |                 let result = bank_client.send_instruction(&mint_keypair, instruction);
 | 
					
						
							| 
									
										
										
										
											2019-06-10 11:00:15 -07:00
										 |  |  |                 if program.1 {
 | 
					
						
							|  |  |  |                     assert!(result.is_ok());
 | 
					
						
							|  |  |  |                 } else {
 | 
					
						
							|  |  |  |                     assert!(result.is_err());
 | 
					
						
							|  |  |  |                 }
 | 
					
						
							| 
									
										
										
										
											2019-03-02 21:33:02 -08:00
										 |  |  |             }
 | 
					
						
							|  |  |  |         }
 | 
					
						
							| 
									
										
										
										
											2020-01-22 09:11:56 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         #[test]
 | 
					
						
							|  |  |  |         fn test_program_bpf_rust_duplicate_accounts() {
 | 
					
						
							|  |  |  |             solana_logger::setup();
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             let filename = create_bpf_path("solana_bpf_rust_dup_accounts");
 | 
					
						
							|  |  |  |             let mut file = File::open(filename).unwrap();
 | 
					
						
							|  |  |  |             let mut elf = Vec::new();
 | 
					
						
							|  |  |  |             file.read_to_end(&mut elf).unwrap();
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             let GenesisConfigInfo {
 | 
					
						
							|  |  |  |                 genesis_config,
 | 
					
						
							|  |  |  |                 mint_keypair,
 | 
					
						
							|  |  |  |                 ..
 | 
					
						
							|  |  |  |             } = create_genesis_config(50);
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             let bank = Arc::new(Bank::new(&genesis_config));
 | 
					
						
							|  |  |  |             let bank_client = BankClient::new_shared(&bank);
 | 
					
						
							|  |  |  |             let program_id = load_program(&bank_client, &mint_keypair, &bpf_loader::id(), elf);
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             let payee_account = Account::new(10, 1, &program_id);
 | 
					
						
							|  |  |  |             let payee_pubkey = Pubkey::new_rand();
 | 
					
						
							|  |  |  |             bank.store_account(&payee_pubkey, &payee_account);
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             let account = Account::new(10, 1, &program_id);
 | 
					
						
							|  |  |  |             let pubkey = Pubkey::new_rand();
 | 
					
						
							|  |  |  |             let account_metas = vec![
 | 
					
						
							|  |  |  |                 AccountMeta::new(mint_keypair.pubkey(), true),
 | 
					
						
							|  |  |  |                 AccountMeta::new(payee_pubkey, false),
 | 
					
						
							|  |  |  |                 AccountMeta::new(pubkey, false),
 | 
					
						
							|  |  |  |                 AccountMeta::new(pubkey, false),
 | 
					
						
							|  |  |  |             ];
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             bank.store_account(&pubkey, &account);
 | 
					
						
							|  |  |  |             let instruction = Instruction::new(program_id, &1u8, account_metas.clone());
 | 
					
						
							|  |  |  |             let result = bank_client.send_instruction(&mint_keypair, instruction);
 | 
					
						
							|  |  |  |             let data = bank_client.get_account_data(&pubkey).unwrap().unwrap();
 | 
					
						
							|  |  |  |             assert!(result.is_ok());
 | 
					
						
							|  |  |  |             assert_eq!(data[0], 1);
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             bank.store_account(&pubkey, &account);
 | 
					
						
							|  |  |  |             let instruction = Instruction::new(program_id, &2u8, account_metas.clone());
 | 
					
						
							|  |  |  |             let result = bank_client.send_instruction(&mint_keypair, instruction);
 | 
					
						
							|  |  |  |             let data = bank_client.get_account_data(&pubkey).unwrap().unwrap();
 | 
					
						
							|  |  |  |             assert!(result.is_ok());
 | 
					
						
							|  |  |  |             assert_eq!(data[0], 2);
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             bank.store_account(&pubkey, &account);
 | 
					
						
							|  |  |  |             let instruction = Instruction::new(program_id, &3u8, account_metas.clone());
 | 
					
						
							|  |  |  |             let result = bank_client.send_instruction(&mint_keypair, instruction);
 | 
					
						
							| 
									
										
										
										
											2020-01-24 10:54:26 -08:00
										 |  |  |             let data = bank_client.get_account_data(&pubkey).unwrap().unwrap();
 | 
					
						
							|  |  |  |             assert!(result.is_ok());
 | 
					
						
							|  |  |  |             assert_eq!(data[0], 3);
 | 
					
						
							| 
									
										
										
										
											2020-01-22 09:11:56 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |             bank.store_account(&pubkey, &account);
 | 
					
						
							|  |  |  |             let instruction = Instruction::new(program_id, &4u8, account_metas.clone());
 | 
					
						
							|  |  |  |             let result = bank_client.send_instruction(&mint_keypair, instruction);
 | 
					
						
							|  |  |  |             let lamports = bank_client.get_balance(&pubkey).unwrap();
 | 
					
						
							|  |  |  |             assert!(result.is_ok());
 | 
					
						
							|  |  |  |             assert_eq!(lamports, 11);
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             bank.store_account(&pubkey, &account);
 | 
					
						
							|  |  |  |             let instruction = Instruction::new(program_id, &5u8, account_metas.clone());
 | 
					
						
							|  |  |  |             let result = bank_client.send_instruction(&mint_keypair, instruction);
 | 
					
						
							|  |  |  |             let lamports = bank_client.get_balance(&pubkey).unwrap();
 | 
					
						
							|  |  |  |             assert!(result.is_ok());
 | 
					
						
							|  |  |  |             assert_eq!(lamports, 12);
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             bank.store_account(&pubkey, &account);
 | 
					
						
							|  |  |  |             let instruction = Instruction::new(program_id, &6u8, account_metas.clone());
 | 
					
						
							|  |  |  |             let result = bank_client.send_instruction(&mint_keypair, instruction);
 | 
					
						
							| 
									
										
										
										
											2020-01-24 10:54:26 -08:00
										 |  |  |             let lamports = bank_client.get_balance(&pubkey).unwrap();
 | 
					
						
							|  |  |  |             assert!(result.is_ok());
 | 
					
						
							|  |  |  |             assert_eq!(lamports, 13);
 | 
					
						
							| 
									
										
										
										
											2020-01-22 09:11:56 -08:00
										 |  |  |         }
 | 
					
						
							| 
									
										
										
										
											2019-01-02 15:12:42 -08:00
										 |  |  |     }
 | 
					
						
							|  |  |  | }
 |