Add BPF Sanity program-test based test (#19159)

This commit is contained in:
Jack May
2021-08-11 12:07:15 -07:00
committed by GitHub
parent 446816de52
commit 9dfeee2993
6 changed files with 51 additions and 5 deletions

View File

@ -0,0 +1,35 @@
#![cfg(feature = "test-bpf")]
use solana_bpf_rust_sanity::process_instruction;
use solana_program_test::*;
use solana_sdk::{
instruction::{AccountMeta, Instruction},
pubkey::Pubkey,
signature::{Keypair, Signer},
transaction::Transaction,
};
#[tokio::test]
async fn test_sysvars() {
let program_id = Pubkey::new_unique();
let program_test = ProgramTest::new(
"solana_bpf_rust_sanity",
program_id,
processor!(process_instruction),
);
let (mut banks_client, payer_keypair, recent_blockhash) = program_test.start().await;
let mut transaction = Transaction::new_with_payer(
&[Instruction::new_with_bincode(
program_id,
&(),
vec![
AccountMeta::new(payer_keypair.pubkey(), true),
AccountMeta::new(Keypair::new().pubkey(), false),
],
)],
Some(&payer_keypair.pubkey()),
);
transaction.sign(&[&payer_keypair], recent_blockhash);
banks_client.process_transaction(transaction).await.unwrap();
}