From 3fa841496ea4f4acdffa9f724076876f376b1d7f Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Thu, 18 Feb 2021 14:37:43 -0500 Subject: [PATCH] temp paths --- lightning-persister/src/lib.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lightning-persister/src/lib.rs b/lightning-persister/src/lib.rs index 0febc0cef..a9c0850a8 100644 --- a/lightning-persister/src/lib.rs +++ b/lightning-persister/src/lib.rs @@ -197,14 +197,20 @@ mod tests { } } + fn get_temp_path(name: &str) -> String { + let mut path = std::env::temp_dir(); + path.push(name); + path.to_str().unwrap().to_string() + } + // Integration-test the FilesystemPersister. Test relaying a few payments // and check that the persisted data is updated the appropriate number of // times. #[test] fn test_filesystem_persister() { // Create the nodes, giving them FilesystemPersisters for data persisters. - let persister_0 = FilesystemPersister::new("test_filesystem_persister_0".to_string()); - let persister_1 = FilesystemPersister::new("test_filesystem_persister_1".to_string()); + let persister_0 = FilesystemPersister::new(get_temp_path("test_filesystem_persister_0")); + let persister_1 = FilesystemPersister::new(get_temp_path("test_filesystem_persister_1")); let chanmon_cfgs = create_chanmon_cfgs(2); let mut node_cfgs = create_node_cfgs(2, &chanmon_cfgs); let chain_mon_0 = test_utils::TestChainMonitor::new(Some(&chanmon_cfgs[0].chain_source), &chanmon_cfgs[0].tx_broadcaster, &chanmon_cfgs[0].logger, &chanmon_cfgs[0].fee_estimator, &persister_0, &node_cfgs[0].keys_manager); @@ -273,7 +279,7 @@ mod tests { #[cfg(not(target_os = "windows"))] #[test] fn test_readonly_dir_perm_failure() { - let persister = FilesystemPersister::new("test_readonly_dir_perm_failure".to_string()); + let persister = FilesystemPersister::new(get_temp_path("test_readonly_dir_perm_failure")); fs::create_dir_all(&persister.path_to_channel_data).unwrap(); // Set up a dummy channel and force close. This will produce a monitor -- 2.39.5