Add solana-test-validator --warp-slot argument

This commit is contained in:
Michael Vines
2021-01-21 18:34:51 -08:00
parent dd5a2ef05f
commit bf1943e489
12 changed files with 147 additions and 24 deletions

View File

@@ -14,7 +14,7 @@ use {
},
solana_sdk::{
account::Account,
clock::DEFAULT_MS_PER_SLOT,
clock::{Slot, DEFAULT_MS_PER_SLOT},
commitment_config::CommitmentConfig,
fee_calculator::{FeeCalculator, FeeRateGovernor},
hash::Hash,
@@ -48,6 +48,7 @@ pub struct TestValidatorGenesis {
rent: Rent,
rpc_config: JsonRpcConfig,
rpc_ports: Option<(u16, u16)>, // (JsonRpc, JsonRpcPubSub), None == random ports
warp_slot: Option<Slot>,
accounts: HashMap<Pubkey, Account>,
programs: Vec<ProgramInfo>,
}
@@ -78,6 +79,11 @@ impl TestValidatorGenesis {
self
}
pub fn warp_slot(&mut self, warp_slot: Slot) -> &mut Self {
self.warp_slot = Some(warp_slot);
self
}
/// Add an account to the test environment
pub fn add_account(&mut self, address: Pubkey, account: Account) -> &mut Self {
self.accounts.insert(address, account);
@@ -99,9 +105,10 @@ impl TestValidatorGenesis {
T: IntoIterator<Item = Pubkey>,
{
for address in addresses {
info!("Fetching {}...", address);
info!("Fetching {} over RPC...", address);
let account = rpc_client.get_account(&address).unwrap_or_else(|err| {
panic!("Failed to fetch {}: {}", address, err);
error!("Failed to fetch {}: {}", address, err);
crate::validator::abort();
});
self.add_account(address, account);
}
@@ -280,7 +287,7 @@ impl TestValidator {
);
}
let genesis_config = create_genesis_config_with_leader_ex(
let mut genesis_config = create_genesis_config_with_leader_ex(
mint_lamports,
&mint_address,
&validator_identity.pubkey(),
@@ -293,6 +300,7 @@ impl TestValidator {
solana_sdk::genesis_config::ClusterType::Development,
accounts.into_iter().collect(),
);
genesis_config.epoch_schedule = solana_sdk::epoch_schedule::EpochSchedule::without_warmup();
let ledger_path = match &config.ledger_path {
None => create_new_tmp_ledger!(&genesis_config).0,
@@ -385,6 +393,7 @@ impl TestValidator {
snapshot_version: SnapshotVersion::default(),
}),
enforce_ulimit_nofile: false,
warp_slot: config.warp_slot,
..ValidatorConfig::default()
};