From e01278ef552c18b9ae473f6bce43684e42916c7a Mon Sep 17 00:00:00 2001 From: Brooks Date: Thu, 16 May 2024 12:50:22 -0400 Subject: [PATCH] Removes unnecessary tests in snapshot_packager_service.rs (#1371) --- core/src/snapshot_packager_service.rs | 83 +-------------------------- 1 file changed, 3 insertions(+), 80 deletions(-) diff --git a/core/src/snapshot_packager_service.rs b/core/src/snapshot_packager_service.rs index 259d0a0805b524..e778e5cb12a392 100644 --- a/core/src/snapshot_packager_service.rs +++ b/core/src/snapshot_packager_service.rs @@ -196,91 +196,14 @@ mod tests { rand::seq::SliceRandom, solana_runtime::{ snapshot_archive_info::SnapshotArchiveInfo, - snapshot_bank_utils, snapshot_hash::SnapshotHash, snapshot_package::{SnapshotKind, SnapshotPackage}, - snapshot_utils::{self, ArchiveFormat, SnapshotVersion}, + snapshot_utils::{ArchiveFormat, SnapshotVersion}, }, - solana_sdk::{clock::Slot, genesis_config::GenesisConfig, hash::Hash}, - std::{ - fs::{self, remove_dir_all}, - path::{Path, PathBuf}, - time::Instant, - }, - tempfile::TempDir, + solana_sdk::{clock::Slot, hash::Hash}, + std::{path::PathBuf, time::Instant}, }; - // Create temporary placeholder directory for all test files - fn make_tmp_dir_path() -> PathBuf { - let out_dir = std::env::var("FARF_DIR").unwrap_or_else(|_| "farf".to_string()); - let path = PathBuf::from(format!("{out_dir}/tmp/test_package_snapshots")); - - // whack any possible collision - let _ignored = std::fs::remove_dir_all(&path); - // whack any possible collision - let _ignored = std::fs::remove_file(&path); - - path - } - - #[test] - fn test_package_snapshots_relative_ledger_path() { - let temp_dir = make_tmp_dir_path(); - create_and_verify_snapshot(&temp_dir); - remove_dir_all(temp_dir).expect("should remove tmp dir"); - } - - #[test] - fn test_package_snapshots() { - create_and_verify_snapshot(TempDir::new().unwrap().path()) - } - - fn create_and_verify_snapshot(temp_dir: &Path) { - let bank_snapshots_dir = temp_dir.join("snapshots"); - fs::create_dir_all(&bank_snapshots_dir).unwrap(); - let full_snapshot_archives_dir = temp_dir.join("full_snapshot_archives"); - let incremental_snapshot_archives_dir = temp_dir.join("incremental_snapshot_archives"); - fs::create_dir_all(&full_snapshot_archives_dir).unwrap(); - fs::create_dir_all(&incremental_snapshot_archives_dir).unwrap(); - - let num_snapshots = 1; - - let genesis_config = GenesisConfig::default(); - let bank = snapshot_bank_utils::create_snapshot_dirs_for_tests( - &genesis_config, - &bank_snapshots_dir, - num_snapshots, - num_snapshots, - ); - - let bank_snapshot_info = - snapshot_utils::get_highest_bank_snapshot(&bank_snapshots_dir).unwrap(); - let snapshot_storages = bank.get_snapshot_storages(None); - let archive_format = ArchiveFormat::Tar; - - let full_archive = snapshot_bank_utils::package_and_archive_full_snapshot( - &bank, - &bank_snapshot_info, - full_snapshot_archives_dir, - incremental_snapshot_archives_dir, - snapshot_storages, - archive_format, - SnapshotVersion::default(), - snapshot_utils::DEFAULT_MAX_FULL_SNAPSHOT_ARCHIVES_TO_RETAIN, - snapshot_utils::DEFAULT_MAX_INCREMENTAL_SNAPSHOT_ARCHIVES_TO_RETAIN, - ) - .unwrap(); - - // Check archive is correct - snapshot_utils::verify_snapshot_archive( - full_archive.path(), - bank_snapshots_dir, - archive_format, - snapshot_utils::VerifyBank::Deterministic, - bank_snapshot_info.slot, - ); - } - /// Ensure that unhandled snapshot packages are properly re-enqueued or dropped /// /// The snapshot package handler should re-enqueue unhandled snapshot packages, if those