fix: use tempdir when testing static files (#6962)

This commit is contained in:
Abner Zheng
2024-03-16 20:57:18 +08:00
committed by GitHub
parent 5e9e21dec5
commit 3b4726a714
10 changed files with 88 additions and 96 deletions

View File

@ -83,11 +83,11 @@ impl Case for BlockchainTestCase {
.try_for_each(|case| {
// Create a new test database and initialize a provider for the test case.
let db = create_test_rw_db();
let static_files_dir = create_test_static_files_dir();
let (_static_files_dir, static_files_dir_path) = create_test_static_files_dir();
let provider = ProviderFactory::new(
db.as_ref(),
Arc::new(case.network.clone().into()),
static_files_dir.clone(),
static_files_dir_path,
)?
.provider_rw()
.unwrap();
@ -169,11 +169,6 @@ impl Case for BlockchainTestCase {
// Drop the provider without committing to the database.
drop(provider);
// TODO: replace with `tempdir` usage, so the temp directory is removed
// automatically when the variable goes out of scope
reth_primitives::fs::remove_dir_all(static_files_dir)
.expect("Failed to remove static files directory");
Ok(())
})?;