Skip to content

Commit 8a111a1

Browse files
committed
f test struct docs
1 parent 1f4df39 commit 8a111a1

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lightning/src/util/test_utils.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,12 @@ impl Future for OneShotChannel {
874874
}
875875
}
876876

877+
/// An in-memory KVStore for testing.
878+
///
879+
/// Sync writes always complete immediately while async writes always block until manually
880+
/// completed with [`Self::complete_async_writes_through`] or [`Self::complete_all_async_writes`].
881+
///
882+
/// Removes always complete immediately.
877883
pub struct TestStore {
878884
pending_async_writes: Mutex<HashMap<String, Vec<(usize, OneShotChannelState, Vec<u8>)>>>,
879885
persisted_bytes: Mutex<HashMap<String, HashMap<String, Vec<u8>>>>,
@@ -898,6 +904,8 @@ impl TestStore {
898904
.unwrap_or(Vec::new())
899905
}
900906

907+
/// Completes all pending async writes for the given namespace and key, up to and through the
908+
/// given `write_id` (which can be fetched from [`Self::list_pending_async_writes`]).
901909
pub fn complete_async_writes_through(
902910
&self, primary_namespace: &str, secondary_namespace: &str, key: &str, write_id: usize,
903911
) {
@@ -924,6 +932,7 @@ impl TestStore {
924932
});
925933
}
926934

935+
/// Completes all pending async writes on all namespaces and keys.
927936
pub fn complete_all_async_writes(&self) {
928937
let pending_writes: Vec<String> =
929938
self.pending_async_writes.lock().unwrap().keys().cloned().collect();

0 commit comments

Comments
 (0)