Fix fragile tests in prep of stake rewrite pr (#13654)

* Fix fragile tests in prep of stake rewrite pr

* Restore BOOTSTRAP_VALIDATOR_LAMPORTS where appropriate

* Further clean up

* Further clean up

* Aligh with other call site change

* Remove false warn!

* fix ci!
This commit is contained in:
Ryo Onodera
2020-11-20 17:21:03 +09:00
committed by GitHub
parent 2cb006fa44
commit b74d7b5758
7 changed files with 34 additions and 24 deletions

View File

@@ -1,6 +1,6 @@
pub use solana_runtime::genesis_utils::{
create_genesis_config_with_leader, create_genesis_config_with_leader_ex, GenesisConfigInfo,
BOOTSTRAP_VALIDATOR_LAMPORTS,
bootstrap_validator_stake_lamports, create_genesis_config_with_leader,
create_genesis_config_with_leader_ex, GenesisConfigInfo,
};
// same as genesis_config::create_genesis_config, but with bootstrap_validator staking logic
@@ -9,6 +9,6 @@ pub fn create_genesis_config(mint_lamports: u64) -> GenesisConfigInfo {
create_genesis_config_with_leader(
mint_lamports,
&solana_sdk::pubkey::new_rand(),
BOOTSTRAP_VALIDATOR_LAMPORTS,
bootstrap_validator_stake_lamports(),
)
}

View File

@@ -260,13 +260,14 @@ mod tests {
use crate::{
blockstore::make_slot_entries,
genesis_utils::{
create_genesis_config, create_genesis_config_with_leader, GenesisConfigInfo,
BOOTSTRAP_VALIDATOR_LAMPORTS,
bootstrap_validator_stake_lamports, create_genesis_config,
create_genesis_config_with_leader, GenesisConfigInfo,
},
get_tmp_ledger_path,
staking_utils::tests::setup_vote_and_stake_accounts,
};
use solana_runtime::bank::Bank;
use solana_runtime::genesis_utils::BOOTSTRAP_VALIDATOR_LAMPORTS;
use solana_sdk::clock::NUM_CONSECUTIVE_LEADER_SLOTS;
use solana_sdk::epoch_schedule::{
EpochSchedule, DEFAULT_LEADER_SCHEDULE_SLOT_OFFSET, DEFAULT_SLOTS_PER_EPOCH,
@@ -382,7 +383,7 @@ mod tests {
let mut genesis_config = create_genesis_config_with_leader(
BOOTSTRAP_VALIDATOR_LAMPORTS,
&pubkey,
BOOTSTRAP_VALIDATOR_LAMPORTS,
bootstrap_validator_stake_lamports(),
)
.genesis_config;
genesis_config.epoch_schedule = EpochSchedule::custom(
@@ -435,7 +436,7 @@ mod tests {
let mut genesis_config = create_genesis_config_with_leader(
BOOTSTRAP_VALIDATOR_LAMPORTS,
&pubkey,
BOOTSTRAP_VALIDATOR_LAMPORTS,
bootstrap_validator_stake_lamports(),
)
.genesis_config;
genesis_config.epoch_schedule.warmup = false;
@@ -519,7 +520,7 @@ mod tests {
mut genesis_config,
mint_keypair,
..
} = create_genesis_config(10_000);
} = create_genesis_config(10_000 * bootstrap_validator_stake_lamports());
genesis_config.epoch_schedule.warmup = false;
let bank = Bank::new(&genesis_config);
@@ -533,7 +534,7 @@ mod tests {
&mint_keypair,
&vote_account,
&validator_identity,
BOOTSTRAP_VALIDATOR_LAMPORTS,
bootstrap_validator_stake_lamports(),
);
let node_pubkey = validator_identity.pubkey();

View File

@@ -55,14 +55,15 @@ fn sort_stakes(stakes: &mut Vec<(Pubkey, u64)>) {
mod tests {
use super::*;
use solana_runtime::genesis_utils::{
create_genesis_config_with_leader, BOOTSTRAP_VALIDATOR_LAMPORTS,
bootstrap_validator_stake_lamports, create_genesis_config_with_leader,
BOOTSTRAP_VALIDATOR_LAMPORTS,
};
#[test]
fn test_leader_schedule_via_bank() {
let pubkey = solana_sdk::pubkey::new_rand();
let genesis_config =
create_genesis_config_with_leader(0, &pubkey, BOOTSTRAP_VALIDATOR_LAMPORTS)
create_genesis_config_with_leader(0, &pubkey, bootstrap_validator_stake_lamports())
.genesis_config;
let bank = Bank::new(&genesis_config);
@@ -86,7 +87,7 @@ mod tests {
let genesis_config = create_genesis_config_with_leader(
BOOTSTRAP_VALIDATOR_LAMPORTS,
&pubkey,
BOOTSTRAP_VALIDATOR_LAMPORTS,
bootstrap_validator_stake_lamports(),
)
.genesis_config;
let bank = Bank::new(&genesis_config);

View File

@@ -101,7 +101,7 @@ where
pub(crate) mod tests {
use super::*;
use crate::genesis_utils::{
create_genesis_config, GenesisConfigInfo, BOOTSTRAP_VALIDATOR_LAMPORTS,
bootstrap_validator_stake_lamports, create_genesis_config, GenesisConfigInfo,
};
use solana_sdk::{
account::from_account,
@@ -178,10 +178,10 @@ pub(crate) mod tests {
#[test]
fn test_epoch_stakes_and_lockouts() {
solana_logger::setup();
let stake = BOOTSTRAP_VALIDATOR_LAMPORTS * 100;
let stake = bootstrap_validator_stake_lamports();
let leader_stake = Stake {
delegation: Delegation {
stake: BOOTSTRAP_VALIDATOR_LAMPORTS,
stake: bootstrap_validator_stake_lamports(),
activation_epoch: std::u64::MAX, // mark as bootstrap
..Delegation::default()
},
@@ -194,7 +194,7 @@ pub(crate) mod tests {
genesis_config,
mint_keypair,
..
} = create_genesis_config(10_000);
} = create_genesis_config(10_000 * bootstrap_validator_stake_lamports());
let bank = Bank::new(&genesis_config);
let vote_account = Keypair::new();