From 6ad623f7955722dcfe971a29faed523b379bd4e9 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Fri, 18 Oct 2024 10:12:34 +0100 Subject: [PATCH] fixup! crypto: Extract a test helper function for simulating verification Convert comment to code example --- .../matrix-sdk-crypto/src/identities/user.rs | 31 ++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/crates/matrix-sdk-crypto/src/identities/user.rs b/crates/matrix-sdk-crypto/src/identities/user.rs index 925ff855492..bb8209439d0 100644 --- a/crates/matrix-sdk-crypto/src/identities/user.rs +++ b/crates/matrix-sdk-crypto/src/identities/user.rs @@ -1283,7 +1283,12 @@ pub(crate) mod testing { /// signature_upload_request will be the result of calling /// [`super::OtherUserIdentity::verify`]. /// - /// msk_json should be JSON like: { + /// # Example + /// + /// ```no_run + /// let signature_upload_request = their_identity.verify().await.unwrap(); + /// + /// let msk_json = json!({ /// "their_user_id": { /// "keys": { "ed25519:blah": "blah" } /// "signatures": { @@ -1292,9 +1297,9 @@ pub(crate) mod testing { /// "usage": [ "master" ], /// "user_id": "their_user_id" /// } - /// } + /// }); /// - /// ssk_json should be JSON like: { + /// let ssk_json = json!({ /// "their_user_id": { /// "keys": { "ed25519:blah": "blah" }, /// "signatures": { @@ -1303,7 +1308,25 @@ pub(crate) mod testing { /// "usage": [ "self_signing" ], /// "user_id": "their_user_id" /// } - /// } + /// }) + /// + /// let response = simulate_key_query_response_for_verification( + /// signature_upload_request, + /// my_identity, + /// my_user_id, + /// their_user_id, + /// msk_json, + /// ssk_json + /// ).await; + /// + /// olm_machine + /// .mark_request_as_sent( + /// &TransactionId::new(), + /// crate::IncomingResponse::KeysQuery(&kq_response), + /// ) + /// .await + /// .unwrap(); + /// ``` pub fn simulate_key_query_response_for_verification( signature_upload_request: SignatureUploadRequest, my_identity: OwnUserIdentity,