Add Rust BPF Tick Height test (#4718)
This commit is contained in:
@@ -75,8 +75,10 @@ mod bpf {
|
||||
use super::*;
|
||||
use solana_sdk::bpf_loader;
|
||||
use solana_sdk::client::SyncClient;
|
||||
use solana_sdk::hash;
|
||||
use solana_sdk::instruction::{AccountMeta, Instruction};
|
||||
use solana_sdk::signature::{Keypair, KeypairUtil};
|
||||
use solana_sdk::syscall::tick_height;
|
||||
use std::io::Read;
|
||||
|
||||
#[test]
|
||||
@@ -90,6 +92,7 @@ mod bpf {
|
||||
("solana_bpf_rust_noop", true),
|
||||
("solana_bpf_rust_dep_crate", true),
|
||||
("solana_bpf_rust_panic", false),
|
||||
("solana_bpf_rust_tick_height", true),
|
||||
];
|
||||
for program in programs.iter() {
|
||||
let filename = create_bpf_path(program.0);
|
||||
@@ -104,6 +107,10 @@ mod bpf {
|
||||
..
|
||||
} = create_genesis_block(50);
|
||||
let bank = Bank::new(&genesis_block);
|
||||
// register some ticks, used by solana_bpf_rust_tick_height
|
||||
for i in 0..10 {
|
||||
bank.register_tick(&hash::hash(format!("hashing {}", i).as_bytes()));
|
||||
}
|
||||
let bank_client = BankClient::new(bank);
|
||||
|
||||
// Call user program
|
||||
@@ -111,6 +118,7 @@ mod bpf {
|
||||
let account_metas = vec![
|
||||
AccountMeta::new(mint_keypair.pubkey(), true),
|
||||
AccountMeta::new(Keypair::new().pubkey(), false),
|
||||
AccountMeta::new(tick_height::id(), false),
|
||||
];
|
||||
let instruction = Instruction::new(program_id, &1u8, account_metas);
|
||||
let result = bank_client.send_instruction(&mint_keypair, instruction);
|
||||
|
Reference in New Issue
Block a user