Remove keypairs from BankClient
Bring its interface closer to the other clients.
This commit is contained in:
@ -28,6 +28,7 @@ mod bpf {
|
||||
mod bpf_c {
|
||||
use super::*;
|
||||
use solana_sdk::bpf_loader;
|
||||
use solana_sdk::signature::KeypairUtil;
|
||||
use std::io::Read;
|
||||
|
||||
#[test]
|
||||
@ -38,14 +39,16 @@ mod bpf {
|
||||
let mut elf = Vec::new();
|
||||
file.read_to_end(&mut elf).unwrap();
|
||||
|
||||
let (genesis_block, mint_keypair) = GenesisBlock::new(50);
|
||||
let (genesis_block, alice_keypair) = GenesisBlock::new(50);
|
||||
let bank = Bank::new(&genesis_block);
|
||||
let alice_client = BankClient::new(&bank, mint_keypair);
|
||||
let bank_client = BankClient::new(&bank);
|
||||
|
||||
// Call user program
|
||||
let program_id = load_program(&bank, &alice_client, &bpf_loader::id(), elf);
|
||||
let instruction = create_invoke_instruction(alice_client.pubkey(), program_id, &1u8);
|
||||
alice_client.process_instruction(instruction).unwrap();
|
||||
let program_id = load_program(&bank_client, &alice_keypair, &bpf_loader::id(), elf);
|
||||
let instruction = create_invoke_instruction(alice_keypair.pubkey(), program_id, &1u8);
|
||||
bank_client
|
||||
.process_instruction(&alice_keypair, instruction)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -67,22 +70,24 @@ mod bpf {
|
||||
let mut elf = Vec::new();
|
||||
file.read_to_end(&mut elf).unwrap();
|
||||
|
||||
let (genesis_block, mint_keypair) = GenesisBlock::new(50);
|
||||
let (genesis_block, alice_keypair) = GenesisBlock::new(50);
|
||||
let bank = Bank::new(&genesis_block);
|
||||
let alice_client = BankClient::new(&bank, mint_keypair);
|
||||
let bank_client = BankClient::new(&bank);
|
||||
|
||||
let loader_id = load_program(
|
||||
&bank,
|
||||
&alice_client,
|
||||
&bank_client,
|
||||
&alice_keypair,
|
||||
&native_loader::id(),
|
||||
"solana_bpf_loader".as_bytes().to_vec(),
|
||||
);
|
||||
|
||||
// Call user program
|
||||
let program_id = load_program(&bank, &alice_client, &loader_id, elf);
|
||||
let program_id = load_program(&bank_client, &alice_keypair, &loader_id, elf);
|
||||
let instruction =
|
||||
create_invoke_instruction(alice_client.pubkey(), program_id, &1u8);
|
||||
alice_client.process_instruction(instruction).unwrap();
|
||||
create_invoke_instruction(alice_keypair.pubkey(), program_id, &1u8);
|
||||
bank_client
|
||||
.process_instruction(&alice_keypair, instruction)
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -94,6 +99,7 @@ mod bpf {
|
||||
#[cfg(feature = "bpf_rust")]
|
||||
mod bpf_rust {
|
||||
use super::*;
|
||||
use solana_sdk::signature::KeypairUtil;
|
||||
use std::io::Read;
|
||||
|
||||
#[test]
|
||||
@ -108,22 +114,24 @@ mod bpf {
|
||||
let mut elf = Vec::new();
|
||||
file.read_to_end(&mut elf).unwrap();
|
||||
|
||||
let (genesis_block, mint_keypair) = GenesisBlock::new(50);
|
||||
let (genesis_block, alice_keypair) = GenesisBlock::new(50);
|
||||
let bank = Bank::new(&genesis_block);
|
||||
let alice_client = BankClient::new(&bank, mint_keypair);
|
||||
let bank_client = BankClient::new(&bank);
|
||||
|
||||
let loader_id = load_program(
|
||||
&bank,
|
||||
&alice_client,
|
||||
&bank_client,
|
||||
&alice_keypair,
|
||||
&native_loader::id(),
|
||||
"solana_bpf_loader".as_bytes().to_vec(),
|
||||
);
|
||||
|
||||
// Call user program
|
||||
let program_id = load_program(&bank, &alice_client, &loader_id, elf);
|
||||
let program_id = load_program(&bank_client, &alice_keypair, &loader_id, elf);
|
||||
let instruction =
|
||||
create_invoke_instruction(alice_client.pubkey(), program_id, &1u8);
|
||||
alice_client.process_instruction(instruction).unwrap();
|
||||
create_invoke_instruction(alice_keypair.pubkey(), program_id, &1u8);
|
||||
bank_client
|
||||
.process_instruction(&alice_keypair, instruction)
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user