caretta-sync/core/src/tests.rs

26 lines
842 B
Rust
Raw Normal View History

2025-05-30 09:26:47 +09:00
use std::{path::PathBuf, sync::LazyLock};
use tempfile::TempDir;
use url::Url;
2025-09-03 13:22:31 +09:00
use crate::{ config::{Config, PartialConfig, PartialIrohConfig, PartialRpcConfig, RpcConfig, StorageConfig}};
2025-06-19 07:24:44 +09:00
use serde::{de::DeserializeOwned, Deserialize, Serialize};
2025-08-20 06:50:35 +09:00
pub static TEST_CONFIG: LazyLock<Config> = LazyLock::new(|| {
let test_dir = TempDir::new().unwrap().keep();
let data_dir = test_dir.join("data");
let cache_dir = test_dir.join("cache");
2025-05-30 09:26:47 +09:00
2025-08-20 06:50:35 +09:00
Config {
2025-09-03 13:22:31 +09:00
iroh: PartialIrohConfig::default().with_new_secret_key().try_into().unwrap(),
2025-08-20 06:50:35 +09:00
storage: StorageConfig {
data_directory: data_dir,
cache_directory: cache_dir,
},
2025-08-23 08:55:25 +09:00
rpc: RpcConfig{
endpoint_url: Url::parse(&(String::from("unix://") + test_dir.join("socket.sock").to_str().unwrap())).unwrap(),
2025-08-23 08:55:25 +09:00
},
2025-08-20 06:50:35 +09:00
}
2025-05-30 09:26:47 +09:00
});