Shorten the paths to the dummy datadirs in the unit tests

It failed CI on MacOS because of overflowing SUN_PATH_LEN.
This commit is contained in:
Antoine Poinsot 2022-08-11 15:07:32 +02:00
parent 069bca546a
commit fe5de96312
No known key found for this signature in database
GPG Key ID: E13FC145CD3F4304
2 changed files with 4 additions and 9 deletions

View File

@ -401,7 +401,7 @@ mod tests {
let ms = DummyMinisafe::new();
let socket_path: path::PathBuf = [
ms.tmp_dir.as_path(),
path::Path::new("datadir"),
path::Path::new("d"),
path::Path::new("bitcoin"),
path::Path::new("minisafed_rpc"),
]

View File

@ -92,13 +92,9 @@ fn uid() -> usize {
pub fn tmp_dir() -> path::PathBuf {
env::temp_dir().join(format!(
"minisafed-unit-tests-{}-{:?}-{}-{}",
"minisafed-{}-{:?}-{}",
process::id(),
thread::current().id(),
time::SystemTime::now()
.duration_since(time::UNIX_EPOCH)
.unwrap()
.subsec_nanos(),
uid(),
))
}
@ -107,9 +103,8 @@ impl DummyMinisafe {
pub fn new() -> DummyMinisafe {
let tmp_dir = tmp_dir();
fs::create_dir_all(&tmp_dir).unwrap();
let data_dir: path::PathBuf = [tmp_dir.as_path(), path::Path::new("datadir")]
.iter()
.collect();
// Use a shorthand for 'datadir', to avoid overflowing SUN_LEN on MacOS.
let data_dir: path::PathBuf = [tmp_dir.as_path(), path::Path::new("d")].iter().collect();
let network = bitcoin::Network::Bitcoin;
let bitcoin_config = BitcoinConfig {