Merge branch 'main' of ssh://git.methanium.net/tensamin/iota

This commit is contained in:
Alex 2026-07-25 22:59:35 +02:00
commit 6b4c144b73
Signed by: alex
SSH key fingerprint: SHA256:D1+Ub8o0v4K5y1JNivW8IxEOelqLSvPmUzBbDIoZkRQ
7 changed files with 92 additions and 130 deletions

View file

@ -240,52 +240,4 @@ fn pending_forward_from_row(row: &rusqlite::Row<'_>) -> rusqlite::Result<Pending
})
}
#[cfg(test)]
mod tests {
use super::*;
fn suffix(name: &str) -> String {
let unix = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.unwrap_or_default()
.as_nanos();
format!("{name}-{unix}")
}
#[test]
fn stores_and_retrieves_chat_secret_blob_for_owner_chat() {
let user_id = suffix("user");
let chat_id = suffix("chat");
put_chat_secret(StoredChatSecret {
user_id: user_id.clone(),
chat_id: chat_id.clone(),
secret_id: "main".to_string(),
version: 1,
encrypted_secret: vec![42, 43],
kem_ciphertext: vec![9, 8, 7],
wrapping_scheme: "mtp-kem-chacha20poly1305-hkdf-sha256-v1".to_string(),
created_at: 1,
updated_at: 2,
})
.unwrap();
let found = get_chat_secret(ChatSecretQuery {
user_id: user_id.clone(),
chat_id: chat_id.clone(),
secret_id: Some("main".to_string()),
})
.unwrap()
.unwrap();
assert_eq!(found.encrypted_secret, vec![42, 43]);
assert_eq!(found.kem_ciphertext, vec![9, 8, 7]);
let denied = get_chat_secret(ChatSecretQuery {
user_id: suffix("other-user"),
chat_id,
secret_id: Some("main".to_string()),
})
.unwrap();
assert!(denied.is_none());
}
}