From 22e4c6b79ed201ab40d30135df31994b2f8b9cc4 Mon Sep 17 00:00:00 2001 From: Xiang Zhu Date: Fri, 18 Nov 2022 21:08:04 -0800 Subject: [PATCH] Fix concurrent_snapshot_packaging test --- core/tests/snapshots.rs | 17 +---------------- runtime/src/snapshot_utils.rs | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/core/tests/snapshots.rs b/core/tests/snapshots.rs index f18f11d0fa0c87..f24aa3883d6c2d 100644 --- a/core/tests/snapshots.rs +++ b/core/tests/snapshots.rs @@ -1,7 +1,6 @@ #![allow(clippy::integer_arithmetic)] use { - bincode::serialize_into, crossbeam_channel::unbounded, fs_extra::dir::CopyOptions, itertools::Itertools, @@ -18,7 +17,7 @@ use { }, accounts_db::{self, ACCOUNTS_DB_CONFIG_FOR_TESTING}, accounts_index::AccountSecondaryIndexes, - bank::{Bank, BankSlotDelta}, + bank::Bank, bank_forks::BankForks, epoch_accounts_hash::EpochAccountsHash, genesis_utils::{create_genesis_config_with_leader, GenesisConfigInfo}, @@ -552,20 +551,6 @@ fn test_concurrent_snapshot_packaging( // Check the archive we cached the state for earlier was generated correctly - // before we compare, stick an empty status_cache in this dir so that the package comparison works - // This is needed since the status_cache is added by the packager and is not collected from - // the source dir for snapshots - snapshot_utils::serialize_snapshot_data_file( - &saved_snapshots_dir - .path() - .join(snapshot_utils::SNAPSHOT_STATUS_CACHE_FILENAME), - |stream| { - serialize_into(stream, &[] as &[BankSlotDelta])?; - Ok(()) - }, - ) - .unwrap(); - // files were saved off before we reserialized the bank in the hacked up accounts_hash_verifier stand-in. solana_runtime::serde_snapshot::reserialize_bank_with_new_accounts_hash( saved_snapshots_dir.path(), diff --git a/runtime/src/snapshot_utils.rs b/runtime/src/snapshot_utils.rs index 7b52510860c313..9a78b98eabd776 100644 --- a/runtime/src/snapshot_utils.rs +++ b/runtime/src/snapshot_utils.rs @@ -2587,6 +2587,22 @@ pub fn verify_snapshot_archive( assert!(crate::serde_snapshot::compare_two_serialized_banks(&p1, &p2).unwrap()); std::fs::remove_file(p1).unwrap(); std::fs::remove_file(p2).unwrap(); + + // The new the status_cache file is inside the slot directory together with the snapshot file. + // When unpacking an archive, the status_cache file from the archive is one-level up outside of + // the slot direcotry. + // The unpacked status_cache file need to be put back into the slot directory for the directory + // comparison to pass. + let existing_unpacked_status_cache_file = + unpacked_snapshots.join(SNAPSHOT_STATUS_CACHE_FILENAME); + let new_unpacked_status_cache_file = unpacked_snapshots + .join(&slot) + .join(SNAPSHOT_STATUS_CACHE_FILENAME); + fs::rename( + existing_unpacked_status_cache_file, + new_unpacked_status_cache_file, + ) + .unwrap(); } assert!(!dir_diff::is_different(&snapshots_to_verify, unpacked_snapshots).unwrap());