Add convenience function for programs to get minimum delegation (#24175)
This commit is contained in:
@ -56,6 +56,7 @@ use {
|
||||
pubkey::Pubkey,
|
||||
rent::Rent,
|
||||
signature::{keypair_from_seed, Keypair, Signer},
|
||||
stake,
|
||||
system_instruction::{self, MAX_PERMITTED_DATA_LENGTH},
|
||||
system_program,
|
||||
sysvar::{self, clock, rent},
|
||||
@ -3522,3 +3523,32 @@ fn test_program_fees() {
|
||||
let post_balance = bank_client.get_balance(&mint_keypair.pubkey()).unwrap();
|
||||
assert_eq!(pre_balance - post_balance, expected_min_fee);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "bpf_rust")]
|
||||
fn test_get_minimum_delegation() {
|
||||
let GenesisConfigInfo {
|
||||
genesis_config,
|
||||
mint_keypair,
|
||||
..
|
||||
} = create_genesis_config(100_123_456_789);
|
||||
let mut bank = Bank::new_for_tests(&genesis_config);
|
||||
bank.feature_set = Arc::new(FeatureSet::all_enabled());
|
||||
|
||||
let (name, id, entrypoint) = solana_bpf_loader_program!();
|
||||
bank.add_builtin(&name, &id, entrypoint);
|
||||
let bank = Arc::new(bank);
|
||||
let bank_client = BankClient::new_shared(&bank);
|
||||
|
||||
let program_id = load_bpf_program(
|
||||
&bank_client,
|
||||
&bpf_loader::id(),
|
||||
&mint_keypair,
|
||||
"solana_bpf_rust_get_minimum_delegation",
|
||||
);
|
||||
|
||||
let account_metas = vec![AccountMeta::new_readonly(stake::program::id(), false)];
|
||||
let instruction = Instruction::new_with_bytes(program_id, &[], account_metas);
|
||||
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
||||
assert!(result.is_ok());
|
||||
}
|
||||
|
Reference in New Issue
Block a user