@@ -20,6 +20,7 @@ use std::collections::hash_map;
2020use std:: collections:: HashMap ;
2121use std:: env;
2222use std:: io:: { self , Write } ;
23+ use std:: path:: PathBuf ;
2324use std:: sync:: atomic:: { AtomicBool , Ordering } ;
2425use std:: sync:: Arc ;
2526use std:: sync:: Mutex ;
@@ -220,10 +221,12 @@ impl Logger for TestLogger {
220221 }
221222}
222223
223- pub fn random_storage_path ( ) -> String {
224+ pub fn random_storage_path ( ) -> PathBuf {
225+ let mut temp_path = std:: env:: temp_dir ( ) ;
224226 let mut rng = thread_rng ( ) ;
225227 let rand_dir: String = ( 0 ..7 ) . map ( |_| rng. sample ( Alphanumeric ) as char ) . collect ( ) ;
226- format ! ( "/tmp/{}" , rand_dir)
228+ temp_path. push ( rand_dir) ;
229+ temp_path
227230}
228231
229232pub fn random_port ( ) -> u16 {
@@ -238,8 +241,8 @@ pub fn random_config() -> Config {
238241 println ! ( "Setting network: {}" , config. network) ;
239242
240243 let rand_dir = random_storage_path ( ) ;
241- println ! ( "Setting random LDK storage dir: {}" , rand_dir) ;
242- config. storage_dir_path = rand_dir;
244+ println ! ( "Setting random LDK storage dir: {}" , rand_dir. display ( ) ) ;
245+ config. storage_dir_path = rand_dir. to_str ( ) . unwrap ( ) . to_owned ( ) ;
243246
244247 let rand_port = random_port ( ) ;
245248 println ! ( "Setting random LDK listening port: {}" , rand_port) ;
0 commit comments