diff --git a/matrix_sdk/src/client.rs b/matrix_sdk/src/client.rs index 74f47a2f..548f3a4c 100644 --- a/matrix_sdk/src/client.rs +++ b/matrix_sdk/src/client.rs @@ -74,7 +74,7 @@ pub struct Client { pub(crate) base_client: BaseClient, } -// #[cfg_attr(tarpaulin, skip)] +#[cfg(not(tarpaulin_include))] impl Debug for Client { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> StdResult<(), fmt::Error> { write!(fmt, "Client {{ homeserver: {} }}", self.homeserver) @@ -115,7 +115,7 @@ pub struct ClientConfig { timeout: Option, } -// #[cfg_attr(tarpaulin, skip)] +#[cfg(not(tarpaulin_include))] impl Debug for ClientConfig { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { let mut res = fmt.debug_struct("ClientConfig"); diff --git a/matrix_sdk_base/src/client.rs b/matrix_sdk_base/src/client.rs index 21168bf0..fc26e0a7 100644 --- a/matrix_sdk_base/src/client.rs +++ b/matrix_sdk_base/src/client.rs @@ -212,7 +212,7 @@ pub struct BaseClient { store_passphrase: Arc>, } -// #[cfg_attr(tarpaulin, skip)] +#[cfg(not(tarpaulin_include))] impl fmt::Debug for BaseClient { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") @@ -246,7 +246,7 @@ pub struct BaseClientConfig { passphrase: Option>, } -// #[cfg_attr(tarpaulin, skip)] +#[cfg(not(tarpaulin_include))] impl std::fmt::Debug for BaseClientConfig { fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> StdResult<(), std::fmt::Error> { fmt.debug_struct("BaseClientConfig").finish() diff --git a/matrix_sdk_crypto/src/device.rs b/matrix_sdk_crypto/src/device.rs index 62a54bb8..eafb193b 100644 --- a/matrix_sdk_crypto/src/device.rs +++ b/matrix_sdk_crypto/src/device.rs @@ -198,7 +198,7 @@ impl Device { #[cfg(test)] pub async fn from_machine(machine: &OlmMachine) -> Device { - Device::from_account(&machine.account).await + Device::from_account(machine.account()).await } #[cfg(test)] diff --git a/matrix_sdk_crypto/src/machine.rs b/matrix_sdk_crypto/src/machine.rs index e7332096..73adde35 100644 --- a/matrix_sdk_crypto/src/machine.rs +++ b/matrix_sdk_crypto/src/machine.rs @@ -75,7 +75,7 @@ pub struct OlmMachine { /// The unique device id of the device that holds this account. device_id: Box, /// Our underlying Olm Account holding our identity keys. - pub(crate) account: Account, + account: Account, /// Store for the encryption keys. /// Persists all the encryption keys so a client can resume the session /// without the need to create new keys. @@ -87,7 +87,7 @@ pub struct OlmMachine { verification_machine: VerificationMachine, } -// #[cfg_attr(tarpaulin, skip)] +#[cfg(not(tarpaulin_include))] impl std::fmt::Debug for OlmMachine { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("OlmMachine") @@ -214,6 +214,12 @@ impl OlmMachine { self.account.should_upload_keys().await } + /// Get the underlying Olm account of the machine. + #[cfg(test)] + pub(crate) fn account(&self) -> &Account { + &self.account + } + /// Update the count of one-time keys that are currently on the server. fn update_key_count(&self, count: u64) { self.account.update_uploaded_key_count(count); diff --git a/matrix_sdk_crypto/src/olm/account.rs b/matrix_sdk_crypto/src/olm/account.rs index a8cd18ee..5ee89216 100644 --- a/matrix_sdk_crypto/src/olm/account.rs +++ b/matrix_sdk_crypto/src/olm/account.rs @@ -63,7 +63,7 @@ pub struct Account { uploaded_signed_key_count: Arc, } -// #[cfg_attr(tarpaulin, skip)] +#[cfg(not(tarpaulin_include))] impl fmt::Debug for Account { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Account") diff --git a/matrix_sdk_crypto/src/olm/group_sessions.rs b/matrix_sdk_crypto/src/olm/group_sessions.rs index bbb36227..717877b6 100644 --- a/matrix_sdk_crypto/src/olm/group_sessions.rs +++ b/matrix_sdk_crypto/src/olm/group_sessions.rs @@ -222,7 +222,7 @@ impl InboundGroupSession { } } -// #[cfg_attr(tarpaulin, skip)] +#[cfg(not(tarpaulin_include))] impl fmt::Debug for InboundGroupSession { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("InboundGroupSession") @@ -401,7 +401,7 @@ impl OutboundGroupSession { } } -// #[cfg_attr(tarpaulin, skip)] +#[cfg(not(tarpaulin_include))] impl std::fmt::Debug for OutboundGroupSession { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("OutboundGroupSession") diff --git a/matrix_sdk_crypto/src/olm/session.rs b/matrix_sdk_crypto/src/olm/session.rs index 07a3339a..a4f31a32 100644 --- a/matrix_sdk_crypto/src/olm/session.rs +++ b/matrix_sdk_crypto/src/olm/session.rs @@ -51,7 +51,7 @@ pub struct Session { pub(crate) last_use_time: Arc, } -// #[cfg_attr(tarpaulin, skip)] +#[cfg(not(tarpaulin_include))] impl fmt::Debug for Session { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Session") diff --git a/matrix_sdk_crypto/src/store/sqlite.rs b/matrix_sdk_crypto/src/store/sqlite.rs index 1800a463..5fd4e3be 100644 --- a/matrix_sdk_crypto/src/store/sqlite.rs +++ b/matrix_sdk_crypto/src/store/sqlite.rs @@ -880,7 +880,7 @@ impl CryptoStore for SqliteStore { } } -// #[cfg_attr(tarpaulin, skip)] +#[cfg(not(tarpaulin_include))] impl std::fmt::Debug for SqliteStore { fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> StdResult<(), std::fmt::Error> { fmt.debug_struct("SqliteStore") diff --git a/matrix_sdk_crypto/src/verification/sas/sas_state.rs b/matrix_sdk_crypto/src/verification/sas/sas_state.rs index eaeb6bf3..80f3032e 100644 --- a/matrix_sdk_crypto/src/verification/sas/sas_state.rs +++ b/matrix_sdk_crypto/src/verification/sas/sas_state.rs @@ -98,6 +98,7 @@ impl TryFrom for AcceptedProtocols { } } +#[cfg(not(tarpaulin_include))] impl Default for AcceptedProtocols { fn default() -> Self { AcceptedProtocols { @@ -146,6 +147,7 @@ pub struct SasState { state: Arc, } +#[cfg(not(tarpaulin_include))] impl std::fmt::Debug for SasState { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("SasState")