program-test: Add large bootstrap stake for realistic warmups (#16739)
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -4941,6 +4941,7 @@ dependencies = [
|
|||||||
name = "solana-program-test"
|
name = "solana-program-test"
|
||||||
version = "1.7.0"
|
version = "1.7.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"assert_matches",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"base64 0.12.3",
|
"base64 0.12.3",
|
||||||
"bincode",
|
"bincode",
|
||||||
|
@ -28,4 +28,5 @@ thiserror = "1.0"
|
|||||||
tokio = { version = "1", features = ["full"] }
|
tokio = { version = "1", features = ["full"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
assert_matches = "1.3.0"
|
||||||
solana-stake-program = { path = "../programs/stake", version = "=1.7.0" }
|
solana-stake-program = { path = "../programs/stake", version = "=1.7.0" }
|
||||||
|
@ -672,7 +672,8 @@ impl ProgramTest {
|
|||||||
let rent = Rent::default();
|
let rent = Rent::default();
|
||||||
let fee_rate_governor = FeeRateGovernor::default();
|
let fee_rate_governor = FeeRateGovernor::default();
|
||||||
let bootstrap_validator_pubkey = Pubkey::new_unique();
|
let bootstrap_validator_pubkey = Pubkey::new_unique();
|
||||||
let bootstrap_validator_stake_lamports = rent.minimum_balance(VoteState::size_of());
|
let bootstrap_validator_stake_lamports =
|
||||||
|
rent.minimum_balance(VoteState::size_of()) + sol_to_lamports(1_000_000.0);
|
||||||
|
|
||||||
let mint_keypair = Keypair::new();
|
let mint_keypair = Keypair::new();
|
||||||
let voting_keypair = Keypair::new();
|
let voting_keypair = Keypair::new();
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#![allow(clippy::integer_arithmetic)]
|
#![allow(clippy::integer_arithmetic)]
|
||||||
use {
|
use {
|
||||||
|
assert_matches::assert_matches,
|
||||||
|
bincode::deserialize,
|
||||||
solana_program_test::{processor, ProgramTest, ProgramTestError},
|
solana_program_test::{processor, ProgramTest, ProgramTestError},
|
||||||
solana_sdk::{
|
solana_sdk::{
|
||||||
account_info::{next_account_info, AccountInfo},
|
account_info::{next_account_info, AccountInfo},
|
||||||
@ -11,12 +13,16 @@ use {
|
|||||||
rent::Rent,
|
rent::Rent,
|
||||||
signature::{Keypair, Signer},
|
signature::{Keypair, Signer},
|
||||||
system_instruction, system_program,
|
system_instruction, system_program,
|
||||||
sysvar::{clock, Sysvar},
|
sysvar::{
|
||||||
|
clock,
|
||||||
|
stake_history::{self, StakeHistory},
|
||||||
|
Sysvar,
|
||||||
|
},
|
||||||
transaction::{Transaction, TransactionError},
|
transaction::{Transaction, TransactionError},
|
||||||
},
|
},
|
||||||
solana_stake_program::{
|
solana_stake_program::{
|
||||||
stake_instruction,
|
stake_instruction,
|
||||||
stake_state::{Authorized, Lockup},
|
stake_state::{Authorized, Lockup, StakeState},
|
||||||
},
|
},
|
||||||
solana_vote_program::{
|
solana_vote_program::{
|
||||||
vote_instruction,
|
vote_instruction,
|
||||||
@ -248,4 +254,30 @@ async fn stake_rewards_from_warp() {
|
|||||||
.expect("account exists")
|
.expect("account exists")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert!(account.lamports > stake_lamports);
|
assert!(account.lamports > stake_lamports);
|
||||||
|
|
||||||
|
// check that stake is fully active
|
||||||
|
let stake_history_account = context
|
||||||
|
.banks_client
|
||||||
|
.get_account(stake_history::id())
|
||||||
|
.await
|
||||||
|
.expect("account exists")
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let clock_account = context
|
||||||
|
.banks_client
|
||||||
|
.get_account(clock::id())
|
||||||
|
.await
|
||||||
|
.expect("account exists")
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let stake_state: StakeState = deserialize(&account.data).unwrap();
|
||||||
|
let stake_history: StakeHistory = deserialize(&stake_history_account.data).unwrap();
|
||||||
|
let clock: Clock = deserialize(&clock_account.data).unwrap();
|
||||||
|
let stake = stake_state.stake().unwrap();
|
||||||
|
assert_matches!(
|
||||||
|
stake
|
||||||
|
.delegation
|
||||||
|
.stake_activating_and_deactivating(clock.epoch, Some(&stake_history), true,),
|
||||||
|
(_, 0, 0)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user