Skip to content

Commit 176ac00

Browse files
committed
Keep store unit test out of integration tests
The in-memory store source is shared by the library test utilities and integration-test helpers. Keep its unit test in the library-only module so each integration binary does not register and rerun it. Co-Authored-By: HAL 9000
1 parent cb799ae commit 176ac00

2 files changed

Lines changed: 27 additions & 26 deletions

File tree

src/io/in_memory_store.rs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -222,29 +222,3 @@ impl MigratableKVStore for InMemoryStore {
222222

223223
unsafe impl Sync for InMemoryStore {}
224224
unsafe impl Send for InMemoryStore {}
225-
226-
#[cfg(test)]
227-
mod tests {
228-
use super::*;
229-
230-
#[tokio::test]
231-
async fn in_memory_store_list_all_keys() {
232-
let store = InMemoryStore::new();
233-
234-
KVStore::write(&store, "ns_a", "sub_a", "key_a", vec![1u8]).await.unwrap();
235-
KVStore::write(&store, "ns_a", "sub_b", "key_b", vec![2u8]).await.unwrap();
236-
KVStore::write(&store, "ns_b", "", "key_c", vec![3u8]).await.unwrap();
237-
238-
let mut keys = MigratableKVStore::list_all_keys(&store).await.unwrap();
239-
keys.sort();
240-
241-
assert_eq!(
242-
keys,
243-
vec![
244-
("ns_a".to_string(), "sub_a".to_string(), "key_a".to_string()),
245-
("ns_a".to_string(), "sub_b".to_string(), "key_b".to_string()),
246-
("ns_b".to_string(), "".to_string(), "key_c".to_string()),
247-
]
248-
);
249-
}
250-
}

src/io/test_utils.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,33 @@ const EXPECTED_UPDATES_PER_PAYMENT: u64 = 5;
161161

162162
pub(crate) use in_memory_store::InMemoryStore;
163163

164+
#[cfg(test)]
165+
mod tests {
166+
use super::InMemoryStore;
167+
use lightning::util::persist::{KVStore, MigratableKVStore};
168+
169+
#[tokio::test]
170+
async fn in_memory_store_list_all_keys() {
171+
let store = InMemoryStore::new();
172+
173+
KVStore::write(&store, "ns_a", "sub_a", "key_a", vec![1u8]).await.unwrap();
174+
KVStore::write(&store, "ns_a", "sub_b", "key_b", vec![2u8]).await.unwrap();
175+
KVStore::write(&store, "ns_b", "", "key_c", vec![3u8]).await.unwrap();
176+
177+
let mut keys = MigratableKVStore::list_all_keys(&store).await.unwrap();
178+
keys.sort();
179+
180+
assert_eq!(
181+
keys,
182+
vec![
183+
("ns_a".to_string(), "sub_a".to_string(), "key_a".to_string()),
184+
("ns_a".to_string(), "sub_b".to_string(), "key_b".to_string()),
185+
("ns_b".to_string(), "".to_string(), "key_c".to_string()),
186+
]
187+
);
188+
}
189+
}
190+
164191
pub(crate) fn random_storage_path() -> PathBuf {
165192
let mut temp_path = std::env::temp_dir();
166193
let mut rng = rng();

0 commit comments

Comments
 (0)