Rename StaticEntrypoint to ProcessInstruction

This commit is contained in:
Greg Fitzgerald
2019-03-16 17:20:09 -06:00
committed by Grimes
parent ae4d14a2ad
commit c09accb685
4 changed files with 26 additions and 45 deletions

View File

@@ -154,7 +154,7 @@ mod test {
fn create_bank(lamports: u64) -> (Bank, Keypair) {
let (genesis_block, mint_keypair) = GenesisBlock::new(lamports);
let mut bank = Bank::new(&genesis_block);
bank.add_entrypoint(id(), process_instruction);
bank.add_instruction_processor(id(), process_instruction);
(bank, mint_keypair)
}

View File

@@ -1,32 +0,0 @@
use solana_budget_api::budget_transaction::BudgetTransaction;
use solana_runtime::bank::{Bank, Result};
use solana_sdk::genesis_block::GenesisBlock;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::{Keypair, KeypairUtil};
struct BudgetBank<'a> {
bank: &'a Bank,
}
impl<'a> BudgetBank<'a> {
fn new(bank: &'a Bank) -> Self {
bank.add_native_program("solana_budget_program", &solana_budget_api::id());
Self { bank }
}
fn pay(&self, from_keypair: &Keypair, to_id: &Pubkey, lamports: u64) -> Result<()> {
let blockhash = self.bank.last_blockhash();
let tx = BudgetTransaction::new_payment(from_keypair, to_id, lamports, blockhash, 0);
self.bank.process_transaction(&tx)
}
}
#[test]
fn test_budget_payment_via_bank() {
let (genesis_block, from_keypair) = GenesisBlock::new(10_000);
let bank = Bank::new(&genesis_block);
let budget_bank = BudgetBank::new(&bank);
let to_id = Keypair::new().pubkey();
budget_bank.pay(&from_keypair, &to_id, 100).unwrap();
assert_eq!(bank.get_balance(&to_id), 100);
}