forked from solana-developers/program-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.rs
More file actions
51 lines (41 loc) · 1.34 KB
/
test.rs
File metadata and controls
51 lines (41 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use litesvm::LiteSVM;
use processing_instructions_program::InstructionData;
use solana_instruction::{AccountMeta, Instruction};
use solana_keypair::{Keypair, Signer};
use solana_native_token::LAMPORTS_PER_SOL;
use solana_pubkey::Pubkey;
use solana_transaction::Transaction;
#[test]
fn test_processing_ixs() {
let mut svm = LiteSVM::new();
let program_id = Pubkey::new_unique();
let program_bytes = include_bytes!("../../tests/fixtures/processing_instructions_program.so");
svm.add_program(program_id, program_bytes).unwrap();
let payer = Keypair::new();
svm.airdrop(&payer.pubkey(), LAMPORTS_PER_SOL * 10).unwrap();
let jimmy = InstructionData {
name: "Jimmy".to_string(),
height: 3,
};
let mary = InstructionData {
name: "Mary".to_string(),
height: 3,
};
let ix1 = Instruction {
program_id,
accounts: vec![AccountMeta::new(payer.pubkey(), true)],
data: borsh::to_vec(&jimmy).unwrap(),
};
let ix2 = Instruction {
program_id,
accounts: vec![AccountMeta::new(payer.pubkey(), true)],
data: borsh::to_vec(&mary).unwrap(),
};
let tx = Transaction::new_signed_with_payer(
&[ix1, ix2],
Some(&payer.pubkey()),
&[&payer],
svm.latest_blockhash(),
);
let _ = svm.send_transaction(tx).is_ok();
}