Skip to content

Commit

Permalink
bpf test
Browse files Browse the repository at this point in the history
  • Loading branch information
sakridge committed Aug 26, 2020
1 parent 1e16f5b commit a9f586f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions programs/bpf/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ fn main() {
"dup_accounts",
"error_handling",
"external_spend",
"instruction_introspection",
"invoke",
"invoked",
"iter",
Expand Down
31 changes: 31 additions & 0 deletions programs/bpf/tests/programs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,3 +457,34 @@ fn test_program_bpf_invoke() {
}
}
}

#[test]
#[cfg(any(feature = "bpf_rust"))]
fn test_program_bpf_instruction_introspection() {
solana_logger::setup();

let GenesisConfigInfo {
genesis_config,
mint_keypair,
..
} = create_genesis_config(50_000);
let mut bank = Bank::new(&genesis_config);

let (name, id, entrypoint) = solana_bpf_loader_program!();
bank.add_builtin_loader(&name, id, entrypoint);
let bank = Arc::new(bank);
let bank_client = BankClient::new_shared(&bank);

let program_id = load_bpf_program(
&bank_client,
&mint_keypair,
"solana_bpf_rust_instruction_introspection",
);
let account_metas = vec![AccountMeta::new(
solana_sdk::sysvar::instructions::id(),
false,
)];
let instruction = Instruction::new(program_id, &0u8, account_metas);
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
assert!(result.is_ok());
}

0 comments on commit a9f586f

Please sign in to comment.