Remove BankClient::process_instructions
This commit is contained in:
parent
55115d0eeb
commit
0ac865f08c
|
@ -167,7 +167,8 @@ mod tests {
|
|||
let alice_pubkey = alice_client.pubkey();
|
||||
let bob_pubkey = Keypair::new().pubkey();
|
||||
let instructions = BudgetInstruction::new_payment(&alice_pubkey, &bob_pubkey, 100);
|
||||
alice_client.process_instructions(instructions).unwrap();
|
||||
let message = Message::new(instructions);
|
||||
alice_client.process_message(message).unwrap();
|
||||
assert_eq!(bank.get_balance(&bob_pubkey), 100);
|
||||
}
|
||||
|
||||
|
@ -189,7 +190,8 @@ mod tests {
|
|||
None,
|
||||
1,
|
||||
);
|
||||
alice_client.process_instructions(instructions).unwrap();
|
||||
let message = Message::new(instructions);
|
||||
alice_client.process_message(message).unwrap();
|
||||
|
||||
// Attack! Part 1: Sign a witness transaction with a random key.
|
||||
let mallory_client = BankClient::new(&bank, Keypair::new());
|
||||
|
@ -232,7 +234,8 @@ mod tests {
|
|||
None,
|
||||
1,
|
||||
);
|
||||
alice_client.process_instructions(instructions).unwrap();
|
||||
let message = Message::new(instructions);
|
||||
alice_client.process_message(message).unwrap();
|
||||
|
||||
// Attack! Part 1: Sign a timestamp transaction with a random key.
|
||||
let mallory_client = BankClient::new(&bank, Keypair::new());
|
||||
|
@ -278,7 +281,8 @@ mod tests {
|
|||
None,
|
||||
1,
|
||||
);
|
||||
alice_client.process_instructions(instructions).unwrap();
|
||||
let message = Message::new(instructions);
|
||||
alice_client.process_message(message).unwrap();
|
||||
assert_eq!(bank.get_balance(&alice_pubkey), 1);
|
||||
assert_eq!(bank.get_balance(&budget_pubkey), 1);
|
||||
|
||||
|
@ -337,7 +341,8 @@ mod tests {
|
|||
Some(alice_pubkey),
|
||||
1,
|
||||
);
|
||||
alice_client.process_instructions(instructions).unwrap();
|
||||
let message = Message::new(instructions);
|
||||
alice_client.process_message(message).unwrap();
|
||||
assert_eq!(bank.get_balance(&alice_pubkey), 2);
|
||||
assert_eq!(bank.get_balance(&budget_pubkey), 1);
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@ mod tests {
|
|||
use solana_runtime::bank_client::BankClient;
|
||||
use solana_sdk::genesis_block::GenesisBlock;
|
||||
use solana_sdk::instruction::{AccountMeta, Instruction, InstructionError};
|
||||
use solana_sdk::message::Message;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use solana_sdk::signature::{Keypair, KeypairUtil};
|
||||
use solana_sdk::system_instruction::SystemInstruction;
|
||||
|
@ -69,7 +70,8 @@ mod tests {
|
|||
lamports: u64,
|
||||
) -> Result<()> {
|
||||
let ixs = VoteInstruction::new_account(&bank_client.pubkey(), vote_id, lamports);
|
||||
bank_client.process_instructions(ixs)
|
||||
let message = Message::new(ixs);
|
||||
bank_client.process_message(message)
|
||||
}
|
||||
|
||||
fn create_vote_account_with_delegate(
|
||||
|
@ -81,7 +83,8 @@ mod tests {
|
|||
let mut ixs = VoteInstruction::new_account(&bank_client.pubkey(), &vote_id, lamports);
|
||||
let delegate_ix = VoteInstruction::new_delegate_stake(&vote_id, delegate_id);
|
||||
ixs.push(delegate_ix);
|
||||
bank_client.process_instructions(ixs)
|
||||
let message = Message::new(ixs);
|
||||
bank_client.process_message(message)
|
||||
}
|
||||
|
||||
fn submit_vote(
|
||||
|
@ -142,7 +145,8 @@ mod tests {
|
|||
// the 0th account in the second instruction is not! The program
|
||||
// needs to check that it's signed.
|
||||
let move_ix = SystemInstruction::new_move(&mallory_id, &vote_id, 1);
|
||||
let result = mallory_client.process_instructions(vec![move_ix, vote_ix]);
|
||||
let message = Message::new(vec![move_ix, vote_ix]);
|
||||
let result = mallory_client.process_message(message);
|
||||
|
||||
// And ensure there's no vote.
|
||||
let vote_account = bank.get_account(&vote_id).unwrap();
|
||||
|
|
|
@ -36,17 +36,10 @@ impl<'a> BankClient<'a> {
|
|||
self.bank.process_transaction(&transaction)
|
||||
}
|
||||
|
||||
/// Create and process a transaction from a list of instructions.
|
||||
pub fn process_instructions(
|
||||
&self,
|
||||
instructions: Vec<Instruction>,
|
||||
) -> Result<(), TransactionError> {
|
||||
self.process_message(Message::new(instructions))
|
||||
}
|
||||
|
||||
/// Create and process a transaction from a single instruction.
|
||||
pub fn process_instruction(&self, instruction: Instruction) -> Result<(), TransactionError> {
|
||||
self.process_instructions(vec![instruction])
|
||||
let message = Message::new(vec![instruction]);
|
||||
self.process_message(message)
|
||||
}
|
||||
|
||||
/// Transfer lamports to pubkey
|
||||
|
|
Loading…
Reference in New Issue