Make rpc test_account_subscribe aware of stake minimum delegation (#24659)
This commit is contained in:
parent
74b05eebd8
commit
d6869773bb
|
@ -19,7 +19,7 @@ pub fn add_genesis_accounts(genesis_config: &mut GenesisConfig) -> u64 {
|
||||||
/// NOTE: This is also used to calculate the minimum balance of a stake account, which is the
|
/// NOTE: This is also used to calculate the minimum balance of a stake account, which is the
|
||||||
/// rent exempt reserve _plus_ the minimum stake delegation.
|
/// rent exempt reserve _plus_ the minimum stake delegation.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub(crate) fn get_minimum_delegation(_feature_set: &FeatureSet) -> u64 {
|
pub fn get_minimum_delegation(_feature_set: &FeatureSet) -> u64 {
|
||||||
// If/when the minimum delegation amount is changed, the `feature_set` parameter will be used
|
// If/when the minimum delegation amount is changed, the `feature_set` parameter will be used
|
||||||
// to chose the correct value. And since the MINIMUM_STAKE_DELEGATION constant cannot be
|
// to chose the correct value. And since the MINIMUM_STAKE_DELEGATION constant cannot be
|
||||||
// removed, use it here as to not duplicate magic constants.
|
// removed, use it here as to not duplicate magic constants.
|
||||||
|
|
|
@ -607,7 +607,7 @@ mod tests {
|
||||||
signature::{Keypair, Signer},
|
signature::{Keypair, Signer},
|
||||||
stake::{
|
stake::{
|
||||||
self, instruction as stake_instruction,
|
self, instruction as stake_instruction,
|
||||||
state::{Authorized, Lockup, StakeAuthorize},
|
state::{Authorized, Lockup, StakeAuthorize, StakeState},
|
||||||
},
|
},
|
||||||
system_instruction, system_program, system_transaction,
|
system_instruction, system_program, system_transaction,
|
||||||
transaction::{self, Transaction},
|
transaction::{self, Transaction},
|
||||||
|
@ -828,7 +828,7 @@ mod tests {
|
||||||
genesis_config,
|
genesis_config,
|
||||||
mint_keypair: alice,
|
mint_keypair: alice,
|
||||||
..
|
..
|
||||||
} = create_genesis_config(10_000);
|
} = create_genesis_config(10_000_000_000);
|
||||||
|
|
||||||
let new_stake_authority = solana_sdk::pubkey::new_rand();
|
let new_stake_authority = solana_sdk::pubkey::new_rand();
|
||||||
let stake_authority = Keypair::new();
|
let stake_authority = Keypair::new();
|
||||||
|
@ -872,16 +872,24 @@ mod tests {
|
||||||
rpc_subscriptions.notify_slot(1, 0, 0);
|
rpc_subscriptions.notify_slot(1, 0, 0);
|
||||||
receiver2.recv();
|
receiver2.recv();
|
||||||
|
|
||||||
let tx = system_transaction::transfer(&alice, &from.pubkey(), 51, blockhash);
|
let balance = {
|
||||||
process_transaction_and_notify(&bank_forks, &tx, &rpc_subscriptions, 1).unwrap();
|
let bank = bank_forks.read().unwrap().working_bank();
|
||||||
|
let rent = &bank.rent_collector().rent;
|
||||||
|
let rent_exempt_reserve = rent.minimum_balance(StakeState::size_of());
|
||||||
|
let minimum_delegation =
|
||||||
|
solana_stake_program::get_minimum_delegation(&bank.feature_set);
|
||||||
|
rent_exempt_reserve + minimum_delegation
|
||||||
|
};
|
||||||
|
|
||||||
|
let tx = system_transaction::transfer(&alice, &from.pubkey(), balance, blockhash);
|
||||||
|
process_transaction_and_notify(&bank_forks, &tx, &rpc_subscriptions, 1).unwrap();
|
||||||
let authorized = Authorized::auto(&stake_authority.pubkey());
|
let authorized = Authorized::auto(&stake_authority.pubkey());
|
||||||
let ixs = stake_instruction::create_account(
|
let ixs = stake_instruction::create_account(
|
||||||
&from.pubkey(),
|
&from.pubkey(),
|
||||||
&stake_account.pubkey(),
|
&stake_account.pubkey(),
|
||||||
&authorized,
|
&authorized,
|
||||||
&Lockup::default(),
|
&Lockup::default(),
|
||||||
51,
|
balance,
|
||||||
);
|
);
|
||||||
let message = Message::new(&ixs, Some(&from.pubkey()));
|
let message = Message::new(&ixs, Some(&from.pubkey()));
|
||||||
let tx = Transaction::new(&[&from, &stake_account], message, blockhash);
|
let tx = Transaction::new(&[&from, &stake_account], message, blockhash);
|
||||||
|
@ -904,7 +912,7 @@ mod tests {
|
||||||
"context": { "slot": 1 },
|
"context": { "slot": 1 },
|
||||||
"value": {
|
"value": {
|
||||||
"owner": stake_program_id.to_string(),
|
"owner": stake_program_id.to_string(),
|
||||||
"lamports": 51,
|
"lamports": balance,
|
||||||
"data": [base64::encode(expected_data), encoding],
|
"data": [base64::encode(expected_data), encoding],
|
||||||
"executable": false,
|
"executable": false,
|
||||||
"rentEpoch": 0,
|
"rentEpoch": 0,
|
||||||
|
|
Loading…
Reference in New Issue