mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-06 23:15:08 -04:00
fix(bindings): Withheld code mapping
This commit is contained in:
@@ -65,3 +65,4 @@ uniffi = { workspace = true, features = ["build"] }
|
||||
|
||||
[dev-dependencies]
|
||||
tempfile = "3.3.0"
|
||||
assert_matches = { workspace = true }
|
||||
|
||||
@@ -69,7 +69,7 @@ impl From<MegolmError> for DecryptionError {
|
||||
match value {
|
||||
MegolmError::MissingRoomKey(withheld_code) => Self::MissingRoomKey {
|
||||
error: "Withheld Inbound group session".to_owned(),
|
||||
withheld_code: withheld_code.map(|w| w.to_string()),
|
||||
withheld_code: withheld_code.map(|w| w.as_str().to_owned()),
|
||||
},
|
||||
_ => Self::Megolm { error: value.to_string() },
|
||||
}
|
||||
@@ -93,3 +93,26 @@ impl From<InnerStoreError> for DecryptionError {
|
||||
Self::Store { error: err.to_string() }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
use assert_matches::assert_matches;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_withheld_error_mapping() {
|
||||
use matrix_sdk_crypto::types::events::room_key_withheld::WithheldCode;
|
||||
|
||||
let inner_error = MegolmError::MissingRoomKey(Some(WithheldCode::Unverified));
|
||||
|
||||
let binding_error: DecryptionError = inner_error.into();
|
||||
|
||||
let code = assert_matches!(
|
||||
binding_error,
|
||||
DecryptionError::MissingRoomKey { error: _, withheld_code: Some(withheld_code) } => withheld_code
|
||||
);
|
||||
assert_eq!("m.unverified", code)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user