From 27bd6fbf0e5142e1a9187fc1e4470a1d34681d28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Thu, 14 Dec 2023 19:48:27 +0000 Subject: [PATCH] test: use tempdirs for genesis artifacts --- apps/src/lib/config/genesis.rs | 4 ++-- apps/src/lib/node/ledger/shell/init_chain.rs | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/src/lib/config/genesis.rs b/apps/src/lib/config/genesis.rs index f7da635257..51eae935f6 100644 --- a/apps/src/lib/config/genesis.rs +++ b/apps/src/lib/config/genesis.rs @@ -311,7 +311,7 @@ pub struct Parameters { #[cfg(all(any(test, feature = "benches"), not(feature = "integration")))] pub fn make_dev_genesis( num_validators: u64, - target_chain_dir: std::path::PathBuf, + target_chain_dir: &std::path::Path, ) -> Finalized { use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use std::time::Duration; @@ -545,7 +545,7 @@ pub fn make_dev_genesis( // Write out the TOML files for benches #[cfg(feature = "benches")] genesis - .write_toml_files(&target_chain_dir) + .write_toml_files(target_chain_dir) .expect("Must be able to write the finalized genesis"); #[cfg(not(feature = "benches"))] let _ = target_chain_dir; // avoid unused warn diff --git a/apps/src/lib/node/ledger/shell/init_chain.rs b/apps/src/lib/node/ledger/shell/init_chain.rs index dce3ed0106..ca2ba5eb83 100644 --- a/apps/src/lib/node/ledger/shell/init_chain.rs +++ b/apps/src/lib/node/ledger/shell/init_chain.rs @@ -112,7 +112,7 @@ where ))] let genesis = { let chain_dir = self.base_dir.join(chain_id); - genesis::make_dev_genesis(_num_validators, chain_dir) + genesis::make_dev_genesis(_num_validators, &chain_dir) }; #[cfg(all( any(test, feature = "benches"), @@ -953,8 +953,8 @@ mod test { fn test_dry_run_lookup_vp() { let (mut shell, _x, _y, _z) = TestShell::new_at_height(0); shell.wasm_dir = PathBuf::new(); + let mut genesis = genesis::make_dev_genesis(1, &shell.base_dir); let mut initializer = InitChainValidation::new(&mut shell, true); - let mut genesis = genesis::make_dev_genesis(1, PathBuf::new()); let mut vp_cache = HashMap::new(); let code = initializer.lookup_vp("vp_user", &genesis, &mut vp_cache); @@ -996,8 +996,8 @@ mod test { let test_dir = tempfile::tempdir().unwrap(); shell.wasm_dir = test_dir.path().into(); + let genesis = genesis::make_dev_genesis(1, &shell.base_dir); let mut initializer = InitChainValidation::new(&mut shell, true); - let genesis = genesis::make_dev_genesis(1, PathBuf::new()); let res = initializer .store_wasms(&genesis.get_chain_parameters(PathBuf::new())); @@ -1062,8 +1062,8 @@ mod test { fn test_dry_run_init_token_balance() { let (mut shell, _x, _y, _z) = TestShell::new_at_height(0); shell.wasm_dir = PathBuf::new(); + let mut genesis = genesis::make_dev_genesis(1, &shell.base_dir); let mut initializer = InitChainValidation::new(&mut shell, true); - let mut genesis = genesis::make_dev_genesis(1, PathBuf::new()); let token_alias = Alias::from_str("apfel").unwrap(); genesis .tokens @@ -1088,8 +1088,8 @@ mod test { fn test_dry_run_genesis_bonds() { let (mut shell, _x, _y, _z) = TestShell::new_at_height(0); shell.wasm_dir = PathBuf::new(); + let mut genesis = genesis::make_dev_genesis(1, &shell.base_dir); let mut initializer = InitChainValidation::new(&mut shell, true); - let mut genesis = genesis::make_dev_genesis(1, PathBuf::new()); let default_addresses: HashMap = defaults::addresses().into_iter().collect(); let albert_address = if let Some(Address::Established(albert)) =