Rename to ClusterType and restore devnet compat. (#12068)
* Rename to ClusterType and restore devnet compat. * De-duplicate parse code and add comments * Adjust default Devnet genesis & reduce it in tests
This commit is contained in:
@ -7,26 +7,26 @@ macro_rules! DEFINE_SNAPSHOT_VERSION_PARAMETERIZED_TEST_FUNCTIONS {
|
||||
use super::*;
|
||||
|
||||
const SNAPSHOT_VERSION: SnapshotVersion = SnapshotVersion::$x;
|
||||
const OPERATING_MODE: OperatingMode = OperatingMode::$y;
|
||||
const CLUSTER_TYPE: ClusterType = ClusterType::$y;
|
||||
|
||||
#[test]
|
||||
fn test_bank_forks_status_cache_snapshot_n() {
|
||||
run_test_bank_forks_status_cache_snapshot_n(SNAPSHOT_VERSION, OPERATING_MODE)
|
||||
run_test_bank_forks_status_cache_snapshot_n(SNAPSHOT_VERSION, CLUSTER_TYPE)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bank_forks_snapshot_n() {
|
||||
run_test_bank_forks_snapshot_n(SNAPSHOT_VERSION, OPERATING_MODE)
|
||||
run_test_bank_forks_snapshot_n(SNAPSHOT_VERSION, CLUSTER_TYPE)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_concurrent_snapshot_packaging() {
|
||||
run_test_concurrent_snapshot_packaging(SNAPSHOT_VERSION, OPERATING_MODE)
|
||||
run_test_concurrent_snapshot_packaging(SNAPSHOT_VERSION, CLUSTER_TYPE)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_slots_to_snapshot() {
|
||||
run_test_slots_to_snapshot(SNAPSHOT_VERSION, OPERATING_MODE)
|
||||
run_test_slots_to_snapshot(SNAPSHOT_VERSION, CLUSTER_TYPE)
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -50,7 +50,7 @@ mod tests {
|
||||
};
|
||||
use solana_sdk::{
|
||||
clock::Slot,
|
||||
genesis_config::{GenesisConfig, OperatingMode},
|
||||
genesis_config::{ClusterType, GenesisConfig},
|
||||
hash::hashv,
|
||||
pubkey::Pubkey,
|
||||
signature::{Keypair, Signer},
|
||||
@ -60,8 +60,9 @@ mod tests {
|
||||
use tempfile::TempDir;
|
||||
|
||||
DEFINE_SNAPSHOT_VERSION_PARAMETERIZED_TEST_FUNCTIONS!(V1_2_0, Development, V1_2_0_Development);
|
||||
DEFINE_SNAPSHOT_VERSION_PARAMETERIZED_TEST_FUNCTIONS!(V1_2_0, Preview, V1_2_0_Preview);
|
||||
DEFINE_SNAPSHOT_VERSION_PARAMETERIZED_TEST_FUNCTIONS!(V1_2_0, Stable, V1_2_0_Stable);
|
||||
DEFINE_SNAPSHOT_VERSION_PARAMETERIZED_TEST_FUNCTIONS!(V1_2_0, Devnet, V1_2_0_Devnet);
|
||||
DEFINE_SNAPSHOT_VERSION_PARAMETERIZED_TEST_FUNCTIONS!(V1_2_0, Testnet, V1_2_0_Testnet);
|
||||
DEFINE_SNAPSHOT_VERSION_PARAMETERIZED_TEST_FUNCTIONS!(V1_2_0, MainnetBeta, V1_2_0_MainnetBeta);
|
||||
|
||||
struct SnapshotTestConfig {
|
||||
accounts_dir: TempDir,
|
||||
@ -75,14 +76,14 @@ mod tests {
|
||||
impl SnapshotTestConfig {
|
||||
fn new(
|
||||
snapshot_version: SnapshotVersion,
|
||||
operating_mode: OperatingMode,
|
||||
cluster_type: ClusterType,
|
||||
snapshot_interval_slots: u64,
|
||||
) -> SnapshotTestConfig {
|
||||
let accounts_dir = TempDir::new().unwrap();
|
||||
let snapshot_dir = TempDir::new().unwrap();
|
||||
let snapshot_output_path = TempDir::new().unwrap();
|
||||
let mut genesis_config_info = create_genesis_config(10_000);
|
||||
genesis_config_info.genesis_config.operating_mode = operating_mode;
|
||||
genesis_config_info.genesis_config.cluster_type = cluster_type;
|
||||
let bank0 = Bank::new_with_paths(
|
||||
&genesis_config_info.genesis_config,
|
||||
vec![accounts_dir.path().to_path_buf()],
|
||||
@ -163,7 +164,7 @@ mod tests {
|
||||
// `last_slot` bank
|
||||
fn run_bank_forks_snapshot_n<F>(
|
||||
snapshot_version: SnapshotVersion,
|
||||
operating_mode: OperatingMode,
|
||||
cluster_type: ClusterType,
|
||||
last_slot: Slot,
|
||||
f: F,
|
||||
set_root_interval: u64,
|
||||
@ -172,7 +173,7 @@ mod tests {
|
||||
{
|
||||
solana_logger::setup();
|
||||
// Set up snapshotting config
|
||||
let mut snapshot_test_config = SnapshotTestConfig::new(snapshot_version, operating_mode, 1);
|
||||
let mut snapshot_test_config = SnapshotTestConfig::new(snapshot_version, cluster_type, 1);
|
||||
|
||||
let bank_forks = &mut snapshot_test_config.bank_forks;
|
||||
let mint_keypair = &snapshot_test_config.genesis_config_info.mint_keypair;
|
||||
@ -219,13 +220,13 @@ mod tests {
|
||||
|
||||
fn run_test_bank_forks_snapshot_n(
|
||||
snapshot_version: SnapshotVersion,
|
||||
operating_mode: OperatingMode,
|
||||
cluster_type: ClusterType,
|
||||
) {
|
||||
// create banks up to slot 4 and create 1 new account in each bank. test that bank 4 snapshots
|
||||
// and restores correctly
|
||||
run_bank_forks_snapshot_n(
|
||||
snapshot_version,
|
||||
operating_mode,
|
||||
cluster_type,
|
||||
4,
|
||||
|bank, mint_keypair| {
|
||||
let key1 = Keypair::new().pubkey();
|
||||
@ -258,12 +259,12 @@ mod tests {
|
||||
|
||||
fn run_test_concurrent_snapshot_packaging(
|
||||
snapshot_version: SnapshotVersion,
|
||||
operating_mode: OperatingMode,
|
||||
cluster_type: ClusterType,
|
||||
) {
|
||||
solana_logger::setup();
|
||||
|
||||
// Set up snapshotting config
|
||||
let mut snapshot_test_config = SnapshotTestConfig::new(snapshot_version, operating_mode, 1);
|
||||
let mut snapshot_test_config = SnapshotTestConfig::new(snapshot_version, cluster_type, 1);
|
||||
|
||||
let bank_forks = &mut snapshot_test_config.bank_forks;
|
||||
let accounts_dir = &snapshot_test_config.accounts_dir;
|
||||
@ -408,10 +409,7 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
fn run_test_slots_to_snapshot(
|
||||
snapshot_version: SnapshotVersion,
|
||||
operating_mode: OperatingMode,
|
||||
) {
|
||||
fn run_test_slots_to_snapshot(snapshot_version: SnapshotVersion, cluster_type: ClusterType) {
|
||||
solana_logger::setup();
|
||||
let num_set_roots = MAX_CACHE_ENTRIES * 2;
|
||||
|
||||
@ -420,7 +418,7 @@ mod tests {
|
||||
// Make sure this test never clears bank.slots_since_snapshot
|
||||
let mut snapshot_test_config = SnapshotTestConfig::new(
|
||||
snapshot_version,
|
||||
operating_mode,
|
||||
cluster_type,
|
||||
(*add_root_interval * num_set_roots * 2) as u64,
|
||||
);
|
||||
let mut current_bank = snapshot_test_config.bank_forks[0].clone();
|
||||
@ -456,7 +454,7 @@ mod tests {
|
||||
|
||||
fn run_test_bank_forks_status_cache_snapshot_n(
|
||||
snapshot_version: SnapshotVersion,
|
||||
operating_mode: OperatingMode,
|
||||
cluster_type: ClusterType,
|
||||
) {
|
||||
// create banks up to slot (MAX_CACHE_ENTRIES * 2) + 1 while transferring 1 lamport into 2 different accounts each time
|
||||
// this is done to ensure the AccountStorageEntries keep getting cleaned up as the root moves
|
||||
@ -467,7 +465,7 @@ mod tests {
|
||||
for set_root_interval in &[1, 4] {
|
||||
run_bank_forks_snapshot_n(
|
||||
snapshot_version,
|
||||
operating_mode,
|
||||
cluster_type,
|
||||
(MAX_CACHE_ENTRIES * 2 + 1) as u64,
|
||||
|bank, mint_keypair| {
|
||||
let tx = system_transaction::transfer(
|
||||
|
Reference in New Issue
Block a user