send queue

This commit is contained in:
yves committed 2026-11-20 23:09:05 +01:00
1 parent a520ddb557
commit 10af480218
10 files changed
+701 -60

No files matched your search

+46
View File
@@ -371,3 +371,49 @@ fn schema_versions_and_foreign_files() {
));
let _ = std::fs::remove_dir_all(dir);
}
#[test]
fn outbox_items_persist_per_space() {
let (path, dir) = tmp();
let s = server();
let bob = contact("bob", &s);
let item = |n: u8, data: Vec<u8>| meow_store::OutboxItem {
id: vec![n; 16],
contact: bob.id.clone(),
message_id: vec![n; 16],
deposit: data,
pending: vec![s.clone()],
accepted: 0,
attempts: 0,
created_at: 1,
next_attempt: 1,
};
let mut store = Store::create(&path, "alice", "pw", KDF, false).unwrap();
let mut state = store.load(MAIN).unwrap();
state.contacts.push(bob.clone());
// A large deposit spans several blocks.
state.outbox = vec![item(1, vec![7; 10_000]), item(2, b"small".to_vec())];
store.save(MAIN, &state, Batch::default()).unwrap();
let h = store.create_space("hidden").unwrap();
drop(store);
let mut store = Store::open(&path, "pw").unwrap();
let mut loaded = store.load(MAIN).unwrap();
assert_eq!(loaded.outbox, state.outbox);
// Update one, drop the other.
loaded.outbox.retain(|o| o.id[0] == 1);
loaded.outbox[0].attempts = 3;
store.save(MAIN, &loaded, Batch::default()).unwrap();
drop(store);
let mut store = Store::open(&path, "pw").unwrap();
let again = store.load(MAIN).unwrap();
assert_eq!(again.outbox.len(), 1);
assert_eq!(again.outbox[0].attempts, 3);
assert_eq!(again.outbox[0].deposit, vec![7; 10_000]);
// Other spaces have their own queue.
let h2 = store.unlock("hidden").unwrap().unwrap();
assert_eq!(h2, h);
assert!(store.load(h2).unwrap().outbox.is_empty());
let _ = std::fs::remove_dir_all(dir);
}