Rename Client methods to match proposed BanksClient (bp #10793) (#10800)

* 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:
mergify[bot]
2020-06-25 05:33:12 +00:00
committed by GitHub
parent 0ee4a5e799
commit 85750307aa
23 changed files with 209 additions and 157 deletions

View File

@@ -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);
}
}