|
| 1 | +use litesvm::LiteSVM; |
| 2 | + |
| 3 | +use repository_layout_program::processor::CarnivalInstructionData; |
| 4 | +use solana_instruction::{AccountMeta, Instruction}; |
| 5 | +use solana_keypair::{Keypair, Signer}; |
| 6 | +use solana_program::native_token::LAMPORTS_PER_SOL; |
| 7 | +use solana_pubkey::Pubkey; |
| 8 | +use solana_transaction::Transaction; |
| 9 | + |
| 10 | +#[test] |
| 11 | +fn test_repo_layout() { |
| 12 | + let mut svm = LiteSVM::new(); |
| 13 | + |
| 14 | + let program_id = Pubkey::new_unique(); |
| 15 | + let program_bytes = include_bytes!("../../../../../target/deploy/repository_layout_program.so"); |
| 16 | + |
| 17 | + svm.add_program(program_id, program_bytes).unwrap(); |
| 18 | + |
| 19 | + let payer = Keypair::new(); |
| 20 | + svm.airdrop(&payer.pubkey(), LAMPORTS_PER_SOL * 10).unwrap(); |
| 21 | + |
| 22 | + let data = borsh::to_vec(&CarnivalInstructionData { |
| 23 | + name: "Jimmy".to_string(), |
| 24 | + height: 36, |
| 25 | + ticket_count: 15, |
| 26 | + attraction: "ride".to_string(), |
| 27 | + attraction_name: "Scrambler".to_string(), |
| 28 | + }) |
| 29 | + .unwrap(); |
| 30 | + |
| 31 | + let ix = Instruction { |
| 32 | + program_id, |
| 33 | + accounts: vec![AccountMeta::new(payer.pubkey(), true)], |
| 34 | + data, |
| 35 | + }; |
| 36 | + |
| 37 | + let tx = Transaction::new_signed_with_payer( |
| 38 | + &[ix], |
| 39 | + Some(&payer.pubkey()), |
| 40 | + &[&payer], |
| 41 | + svm.latest_blockhash(), |
| 42 | + ); |
| 43 | + |
| 44 | + let _ = svm.send_transaction(tx).is_ok(); |
| 45 | + |
| 46 | + let data = borsh::to_vec(&CarnivalInstructionData { |
| 47 | + name: "Jimmy".to_string(), |
| 48 | + height: 36, |
| 49 | + ticket_count: 15, |
| 50 | + attraction: "game".to_string(), |
| 51 | + attraction_name: "I Got it!".to_string(), |
| 52 | + }) |
| 53 | + .unwrap(); |
| 54 | + |
| 55 | + let ix = Instruction { |
| 56 | + program_id, |
| 57 | + accounts: vec![AccountMeta::new(payer.pubkey(), true)], |
| 58 | + data, |
| 59 | + }; |
| 60 | + |
| 61 | + let tx = Transaction::new_signed_with_payer( |
| 62 | + &[ix], |
| 63 | + Some(&payer.pubkey()), |
| 64 | + &[&payer], |
| 65 | + svm.latest_blockhash(), |
| 66 | + ); |
| 67 | + |
| 68 | + let _ = svm.send_transaction(tx).is_ok(); |
| 69 | + let data = borsh::to_vec(&CarnivalInstructionData { |
| 70 | + name: "Jimmy".to_string(), |
| 71 | + height: 36, |
| 72 | + ticket_count: 15, |
| 73 | + attraction: "food".to_string(), |
| 74 | + attraction_name: "Taco Shack".to_string(), |
| 75 | + }) |
| 76 | + .unwrap(); |
| 77 | + |
| 78 | + let ix = Instruction { |
| 79 | + program_id, |
| 80 | + accounts: vec![AccountMeta::new(payer.pubkey(), true)], |
| 81 | + data, |
| 82 | + }; |
| 83 | + |
| 84 | + let tx = Transaction::new_signed_with_payer( |
| 85 | + &[ix], |
| 86 | + Some(&payer.pubkey()), |
| 87 | + &[&payer], |
| 88 | + svm.latest_blockhash(), |
| 89 | + ); |
| 90 | + |
| 91 | + let _ = svm.send_transaction(tx).is_ok(); |
| 92 | +} |
0 commit comments