From 340da08fb4d86b26850124aee16fb0c4f6a15bd1 Mon Sep 17 00:00:00 2001 From: qima Date: Fri, 8 Nov 2024 06:54:20 +0800 Subject: [PATCH] WIP --- .github/workflows/merge.yml | 8 ++++++++ sn_networking/src/record_store.rs | 15 +++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index 6e7a7e117e..99c9e58719 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -130,10 +130,18 @@ jobs: - name: Run network tests (with encrypt-records) timeout-minutes: 25 + run: cargo test --release --package sn_networking --features="open-metrics, encrypt-records" -- --skip can_store_after_restart + + - name: Run network tests (with encrypt-records) + timeout-minutes: 5 run: cargo test --release --package sn_networking --features="open-metrics, encrypt-records" can_store_after_restart - name: Run network tests (without encrypt-records) timeout-minutes: 25 + run: cargo test --release --package sn_networking --features="open-metrics" -- --skip can_store_after_restart + + - name: Run network tests (without encrypt-records) + timeout-minutes: 5 run: cargo test --release --package sn_networking --features="open-metrics" can_store_after_restart - name: Run protocol tests diff --git a/sn_networking/src/record_store.rs b/sn_networking/src/record_store.rs index c6dd99cc53..15ecb5ec09 100644 --- a/sn_networking/src/record_store.rs +++ b/sn_networking/src/record_store.rs @@ -452,7 +452,7 @@ impl NodeRecordStore { return Some(Cow::Owned(record)); } Err(error) => { - error!("Error while decrypting record. key: {key:?}: {error:?}"); + println!("Error while decrypting record. key: {key:?}: {error:?}"); None } } @@ -1043,7 +1043,7 @@ mod tests { use bls::SecretKey; use xor_name::XorName; - use assert_fs::TempDir; + use assert_fs::{fixture::{PathChild, PathCreateDir}, TempDir}; use bytes::Bytes; use eyre::{bail, ContextCompat}; use libp2p::kad::K_VALUE; @@ -1246,9 +1246,12 @@ mod tests { #[tokio::test] async fn can_store_after_restart() -> eyre::Result<()> { - let temp_dir = TempDir::new().expect("Should be able to create a temp dir."); + let tmp_dir = TempDir::new()?; + let current_test_dir = tmp_dir.child("can_store_after_restart"); + current_test_dir.create_dir_all()?; + let store_config = NodeRecordStoreConfig { - storage_dir: temp_dir.to_path_buf(), + storage_dir: current_test_dir.to_path_buf(), encryption_seed: [1u8; 16], ..Default::default() }; @@ -1289,7 +1292,7 @@ mod tests { assert!(stored_record.is_some(), "Chunk should be stored"); // Sleep a while to let OS completes the flush to disk - sleep(Duration::from_secs(10)).await; + sleep(Duration::from_secs(5)).await; // Restart the store with same encrypt_seed drop(store); @@ -1310,7 +1313,7 @@ mod tests { // Restart the store with different encrypt_seed let self_id_diff = PeerId::random(); let store_config_diff = NodeRecordStoreConfig { - storage_dir: temp_dir.to_path_buf(), + storage_dir: current_test_dir.to_path_buf(), encryption_seed: [2u8; 16], ..Default::default() };