* Rename Client methods to match proposed BanksClient (#10793)
(cherry picked from commit 7ade330b23)
# Conflicts:
# programs/bpf/tests/programs.rs
# runtime/benches/bank.rs
* Fix merge
Co-authored-by: Greg Fitzgerald <greg@solana.com>
This commit is contained in:
@@ -79,7 +79,11 @@ impl AsyncClient for BankClient {
|
||||
}
|
||||
|
||||
impl SyncClient for BankClient {
|
||||
fn send_message<T: Signers>(&self, keypairs: &T, message: Message) -> Result<Signature> {
|
||||
fn send_and_confirm_message<T: Signers>(
|
||||
&self,
|
||||
keypairs: &T,
|
||||
message: Message,
|
||||
) -> Result<Signature> {
|
||||
let blockhash = self.bank.last_blockhash();
|
||||
let transaction = Transaction::new(keypairs, message, blockhash);
|
||||
self.bank.process_transaction(&transaction)?;
|
||||
@@ -87,16 +91,25 @@ impl SyncClient for BankClient {
|
||||
}
|
||||
|
||||
/// Create and process a transaction from a single instruction.
|
||||
fn send_instruction(&self, keypair: &Keypair, instruction: Instruction) -> Result<Signature> {
|
||||
fn send_and_confirm_instruction(
|
||||
&self,
|
||||
keypair: &Keypair,
|
||||
instruction: Instruction,
|
||||
) -> Result<Signature> {
|
||||
let message = Message::new(&[instruction], Some(&keypair.pubkey()));
|
||||
self.send_message(&[keypair], message)
|
||||
self.send_and_confirm_message(&[keypair], message)
|
||||
}
|
||||
|
||||
/// Transfer `lamports` from `keypair` to `pubkey`
|
||||
fn transfer(&self, lamports: u64, keypair: &Keypair, pubkey: &Pubkey) -> Result<Signature> {
|
||||
fn transfer_and_confirm(
|
||||
&self,
|
||||
lamports: u64,
|
||||
keypair: &Keypair,
|
||||
pubkey: &Pubkey,
|
||||
) -> Result<Signature> {
|
||||
let transfer_instruction =
|
||||
system_instruction::transfer(&keypair.pubkey(), pubkey, lamports);
|
||||
self.send_instruction(keypair, transfer_instruction)
|
||||
self.send_and_confirm_instruction(keypair, transfer_instruction)
|
||||
}
|
||||
|
||||
fn get_account_data(&self, pubkey: &Pubkey) -> Result<Option<Vec<u8>>> {
|
||||
@@ -307,7 +320,9 @@ mod tests {
|
||||
.push(AccountMeta::new(jane_pubkey, true));
|
||||
|
||||
let message = Message::new(&[transfer_instruction], Some(&john_pubkey));
|
||||
bank_client.send_message(&doe_keypairs, message).unwrap();
|
||||
bank_client
|
||||
.send_and_confirm_message(&doe_keypairs, message)
|
||||
.unwrap();
|
||||
assert_eq!(bank_client.get_balance(&bob_pubkey).unwrap(), 42);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user