Skip to content

Commit a1417c2

Browse files
committed
tests corrrectly use a temp dir
1 parent 2d4550e commit a1417c2

5 files changed

Lines changed: 13 additions & 3 deletions

File tree

dash-spv/src/network/manager.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ impl PeerNetworkManager {
8080

8181
let discovery = DnsDiscovery::new().await?;
8282
let data_dir = config.storage_path.clone().unwrap_or_else(|| PathBuf::from("."));
83+
8384
let peer_store = PersistentPeerStorage::open(data_dir.clone()).await?;
8485

8586
let reputation_manager = Arc::new(PeerReputationManager::new());

dash-spv/src/storage/peers.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ impl PersistentPeerStorage {
5555
#[async_trait]
5656
impl PersistentStorage for PersistentPeerStorage {
5757
async fn open(storage_path: impl Into<PathBuf> + Send) -> StorageResult<Self> {
58+
let storage_path = storage_path.into();
59+
5860
Ok(PersistentPeerStorage {
59-
storage_path: storage_path.into().join(Self::FOLDER_NAME),
61+
storage_path: storage_path.join(Self::FOLDER_NAME),
6062
})
6163
}
6264

dash-spv/tests/handshake_test.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ async fn test_handshake_timeout() {
7272

7373
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
7474
async fn test_network_manager_creation() {
75-
let config = ClientConfig::new(Network::Dash);
75+
let temp_dir = tempfile::TempDir::new().expect("Failed to create temporary directory");
76+
let config = ClientConfig::new(Network::Dash).with_storage_path(temp_dir.path().to_path_buf());
7677
let network = PeerNetworkManager::new(&config).await;
7778

7879
assert!(network.is_ok(), "Network manager creation should succeed");

dash-spv/tests/header_sync_test.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,11 @@ async fn test_header_sync_performance() {
261261
#[tokio::test]
262262
async fn test_header_sync_with_client_integration() {
263263
let _ = env_logger::try_init();
264+
let temp_dir = tempfile::TempDir::new().expect("Failed to create temporary directory");
264265

265266
// Test header sync integration with the full client
266267
let config = ClientConfig::new(Network::Dash)
268+
.with_storage_path(temp_dir.path().to_path_buf())
267269
.with_validation_mode(ValidationMode::Basic)
268270
.with_connection_timeout(Duration::from_secs(10));
269271

dash-spv/tests/wallet_integration_test.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ use key_wallet_manager::wallet_manager::WalletManager;
1515
/// Create a test SPV client with memory storage for integration testing.
1616
async fn create_test_client(
1717
) -> DashSpvClient<WalletManager<ManagedWalletInfo>, PeerNetworkManager, DiskStorageManager> {
18-
let config = ClientConfig::testnet().without_filters().without_masternodes();
18+
let temp_dir = tempfile::TempDir::new().expect("Failed to create temporary directory");
19+
let config = ClientConfig::testnet()
20+
.without_filters()
21+
.without_masternodes()
22+
.with_storage_path(temp_dir.path().to_path_buf());
1923

2024
// Create network manager
2125
let network_manager = PeerNetworkManager::new(&config).await.unwrap();

0 commit comments

Comments
 (0)