Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
program-test: Add large bootstrap stake for realistic warmups (backport
Browse files Browse the repository at this point in the history
#16739) (#16741)

* program-test: Add large bootstrap stake for realistic warmups (#16739)

(cherry picked from commit f421463)

# Conflicts:
#	program-test/Cargo.toml

* Fix merge conflict

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
  • Loading branch information
mergify[bot] and joncinque authored Apr 22, 2021
1 parent fadf1ef commit 5f5fa38
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions program-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ thiserror = "1.0"
tokio = { version = "1", features = ["full"] }

[dev-dependencies]
assert_matches = "1.3.0"
solana-stake-program = { path = "../programs/stake", version = "=1.6.7" }
3 changes: 2 additions & 1 deletion program-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,8 @@ impl ProgramTest {
let rent = Rent::default();
let fee_rate_governor = FeeRateGovernor::default();
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 voting_keypair = Keypair::new();
Expand Down
36 changes: 34 additions & 2 deletions program-test/tests/warp.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#![allow(clippy::integer_arithmetic)]
use {
assert_matches::assert_matches,
bincode::deserialize,
solana_program_test::{processor, ProgramTest, ProgramTestError},
solana_sdk::{
account_info::{next_account_info, AccountInfo},
Expand All @@ -11,12 +13,16 @@ use {
rent::Rent,
signature::{Keypair, Signer},
system_instruction, system_program,
sysvar::{clock, Sysvar},
sysvar::{
clock,
stake_history::{self, StakeHistory},
Sysvar,
},
transaction::{Transaction, TransactionError},
},
solana_stake_program::{
stake_instruction,
stake_state::{Authorized, Lockup},
stake_state::{Authorized, Lockup, StakeState},
},
solana_vote_program::{
vote_instruction,
Expand Down Expand Up @@ -248,4 +254,30 @@ async fn stake_rewards_from_warp() {
.expect("account exists")
.unwrap();
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)
);
}

0 comments on commit 5f5fa38

Please sign in to comment.