0
0
mirror of https://github.com/signalapp/libsignal.git synced 2024-09-19 11:32:17 +02:00

Format with group_imports=StdExternalCrate

This commit is contained in:
Alex Konradi 2024-08-28 14:52:47 -04:00 committed by GitHub
parent cbb649d07c
commit a54e6b5b33
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
219 changed files with 586 additions and 659 deletions

View File

@ -1 +1,2 @@
imports_granularity = "Module"
group_imports = "StdExternalCrate"

View File

@ -5,9 +5,9 @@
use std::collections::HashMap;
use crate::constants::ENCLAVE_ID_CDSI_STAGING_AND_PROD;
use prost::Message;
use crate::constants::ENCLAVE_ID_CDSI_STAGING_AND_PROD;
use crate::dcap;
use crate::enclave::{Handshake, Result};
use crate::proto::cds2;

View File

@ -3,6 +3,8 @@
// SPDX-License-Identifier: AGPL-3.0-only
//
use std::time::SystemTime;
use boring_signal::ec::EcKey;
use boring_signal::pkey::Public;
use boring_signal::stack::{Stack, Stackable};
@ -10,8 +12,6 @@ use boring_signal::x509::crl::X509CRLRef;
use boring_signal::x509::store::X509StoreRef;
use boring_signal::x509::{X509StoreContext, X509};
use std::time::SystemTime;
use crate::error::ContextError;
use crate::expireable::Expireable;
@ -162,7 +162,7 @@ impl Expireable for CertChain {
#[cfg(test)]
/// Utilities for creating test certificates / crls
pub mod testutil {
use super::CertChain;
use std::borrow::Borrow;
use boring_signal::asn1::{Asn1Integer, Asn1IntegerRef, Asn1Time};
use boring_signal::bn::{BigNum, MsbOption};
@ -173,7 +173,8 @@ pub mod testutil {
use boring_signal::x509::crl::{X509CRLBuilder, X509Revoked, X509CRL};
use boring_signal::x509::extension::BasicConstraints;
use boring_signal::x509::{X509Name, X509};
use std::borrow::Borrow;
use super::CertChain;
/// generate EC private key
fn pkey() -> PKey<Private> {
@ -309,15 +310,15 @@ pub mod testutil {
#[cfg(test)]
mod test {
use super::testutil::*;
use super::*;
use assert_matches::assert_matches;
use boring_signal::nid::Nid;
use boring_signal::x509::store::{X509Store, X509StoreBuilder};
use boring_signal::x509::verify::X509VerifyFlags;
use boring_signal::x509::X509Ref;
use super::testutil::*;
use super::*;
fn names(certs: &[X509]) -> Vec<String> {
certs
.iter()

View File

@ -22,7 +22,6 @@
// Curve signing key, using the NIST p-256 curve.
use std::collections::HashMap;
use std::time::SystemTime;
use boring_signal::asn1::{Asn1Time, Asn1TimeRef};
@ -651,12 +650,12 @@ mod test {
use std::time::{Duration, SystemTime};
use crate::dcap::endorsements::{QeTcbLevel, TcbInfoVersion};
use crate::dcap::fakes::FakeAttestation;
use boring_signal::bn::BigNum;
use hex_literal::hex;
use super::*;
use crate::dcap::endorsements::{QeTcbLevel, TcbInfoVersion};
use crate::dcap::fakes::FakeAttestation;
const EXPECTED_MRENCLAVE: MREnclave =
hex!("337ac97ce088a132daeb1308ea3159f807de4a827e875b2c90ce21bf4751196f");

View File

@ -8,6 +8,8 @@
//! through the Intel Provisioning Certification Service (PCS), or a cache (PCCS).
//! For specification of the json data structures within the OE structures,
//! see <https://api.portal.trustedservices.intel.com/documentation>
use std::time::SystemTime;
use boring_signal::ec::EcKeyRef;
use boring_signal::ecdsa::{EcdsaSig, EcdsaSigRef};
use boring_signal::pkey::Public;
@ -16,8 +18,6 @@ use serde::Deserialize;
use serde_json::value::RawValue;
use strum::EnumCount;
use std::time::SystemTime;
use crate::cert_chain::CertChain;
use crate::dcap::ecdsa::{deserialize_ecdsa_signature, EcdsaSigned};
use crate::dcap::revocation_list::RevocationList;

View File

@ -5,9 +5,10 @@
//! DCAP quote (Open Enclave "evidence"), ported from Open Enclave headers in v0.17.7.
use sha2::Digest;
use std::collections::HashMap;
use sha2::Digest;
use crate::dcap::sgx_quote::SgxQuote;
use crate::dcap::{Error, Expireable};
use crate::endian::UInt64LE;
@ -152,9 +153,10 @@ impl CustomClaims<'_> {
#[cfg(test)]
mod test {
use hex_literal::hex;
use super::*;
use crate::dcap::MREnclave;
use hex_literal::hex;
const EXPECTED_MRENCLAVE: MREnclave =
hex!("337ac97ce088a132daeb1308ea3159f807de4a827e875b2c90ce21bf4751196f");

View File

@ -12,13 +12,8 @@
//! 3. Manipulate the default evidence/endorsements
//! 4. Create the final evidence/endorsements with [`FakeAttestation::sign`]
use crate::cert_chain::testutil::TestCert;
use crate::cert_chain::CertChain;
use crate::dcap::ecdsa::EcdsaSigned;
use crate::dcap::endorsements::SgxEndorsements;
use crate::dcap::evidence::Evidence;
use crate::dcap::revocation_list::RevocationList;
use crate::dcap::{attest_impl, Attestation};
use std::time::SystemTime;
use boring_signal::asn1::{Asn1Integer, Asn1IntegerRef};
use boring_signal::bn::{BigNum, BigNumContext};
use boring_signal::ec::{EcGroup, EcKey, EcKeyRef};
@ -28,7 +23,13 @@ use boring_signal::nid::Nid;
use boring_signal::pkey::{PKey, Private, Public};
use chrono::Utc;
use std::time::SystemTime;
use crate::cert_chain::testutil::TestCert;
use crate::cert_chain::CertChain;
use crate::dcap::ecdsa::EcdsaSigned;
use crate::dcap::endorsements::SgxEndorsements;
use crate::dcap::evidence::Evidence;
use crate::dcap::revocation_list::RevocationList;
use crate::dcap::{attest_impl, Attestation};
const EVIDENCE_BYTES: &[u8] = include_bytes!("../../tests/data/dcap.evidence");
const ENDORSEMENT_BYTES: &[u8] = include_bytes!("../../tests/data/dcap.endorsements");

View File

@ -3,12 +3,14 @@
// SPDX-License-Identifier: AGPL-3.0-only
//
use crate::dcap::{Error, Expireable, Result};
use boring_signal::nid::Nid;
use boring_signal::x509::crl::{X509CRLRef, X509CRL};
use std::collections::HashSet;
use std::time::SystemTime;
use boring_signal::nid::Nid;
use boring_signal::x509::crl::{X509CRLRef, X509CRL};
use crate::dcap::{Error, Expireable, Result};
#[derive(Debug)]
pub(crate) struct RevocationList {
crl: X509CRL,

View File

@ -7,6 +7,8 @@
//!
//! See <https://download.01.org/intel-sgx/sgx-dcap/1.7/linux/docs/Intel_SGX_ECDSA_QuoteLibReference_DCAP_API.pdf> section A.4
use std::time::SystemTime;
use boring_signal::bn::BigNum;
use boring_signal::ec::{EcGroup, EcKey};
use boring_signal::ecdsa::{EcdsaSig, EcdsaSigRef};
@ -16,8 +18,6 @@ use boring_signal::pkey::Public;
use sha2::Digest;
use zerocopy::{AsBytes, FromBytes, FromZeroes};
use std::time::SystemTime;
use crate::cert_chain::CertChain;
use crate::dcap::ecdsa::{ecdsa_signature_from_bytes, EcdsaSigned};
use crate::dcap::sgx_report_body::SgxReportBody;
@ -325,13 +325,12 @@ static_assertions::const_assert_eq!(578, std::mem::size_of::<SgxEcdsaSignatureHe
#[cfg(test)]
mod tests {
use super::*;
use boring_signal::pkey::Private;
use std::fs;
use std::path::Path;
use boring_signal::pkey::Private;
use super::*;
use crate::cert_chain::testutil::cert_chain;
#[test]

View File

@ -5,12 +5,13 @@
use std::collections::HashMap;
use crate::dcap::{Error, Result};
use crate::error::Context;
use asn1::{oid, ObjectIdentifier, SequenceOf};
use boring_signal::asn1::Asn1ObjectRef;
use boring_signal::nid::Nid;
use crate::dcap::{Error, Result};
use crate::error::Context;
pub const SGX_EXTENSIONS_OID: &str = "1.2.840.113741.1.13.1";
const _SGX_EXTENSIONS_OID_OID: ObjectIdentifier = oid!(1, 2, 840, 113741, 1, 13, 1);
const PPID_OID: ObjectIdentifier = oid!(1, 2, 840, 113741, 1, 13, 1, 1);

View File

@ -6,12 +6,12 @@
use std::collections::HashMap;
use displaydoc::Display;
use prost::Message;
use crate::client_connection::ClientConnection;
use crate::svr2::RaftConfig;
use crate::tpm2snp::Tpm2Error;
use crate::{client_connection, dcap, nitro, proto, snow_resolver};
use prost::Message;
pub type Result<T> = std::result::Result<T, Error>;

View File

@ -7,9 +7,10 @@
#![warn(missing_docs)]
use log::*;
use std::fmt;
use log::*;
use crate::{client_connection, snow_resolver};
/// Error types for HSM enclave.

View File

@ -134,9 +134,10 @@ impl CertChain {
#[cfg(test)]
mod test {
use std::time::Duration;
use boring_signal::base64::decode_block;
use chrono::DateTime;
use std::time::Duration;
use super::*;

View File

@ -15,13 +15,12 @@ use prost::{DecodeError, Message};
use sha2::{Digest, Sha384};
use subtle::ConstantTimeEq;
use crate::constants::NITRO_EXPECTED_PCRS;
use crate::enclave::{self, Claims, Handshake};
use crate::proto;
use crate::svr2::RaftConfig;
use crate::util::SmallMap;
use crate::constants::NITRO_EXPECTED_PCRS;
// A type for Platform Configuration Register values
// They are Sha-384 hashes, 48 byte long.
// https://docs.aws.amazon.com/enclaves/latest/user/set-up-attestation.html#where

View File

@ -110,9 +110,8 @@ pub mod testutil {
mod tests {
use std::time::{Duration, SystemTime};
use crate::client_connection;
use super::*;
use crate::client_connection;
#[test]
fn test_clock_skew() {

View File

@ -3,11 +3,11 @@
// SPDX-License-Identifier: AGPL-3.0-only
//
use prost::Message;
use crate::constants::{
ACCEPTABLE_SW_ADVISORIES, DEFAULT_SW_ADVISORIES, EXPECTED_RAFT_CONFIG_SVR2,
};
use prost::Message;
use crate::enclave::{Error, Handshake, Result};
use crate::proto::svr;

View File

@ -11,13 +11,12 @@ use boring_signal::x509::X509;
use prost::Message;
use crate::cert_chain::{self, CertChain};
use crate::constants::TPM2SNP_EXPECTED_PCRS;
use crate::enclave::{Claims, Error, Handshake, Result, UnvalidatedHandshake};
use crate::expireable::Expireable as _;
use crate::proto::{svr, svr3};
use crate::svr2::RaftConfig;
use crate::constants::TPM2SNP_EXPECTED_PCRS;
mod snp;
mod tpm2;
@ -224,10 +223,12 @@ fn verify_tpm2_quote<'a>(
#[cfg(test)]
mod test {
use super::*;
use hex_literal::hex;
use std::time::Duration;
use hex_literal::hex;
use super::*;
#[test]
fn full_tpm2snp_attestation() {
let attestation_data = include_bytes!("../tests/data/tpm2snp_attestation_msg.dat");

View File

@ -358,11 +358,12 @@ impl<'a> View<'a> {
#[cfg(test)]
mod test {
use super::*;
use assert_matches::assert_matches;
use hex_literal::hex;
use test_case::test_case;
use super::*;
const VALID_SIGNATURE: &[u8] = include_bytes!("../../tests/data/tpm2_valid_signature.dat");
const VALID_REPORT: &[u8] = include_bytes!("../../tests/data/tpm2_valid_report.dat");
const VALID_PCRS: &[u8] = include_bytes!("../../tests/data/tpm2_valid_pcrs.dat");

View File

@ -97,9 +97,8 @@ pub(crate) fn system_time_to_asn1_time(
#[cfg(test)]
mod test {
use crate::endian::{UInt16LE, UInt32LE, UInt64LE};
use super::*;
use crate::endian::{UInt16LE, UInt32LE, UInt64LE};
#[test]
fn test_strip_trailing_null_byte() {

View File

@ -6,6 +6,9 @@
#![allow(clippy::missing_safety_doc)]
#![warn(clippy::unwrap_used)]
use std::ffi::{c_char, c_uchar, c_uint, CString};
use std::panic::AssertUnwindSafe;
use futures_util::FutureExt;
use libsignal_bridge::ffi::*;
#[cfg(feature = "libsignal-bridge-testing")]
@ -13,9 +16,6 @@ use libsignal_bridge::ffi::*;
use libsignal_bridge_testing::*;
use libsignal_protocol::*;
use std::ffi::{c_char, c_uchar, c_uint, CString};
use std::panic::AssertUnwindSafe;
pub mod logging;
#[no_mangle]

View File

@ -6,12 +6,10 @@
#![allow(clippy::missing_safety_doc)]
#![deny(clippy::unwrap_used)]
use jni::objects::{JByteArray, JClass, JLongArray, JObject, JString};
use jni::JNIEnv;
#[cfg(not(target_os = "android"))]
use jni::objects::{AutoLocal, JList, JMap, JValue};
use jni::objects::{JByteArray, JClass, JLongArray, JObject, JString};
use jni::JNIEnv;
use libsignal_bridge::jni::*;
use libsignal_bridge::jni_args;
use libsignal_bridge::net::TokioAsyncContext;

View File

@ -3,12 +3,13 @@
// SPDX-License-Identifier: AGPL-3.0-only
//
use std::panic::{catch_unwind, AssertUnwindSafe};
use std::process::abort;
use jni::objects::{AutoLocal, GlobalRef, JClass, JObject, JValue};
use jni::sys::jint;
use jni::{JNIEnv, JavaVM};
use libsignal_bridge::{describe_panic, jni_args};
use std::panic::{catch_unwind, AssertUnwindSafe};
use std::process::abort;
// Keep this in sync with SignalProtocolLogger.java, as well as the list below.
#[derive(Clone, Copy)]

View File

@ -3,12 +3,13 @@
// SPDX-License-Identifier: AGPL-3.0-only
//
use neon::prelude::*;
use std::future::Future;
use std::pin::Pin;
use std::sync::{Arc, Mutex};
use std::task::{Poll, Wake};
use neon::prelude::*;
/// Adds support for executing futures on a Neon [Channel][].
///
/// [Channel]: https://docs.rs/neon/0.9.0/neon/event/struct.Channel.html

View File

@ -3,7 +3,6 @@
// SPDX-License-Identifier: AGPL-3.0-only
//
use neon::prelude::*;
use std::future::Future;
use std::marker::PhantomData;
use std::mem;
@ -12,6 +11,8 @@ use std::pin::Pin;
use std::sync::{Arc, Mutex, Weak};
use std::task::{Poll, Waker};
use neon::prelude::*;
use crate::result::*;
use crate::util::call_method;

View File

@ -3,11 +3,12 @@
// SPDX-License-Identifier: AGPL-3.0-only
//
use std::future::Future;
use std::panic::{catch_unwind, AssertUnwindSafe, UnwindSafe};
use futures_util::FutureExt;
use neon::prelude::*;
use neon::types::JsPromise;
use std::future::Future;
use std::panic::{catch_unwind, AssertUnwindSafe, UnwindSafe};
use crate::executor::{AssertSendSafe, ChannelEx};
use crate::util::describe_panic;

View File

@ -3,9 +3,10 @@
// SPDX-License-Identifier: AGPL-3.0-only
//
use neon::prelude::*;
use std::any::Any;
use neon::prelude::*;
// See https://github.com/rust-lang/rfcs/issues/1389
pub(crate) fn describe_panic(any: &Box<dyn Any + Send>) -> String {
if let Some(msg) = any.downcast_ref::<&str>() {

View File

@ -3,9 +3,10 @@
// SPDX-License-Identifier: AGPL-3.0-only
//
use std::sync::Arc;
use neon::prelude::*;
use signal_neon_futures::*;
use std::sync::Arc;
mod panics_and_throws;
use panics_and_throws::*;

View File

@ -3,11 +3,11 @@
// SPDX-License-Identifier: AGPL-3.0-only
//
use futures_util::try_join;
use neon::prelude::*;
use std::panic::AssertUnwindSafe;
use std::sync::Arc;
use futures_util::try_join;
use neon::prelude::*;
use signal_neon_futures::*;
struct NameStore {

View File

@ -15,13 +15,13 @@ use minidump_unwind::Symbolizer;
use neon::prelude::*;
use neon::types::buffer::TypedArray;
mod logging;
// Import bridged functions. Without this, the compiler and/or linker are too
// smart and don't include the symbols in the library.
#[allow(unused)]
use libsignal_bridge_testing::*;
mod logging;
#[neon::main]
fn main(mut cx: ModuleContext) -> NeonResult<()> {
libsignal_bridge::node::register(&mut cx)?;

View File

@ -4,12 +4,11 @@
//
use ::signal_crypto;
use libsignal_bridge_macros::*;
use signal_crypto::{Aes256Ctr32, CryptographicHash, CryptographicMac, Error, Result};
use aes_gcm_siv::aead::generic_array::typenum::Unsigned;
use aes_gcm_siv::{AeadCore, AeadInPlace, KeyInit};
use libsignal_bridge_macros::*;
use libsignal_bridge_types::crypto::{Aes256GcmDecryption, Aes256GcmEncryption, Aes256GcmSiv};
use signal_crypto::{Aes256Ctr32, CryptographicHash, CryptographicMac, Error, Result};
use crate::support::*;
use crate::*;

View File

@ -3,10 +3,10 @@
// SPDX-License-Identifier: AGPL-3.0-only
//
use ::attest::ias;
use libsignal_bridge_macros::*;
use crate::*;
use ::attest::ias;
#[bridge_fn(jni = false, node = false)]
pub fn verify_signature(

View File

@ -3,12 +3,10 @@
// SPDX-License-Identifier: AGPL-3.0-only
//
use hmac::digest::{crypto_common, OutputSizeUser};
use crypto_common::KeyInit;
use hmac::digest::typenum::Unsigned;
use hmac::digest::{crypto_common, OutputSizeUser};
use hmac::Hmac;
use libsignal_bridge_macros::*;
use libsignal_bridge_types::incremental_mac::*;
use libsignal_protocol::incremental_mac::{calculate_chunk_size, Incremental};

View File

@ -13,22 +13,12 @@ pub use libsignal_bridge_types::{
bridge_as_handle, bridge_deserialize, bridge_fixed_length_serializable_fns, bridge_get,
bridge_handle_fns, bridge_serializable_handle_fns, describe_panic, io, support,
};
#[cfg(feature = "node")]
pub use libsignal_bridge_types::node_register;
#[cfg(feature = "ffi")]
pub use libsignal_bridge_types::{ffi_arg_type, ffi_result_type};
pub use libsignal_bridge_types::{ffi, ffi_arg_type, ffi_result_type};
#[cfg(feature = "jni")]
pub use libsignal_bridge_types::{jni_arg_type, jni_args, jni_class_name, jni_result_type};
#[cfg(feature = "ffi")]
pub use libsignal_bridge_types::ffi;
#[cfg(feature = "jni")]
pub use libsignal_bridge_types::jni;
pub use libsignal_bridge_types::{jni, jni_arg_type, jni_args, jni_class_name, jni_result_type};
#[cfg(feature = "node")]
pub use libsignal_bridge_types::node;
pub use libsignal_bridge_types::{node, node_register};
pub mod logging;

View File

@ -45,10 +45,10 @@ pub fn log_enabled_in_apps(metadata: &log::Metadata) -> bool {
#[cfg(test)]
mod tests {
use super::*;
use test_case::test_matrix;
use super::*;
#[test_matrix([
"libsignal_foo",
"signal_foo",

View File

@ -8,16 +8,11 @@ use libsignal_bridge_types::media::SanitizedMetadata;
use signal_media::sanitize::{mp4, webp};
use crate::io::{AsyncInput, InputStream, SyncInput, SyncInputStream};
// Not used by the Java bridge.
#[allow(unused_imports)]
use crate::support::*;
use crate::*;
// Will be unused when building for Node only.
#[allow(unused_imports)]
use futures_util::FutureExt;
bridge_handle_fns!(SanitizedMetadata);
/// Exposed so that we have an easy method to invoke from Java to test whether libsignal was

View File

@ -7,7 +7,6 @@ use libsignal_bridge_macros::*;
use libsignal_bridge_types::message_backup::*;
use libsignal_message_backup::backup::Purpose;
use libsignal_message_backup::frame::LimitedReaderFactory;
use libsignal_message_backup::{BackupReader, ReadResult};
use libsignal_protocol::Aci;

View File

@ -7,15 +7,13 @@ use std::convert::TryInto as _;
use std::num::{NonZeroU16, NonZeroU32};
use base64::prelude::{Engine, BASE64_STANDARD};
use rand::rngs::OsRng;
use libsignal_bridge_macros::{bridge_fn, bridge_io};
use libsignal_bridge_types::net::Svr3Clients;
pub use libsignal_bridge_types::net::{ConnectionManager, Environment, TokioAsyncContext};
use libsignal_net::auth::Auth;
use libsignal_net::svr3::traits::*;
use libsignal_net::svr3::{self, migrate_backup, restore_with_fallback, OpaqueMaskedShareSet};
pub use libsignal_bridge_types::net::{ConnectionManager, Environment, TokioAsyncContext};
use rand::rngs::OsRng;
use crate::support::*;
use crate::*;
@ -162,9 +160,10 @@ async fn Svr3Remove(
#[cfg(test)]
mod test {
use super::*;
use test_case::test_case;
use super::*;
#[test_case(Environment::Staging; "staging")]
#[test_case(Environment::Prod; "prod")]
fn can_create_connection_manager(env: Environment) {

View File

@ -10,7 +10,6 @@ use libsignal_bridge_types::net::cdsi::{CdsiLookup, LookupRequest};
use libsignal_bridge_types::net::{ConnectionManager, TokioAsyncContext};
use libsignal_net::auth::Auth;
use libsignal_net::cdsi::{self, AciAndAccessKey, LookupResponse, E164};
use libsignal_protocol::{Aci, SignalProtocolError};
use crate::support::*;

View File

@ -221,11 +221,12 @@ async fn ServerMessageAck_SendStatus(
#[cfg(test)]
mod test {
use super::*;
use crate::net::{ConnectionManager, ConnectionManager_set_proxy, Environment};
use assert_matches::assert_matches;
use libsignal_net::chat::ChatServiceError;
use super::*;
use crate::net::{ConnectionManager, ConnectionManager_set_proxy, Environment};
// Normally we would write this test in the app languages, but it depends on timeouts.
// Using a paused tokio runtime auto-advances time when there's no other work to be done.
#[tokio::test(start_paused = true)]

View File

@ -3,13 +3,13 @@
// SPDX-License-Identifier: AGPL-3.0-only
//
use ::attest::svr2::lookup_groupid;
use ::signal_pin::{local_pin_hash, verify_local_pin_hash, PinHash, Result};
use libsignal_bridge_macros::*;
use signal_pin::Error;
use crate::support::*;
use crate::*;
use ::attest::svr2::lookup_groupid;
use ::signal_pin::{local_pin_hash, verify_local_pin_hash, PinHash, Result};
use signal_pin::Error;
bridge_handle_fns!(PinHash, node = false);

View File

@ -3,6 +3,9 @@
// SPDX-License-Identifier: AGPL-3.0-only
//
// Will be unused when building for Node only.
#[allow(unused_imports)]
use futures_util::FutureExt;
use libsignal_bridge_macros::*;
#[cfg(feature = "jni")]
use libsignal_bridge_types::jni;
@ -11,10 +14,6 @@ use libsignal_protocol::*;
use static_assertions::const_assert_eq;
use uuid::Uuid;
// Will be unused when building for Node only.
#[allow(unused_imports)]
use futures_util::FutureExt;
use crate::support::*;
use crate::*;

View File

@ -3,17 +3,16 @@
// SPDX-License-Identifier: AGPL-3.0-only
//
use libsignal_bridge_macros::*;
#[allow(unused_imports)]
use crate::support::*;
use crate::*;
#[allow(unused_imports)]
use ::usernames::{
create_for_username, decrypt_username, NicknameLimits, Username, UsernameError,
UsernameLinkError,
};
use libsignal_bridge_macros::*;
#[allow(unused_imports)]
use crate::support::*;
use crate::*;
#[bridge_fn]
pub fn Username_Hash(username: String) -> Result<[u8; 32], UsernameError> {

View File

@ -7,26 +7,23 @@ use ::zkgroup;
use libsignal_bridge_macros::*;
use libsignal_bridge_types::zkgroup::validate_serialization;
use libsignal_protocol::{Aci, Pni, ServiceId};
use uuid::Uuid;
use zkgroup::auth::*;
use zkgroup::backups::{
BackupAuthCredential, BackupAuthCredentialPresentation, BackupAuthCredentialRequest,
BackupAuthCredentialRequestContext, BackupAuthCredentialResponse, BackupLevel,
};
use zkgroup::call_links::*;
use zkgroup::generic_server_params::*;
use zkgroup::groups::*;
use zkgroup::profiles::*;
use zkgroup::receipts::*;
pub(crate) use zkgroup::Timestamp;
use zkgroup::*;
use uuid::Uuid;
use zkgroup::backups::{
BackupAuthCredential, BackupAuthCredentialPresentation, BackupAuthCredentialRequest,
BackupAuthCredentialRequestContext, BackupAuthCredentialResponse, BackupLevel,
};
use crate::support::*;
use crate::*;
pub(crate) use zkgroup::Timestamp;
bridge_fixed_length_serializable_fns!(ExpiringProfileKeyCredential);
bridge_fixed_length_serializable_fns!(ExpiringProfileKeyCredentialResponse);
bridge_fixed_length_serializable_fns!(GroupMasterKey);

View File

@ -3,6 +3,8 @@
// SPDX-License-Identifier: AGPL-3.0-only
//
use std::future::Future;
use futures_util::{AsyncReadExt as _, FutureExt};
use io::{AsyncInput, InputStream};
use libsignal_bridge_macros::*;
@ -10,8 +12,6 @@ use libsignal_bridge_types::support::*;
use libsignal_bridge_types::*;
use libsignal_protocol::SignalProtocolError;
use std::future::Future;
use crate::types::*;
pub struct NonSuspendingBackgroundThreadRuntime;

View File

@ -7,11 +7,10 @@
compile_error!("Feature \"ffi\", \"jni\", or \"node\" must be enabled for this crate.");
use libsignal_bridge_macros::bridge_fn;
use libsignal_bridge_types::support::*;
use libsignal_bridge_types::*;
#[cfg(feature = "node")]
pub use libsignal_bridge_types::node;
use libsignal_bridge_types::support::*;
use libsignal_bridge_types::*;
#[bridge_fn]
pub fn test_only_fn_returns_123() -> u32 {

View File

@ -6,10 +6,9 @@
#[allow(unused_imports)]
use libsignal_protocol::SignalProtocolError;
use crate::*;
#[cfg(feature = "jni")]
use crate::jni::HandleJniError;
use crate::*;
/// A syntactic wrapper for a type that allows it to ignored by the macros in ffi/convert.rs and
/// jni/convert.rs, and by gen_ts_decl.py.

View File

@ -3,12 +3,12 @@
// SPDX-License-Identifier: AGPL-3.0-only
//
use super::*;
use crate::net::chat::{ChatListener, MakeChatListener, ServerMessageAck};
use std::ffi::{c_uchar, c_void};
use libsignal_net::chat::ChatServiceError;
use std::ffi::{c_uchar, c_void};
use super::*;
use crate::net::chat::{ChatListener, MakeChatListener, ServerMessageAck};
type ReceivedIncomingMessage = extern "C" fn(
ctx: *mut c_void,

View File

@ -12,12 +12,11 @@ use libsignal_protocol::*;
use paste::paste;
use uuid::Uuid;
use super::*;
use crate::io::{InputStream, SyncInputStream};
use crate::net::chat::MakeChatListener;
use crate::support::{extend_lifetime, AsType, FixedLengthBincodeSerializable, Serialized};
use super::*;
/// Converts arguments from their FFI form to their Rust form.
///
/// `ArgTypeInfo` has two required methods: `borrow` and `load_from`. The use site looks like this:

View File

@ -18,9 +18,8 @@ use signal_pin::Error as PinError;
use usernames::{UsernameError, UsernameLinkError};
use zkgroup::{ZkGroupDeserializationFailure, ZkGroupVerificationFailure};
use crate::support::describe_panic;
use super::{FutureCancelled, NullPointerError, UnexpectedPanic};
use crate::support::describe_panic;
#[derive(Debug)]
#[repr(C)]

View File

@ -3,12 +3,12 @@
// SPDX-License-Identifier: AGPL-3.0-only
//
use super::*;
use crate::support::{AsyncRuntime, ResultReporter};
use std::future::Future;
use futures_util::{FutureExt, TryFutureExt};
use std::future::Future;
use super::*;
use crate::support::{AsyncRuntime, ResultReporter};
#[derive(Debug)]
pub struct FutureCancelled;

View File

@ -9,9 +9,8 @@ use std::io;
use async_trait::async_trait;
use libsignal_protocol::SignalProtocolError;
use crate::io::{InputStream, InputStreamRead, SyncInputStream};
use super::CallbackError;
use crate::io::{InputStream, InputStreamRead, SyncInputStream};
type Read =
extern "C" fn(ctx: *mut c_void, buf: *mut u8, buf_len: usize, amount_read: *mut usize) -> c_int;

View File

@ -3,12 +3,12 @@
// SPDX-License-Identifier: AGPL-3.0-only
//
use super::*;
use std::ffi::{c_int, c_uint, c_void};
use async_trait::async_trait;
use uuid::Uuid;
use std::ffi::{c_int, c_uint, c_void};
use super::*;
type GetIdentityKeyPair =
extern "C" fn(store_ctx: *mut c_void, keyp: *mut *mut PrivateKey) -> c_int;

View File

@ -4,7 +4,6 @@
//
use hmac::Hmac;
use libsignal_protocol::incremental_mac::{Incremental, Validating};
use crate::*;

View File

@ -3,24 +3,22 @@
// SPDX-License-Identifier: AGPL-3.0-only
//
use std::num::ParseIntError;
use std::ops::Deref;
use jni::objects::{AutoLocal, JByteBuffer, JMap, JObjectArray};
use jni::sys::{jbyte, JNI_FALSE, JNI_TRUE};
use jni::JNIEnv;
use libsignal_net::cdsi::LookupResponseEntry;
use libsignal_protocol::*;
use paste::paste;
use std::num::ParseIntError;
use std::ops::Deref;
use super::*;
use crate::io::{InputStream, SyncInputStream};
use crate::message_backup::MessageBackupValidationOutcome;
use crate::net::chat::ResponseAndDebugInfo;
use crate::support::{Array, AsType, FixedLengthBincodeSerializable, Serialized};
use super::*;
/// Converts arguments from their JNI form to their Rust form.
///
/// `ArgTypeInfo` has two required methods: `borrow` and `load_from`. The use site looks like this:

View File

@ -2,16 +2,15 @@
// Copyright 2020-2021 Signal Messenger, LLC.
// SPDX-License-Identifier: AGPL-3.0-only
//
use http::uri::InvalidUri;
use std::fmt;
use std::io::{Error as IoError, ErrorKind as IoErrorKind};
use std::time::Duration;
use jni::objects::{GlobalRef, JObject, JString, JThrowable};
use jni::{JNIEnv, JavaVM};
use attest::hsm_enclave::Error as HsmEnclaveError;
use device_transfer::Error as DeviceTransferError;
use http::uri::InvalidUri;
use jni::objects::{GlobalRef, JObject, JString, JThrowable};
use jni::{JNIEnv, JavaVM};
use libsignal_net::chat::ChatServiceError;
use libsignal_net::infra::ws::{WebSocketConnectError, WebSocketServiceError};
use libsignal_protocol::*;
@ -20,11 +19,10 @@ use signal_pin::Error as PinError;
use usernames::{UsernameError, UsernameLinkError};
use zkgroup::{ZkGroupDeserializationFailure, ZkGroupVerificationFailure};
use super::*;
use crate::net::cdsi::CdsiError;
use crate::support::describe_panic;
use super::*;
/// The top-level error type for when something goes wrong.
#[derive(Debug, thiserror::Error)]
pub enum SignalJniError {

View File

@ -3,12 +3,12 @@
// SPDX-License-Identifier: AGPL-3.0-only
//
use super::*;
use crate::support::{AsyncRuntime, ResultReporter};
use std::future::Future;
use futures_util::{FutureExt, TryFutureExt};
use std::future::Future;
use super::*;
use crate::support::{AsyncRuntime, ResultReporter};
/// Used to complete a Java CompletableFuture from any thread.
pub struct FutureCompleter<T> {

View File

@ -9,7 +9,6 @@ use std::io;
use async_trait::async_trait;
use super::*;
use crate::io::{InputStream, InputStreamRead, SyncInputStream};
pub type JavaInputStream<'a> = JObject<'a>;

View File

@ -9,7 +9,12 @@ use std::marker::PhantomData;
use attest::enclave::Error as EnclaveError;
use attest::hsm_enclave::Error as HsmEnclaveError;
use device_transfer::Error as DeviceTransferError;
pub use jni::objects::{
AutoElements, JByteArray, JClass, JLongArray, JObject, JObjectArray, JString, ReleaseMode,
};
use jni::objects::{GlobalRef, JThrowable, JValue, JValueOwned};
pub use jni::sys::{jboolean, jint, jlong};
pub use jni::JNIEnv;
use jni::JavaVM;
use libsignal_net::infra::ws::WebSocketServiceError;
use libsignal_net::svr3::Error as Svr3Error;
@ -20,12 +25,6 @@ use usernames::{UsernameError, UsernameLinkError};
use crate::net::cdsi::CdsiError;
pub use jni::objects::{
AutoElements, JByteArray, JClass, JLongArray, JObject, JObjectArray, JString, ReleaseMode,
};
pub use jni::sys::{jboolean, jint, jlong};
pub use jni::JNIEnv;
#[macro_use]
mod args;
pub use args::*;

View File

@ -5,10 +5,11 @@
use std::cell::RefCell;
use super::*;
use async_trait::async_trait;
use uuid::Uuid;
use super::*;
pub type JavaIdentityKeyStore<'a> = JObject<'a>;
pub type JavaPreKeyStore<'a> = JObject<'a>;
pub type JavaSignedPreKeyStore<'a> = JObject<'a>;

View File

@ -34,10 +34,10 @@ pub mod zkgroup;
// Desktop does not use SVR
#[cfg(any(feature = "jni", feature = "ffi"))]
mod pin {
use crate::*;
use ::signal_pin::PinHash;
use crate::*;
bridge_as_handle!(PinHash, node = false);
}

View File

@ -3,13 +3,14 @@
// SPDX-License-Identifier: AGPL-3.0-only
//
use crate::*;
use std::marker::PhantomData;
use std::num::{NonZeroU16, NonZeroU32};
use std::panic::RefUnwindSafe;
use aes_gcm_siv::aead::rand_core::CryptoRngCore;
use async_trait::async_trait;
use futures_util::future::join3;
use http::uri::PathAndQuery;
use libsignal_net::auth::Auth;
use libsignal_net::enclave::{
Cdsi, EnclaveEndpoint, EnclaveEndpointConnection, EnclaveKind, Nitro, PpssSetup, Sgx, Tpm2Snp,
@ -29,9 +30,8 @@ use libsignal_net::svr3::{Error, OpaqueMaskedShareSet};
use libsignal_net::timeouts::ONE_ROUTE_CONNECTION_TIMEOUT;
use libsignal_net::utils::ObservableEvent;
use libsignal_svr3::EvaluationResult;
use std::marker::PhantomData;
use std::num::{NonZeroU16, NonZeroU32};
use std::panic::RefUnwindSafe;
use crate::*;
pub mod cdsi;
pub mod chat;
@ -328,10 +328,11 @@ mod empty_env {
#[cfg(test)]
mod test {
use super::*;
use assert_matches::assert_matches;
use test_case::test_case;
use super::*;
#[test_case(Environment::Staging; "staging")]
#[test_case(Environment::Prod; "prod")]
fn can_create_connection_manager(env: Environment) {

View File

@ -8,7 +8,6 @@ use libsignal_net::cdsi::{self, CdsiConnection, ClientResponseCollector, Token};
use libsignal_net::infra::tcp_ssl::TcpSslConnectorStream;
use crate::net::ConnectionManager;
use crate::*;
#[cfg(feature = "jni")]

View File

@ -3,8 +3,8 @@
// SPDX-License-Identifier: AGPL-3.0-only
//
use crate::net::chat::{ChatListener, MakeChatListener, ServerMessageAck};
use crate::node::ResultTypeInfo;
use std::sync::Arc;
use libsignal_net::chat::ChatServiceError;
use libsignal_protocol::Timestamp;
use neon::context::FunctionContext;
@ -12,7 +12,9 @@ use neon::event::Channel;
use neon::handle::{Handle, Root};
use neon::prelude::{Context, Finalize, JsObject, Object};
use signal_neon_futures::call_method;
use std::sync::Arc;
use crate::net::chat::{ChatListener, MakeChatListener, ServerMessageAck};
use crate::node::ResultTypeInfo;
#[derive(Clone)]
pub struct NodeChatListener {

View File

@ -3,26 +3,25 @@
// SPDX-License-Identifier: AGPL-3.0-only
//
use neon::prelude::*;
use neon::types::JsBigInt;
use paste::paste;
use std::cell::RefCell;
use std::collections::hash_map::DefaultHasher;
use std::fmt::Display;
use std::hash::Hasher;
use std::num::ParseIntError;
use std::ops::{Deref, DerefMut, RangeInclusive};
use std::slice;
use neon::prelude::*;
use neon::types::JsBigInt;
use paste::paste;
use super::*;
use crate::io::{InputStream, SyncInputStream};
use crate::message_backup::MessageBackupValidationOutcome;
use crate::net::chat::{MakeChatListener, ResponseAndDebugInfo};
use crate::node::chat::NodeMakeChatListener;
use crate::support::{extend_lifetime, Array, AsType, FixedLengthBincodeSerializable, Serialized};
use super::*;
/// Converts arguments from their JavaScript form to their Rust form.
///
/// `ArgTypeInfo` has two required methods: `borrow` and `load_from`. The use site looks like this:

View File

@ -10,12 +10,11 @@ use futures_util::FutureExt;
use neon::types::{Deferred, JsBigInt};
use signal_neon_futures::ChannelEx;
use super::*;
use crate::support::{
describe_panic, AsyncRuntime, AsyncRuntimeBase, CancellationId, ResultReporter,
};
use super::*;
#[derive(Debug, thiserror::Error, displaydoc::Display)]
/// Promise cancelled
pub struct CancellationError;

View File

@ -3,16 +3,16 @@
// SPDX-License-Identifier: AGPL-3.0-only
//
use crate::io::{InputStream, InputStreamRead, SyncInputStream};
use super::*;
use std::cell::Cell;
use std::io::{Error as IoError, ErrorKind as IoErrorKind, Result as IoResult};
use std::sync::Arc;
use async_trait::async_trait;
use futures_util::TryFutureExt;
use signal_neon_futures::*;
use std::cell::Cell;
use std::io::{Error as IoError, ErrorKind as IoErrorKind, Result as IoResult};
use std::sync::Arc;
use super::*;
use crate::io::{InputStream, InputStreamRead, SyncInputStream};
pub struct NodeInputStream {
js_channel: Channel,

View File

@ -3,10 +3,9 @@
// SPDX-License-Identifier: AGPL-3.0-only
//
use libsignal_protocol::*;
use std::ops::Deref;
use libsignal_protocol::*;
pub use neon::context::Context;
pub use neon::prelude::*;
pub use neon::types::buffer::TypedArray;

View File

@ -3,14 +3,15 @@
// SPDX-License-Identifier: AGPL-3.0-only
//
use super::*;
use std::cell::RefCell;
use std::sync::Arc;
use async_trait::async_trait;
use signal_neon_futures::*;
use std::cell::RefCell;
use std::sync::Arc;
use uuid::Uuid;
use super::*;
pub struct NodePreKeyStore {
js_channel: Channel,
store_object: Arc<Root<JsObject>>,

View File

@ -3,12 +3,11 @@
// SPDX-License-Identifier: AGPL-3.0-only
//
use libsignal_protocol::*;
use static_assertions::const_assert_eq;
// Will be unused when building for Node only.
#[allow(unused_imports)]
use futures_util::FutureExt;
use libsignal_protocol::*;
use static_assertions::const_assert_eq;
use crate::*;

View File

@ -4,18 +4,16 @@
//
use ::zkgroup;
use partial_default::PartialDefault;
use serde::Deserialize;
use zkgroup::groups::*;
use zkgroup::profiles::*;
use zkgroup::receipts::*;
pub use zkgroup::Timestamp;
use zkgroup::*;
use crate::support::*;
use crate::*;
pub use zkgroup::Timestamp;
/// Checks that `bytes` can be deserialized as a `T` using our standard bincode settings.
pub fn validate_serialization<'a, T: Deserialize<'a> + PartialDefault>(

View File

@ -7,10 +7,10 @@
//! Types for identifying an individual Signal client instance.
use uuid::Uuid;
use std::fmt;
use uuid::Uuid;
/// Known types of [ServiceId].
#[derive(Clone, Copy, Hash, PartialEq, Eq, num_enum::IntoPrimitive, num_enum::TryFromPrimitive)]
#[repr(u8)]
@ -331,12 +331,12 @@ where
#[cfg(test)]
mod service_id_tests {
use std::borrow::Borrow;
use proptest::prelude::*;
use rand::seq::SliceRandom;
use rand::thread_rng;
use std::borrow::Borrow;
use super::*;
#[test]

View File

@ -3,10 +3,11 @@
// SPDX-License-Identifier: AGPL-3.0-only
//
use std::result::Result;
use aes::cipher::block_padding::Pkcs7;
use aes::cipher::{BlockDecryptMut, BlockEncryptMut, KeyIvInit};
use aes::Aes256;
use std::result::Result;
#[derive(Debug, displaydoc::Display, thiserror::Error)]
pub enum EncryptionError {
@ -51,9 +52,10 @@ pub fn aes_256_cbc_decrypt(
#[cfg(test)]
mod test {
use super::*;
use hex_literal::hex;
use super::*;
#[test]
fn aes_cbc_test() {
let key = hex!("4e22eb16d964779994222e82192ce9f747da72dc4abe49dfdeeb71d0ffe3796e");

View File

@ -3,11 +3,12 @@
// SPDX-License-Identifier: AGPL-3.0-only
//
use crate::error::{Error, Result};
use aes::cipher::typenum::Unsigned;
use aes::cipher::{InnerIvInit, KeyInit, StreamCipher, StreamCipherSeek};
use aes::Aes256;
use crate::error::{Error, Result};
/// A wrapper around [`ctr::Ctr32BE`] that uses a smaller nonce and supports an initial counter.
pub struct Aes256Ctr32(ctr::Ctr32BE<Aes256>);

View File

@ -3,7 +3,6 @@
// SPDX-License-Identifier: AGPL-3.0-only
//
use crate::{Aes256Ctr32, Error, Result};
use aes::cipher::generic_array::GenericArray;
use aes::cipher::{BlockEncrypt, KeyInit};
use aes::Aes256;
@ -11,6 +10,8 @@ use ghash::universal_hash::UniversalHash;
use ghash::GHash;
use subtle::ConstantTimeEq;
use crate::{Aes256Ctr32, Error, Result};
pub const TAG_SIZE: usize = 16;
pub const NONCE_SIZE: usize = 12;

View File

@ -3,12 +3,12 @@
// SPDX-License-Identifier: AGPL-3.0-only
//
use crate::{Error, Result};
use hmac::{Hmac, Mac};
use sha1::Sha1;
use sha2::{Digest, Sha256, Sha512};
use crate::{Error, Result};
#[derive(Clone)]
pub enum CryptographicMac {
HmacSha256(Hmac<Sha256>),

View File

@ -3,10 +3,11 @@
// SPDX-License-Identifier: AGPL-3.0-only
//
use std::collections::HashMap;
use hex_literal::hex;
use rand::Rng;
use serde::Deserialize;
use std::collections::HashMap;
#[allow(dead_code)]
#[derive(Deserialize, Debug)]

View File

@ -4,14 +4,12 @@
//
use std::cmp::Ordering;
use std::time::{Duration, SystemTime};
use boring::asn1::Asn1Time;
use boring::pkey::PKey;
use boring::rsa::Padding;
use boring::x509::X509;
use device_transfer::*;
#[test]

View File

@ -36,10 +36,11 @@ pub fn verify(search_key: &[u8], commitment: &[u8], data: &[u8], nonce: &[u8; 16
#[cfg(test)]
mod test {
use super::*;
use hex_literal::hex;
use test_case::test_case;
use super::*;
#[test_case(&[], &[], &hex!("edc3f59798cd87f2f48ec8836e2b6ef425cde9ab121ffdefc93d769db7cebabf") ; "empty")]
#[test_case(b"foo", b"bar", &hex!("25df431e884358826fe66f96d65702580104240abd63fa741d9ea3f32914bbf5") ; "case_1")]
#[test_case(b"foo1", b"bar", &hex!("6c31a163a7660d1467fc1c997bd78b0a70b8921ca76b7eb0c6ca077f1e5e121e") ; "case_2")]

View File

@ -119,10 +119,10 @@ pub fn next_monitor(entries: &[u64]) -> u64 {
#[cfg(test)]
mod test {
use super::*;
use proptest::prelude::*;
use super::*;
#[derive(Clone, Debug)]
struct StartAndN {
start: u64,

View File

@ -431,9 +431,10 @@ pub fn verify_consistency_proof(
#[cfg(test)]
mod test {
use super::*;
use hex_literal::hex;
use super::*;
#[test]
fn test_evaluate_batch_proof() {
let mut values = [[0u8; 32]; 6];

View File

@ -5,9 +5,10 @@
//! Implements the Prefix Tree.
use std::result::Result;
use crate::wire::PrefixProof as SearchResult;
use sha2::{Digest as _, Sha256};
use crate::wire::PrefixProof as SearchResult;
const KEY_LENGTH: usize = 32;
/// Malformed proof

View File

@ -136,9 +136,10 @@ impl PublicKey {
#[cfg(test)]
mod tests {
use super::*;
use hex_literal::hex;
use super::*;
struct TestVector {
pk: [u8; 32],
alpha: &'static [u8],

View File

@ -5,9 +5,8 @@
use futures_util::AsyncRead;
use mediasan_common::AsyncSkip;
use mp4san::{sanitize_async_with_config, Config};
pub use mp4san::parse::ParseError;
use mp4san::{sanitize_async_with_config, Config};
pub use mp4san::{InputSpan, SanitizedMetadata};
/// Error type returned by [`sanitize_mp4`].

View File

@ -353,11 +353,10 @@ mod test {
use test_case::test_case;
use uuid::Uuid;
use super::*;
use crate::backup::chat::chat_style::{BubbleColor, CustomChatColor, CustomColorId};
use crate::backup::method::{Store, ValidateOnly};
use super::*;
impl proto::AccountData {
pub(crate) fn test_data() -> Self {
Self {

View File

@ -357,12 +357,11 @@ pub(crate) mod test {
use protobuf::EnumOrUnknown;
use test_case::test_case;
use super::*;
use crate::backup::time::testutil::MillisecondsSinceEpoch;
use crate::backup::time::Duration;
use crate::backup::TryIntoWith as _;
use super::*;
impl proto::IndividualCall {
const TEST_ID: CallId = CallId(33333);

View File

@ -693,18 +693,16 @@ mod test {
use std::time::UNIX_EPOCH;
use assert_matches::assert_matches;
use protobuf::SpecialFields;
use test_case::test_case;
use super::*;
use crate::backup::chat::testutil::TestContext;
use crate::backup::method::Store;
use crate::backup::recipient::FullRecipientData;
use crate::backup::time::testutil::MillisecondsSinceEpoch;
use crate::backup::Purpose;
use super::*;
impl proto::ChatItem {
pub(crate) fn test_data() -> Self {
Self {

View File

@ -405,12 +405,11 @@ mod test {
use test_case::test_case;
use super::*;
use crate::backup::chat::chat_style::Color;
use crate::backup::chat::testutil::TestContext;
use crate::backup::method::Store;
use super::*;
impl proto::ChatStyle {
fn test_data() -> Self {
Self {

View File

@ -172,12 +172,11 @@ impl TryFrom<proto::ContactAttachment> for ContactAttachment {
mod test {
use test_case::test_case;
use super::*;
use crate::backup::chat::testutil::TestContext;
use crate::backup::chat::ReactionError;
use crate::backup::recipient::FullRecipientData;
use super::*;
impl proto::ContactMessage {
fn test_data() -> Self {
Self {

View File

@ -494,9 +494,8 @@ impl<T: Debug> Debug for NoValidation<T> {
mod test {
use test_case::test_case;
use crate::proto::backup::{group_change_chat_update, group_invitation_revoked_update};
use super::*;
use crate::proto::backup::{group_change_chat_update, group_invitation_revoked_update};
const ACI_BYTES: [u8; 16] = [0xaa; 16];
const ACI: Aci = Aci::from_uuid_bytes(ACI_BYTES);

View File

@ -5,7 +5,6 @@
use crate::backup::file::{FilePointer, FilePointerError};
use crate::backup::time::Timestamp;
use crate::proto::backup as proto;
#[derive(Debug, serde::Serialize)]
@ -60,9 +59,8 @@ impl TryFrom<proto::LinkPreview> for LinkPreview {
mod test {
use test_case::test_case;
use crate::backup::time::testutil::MillisecondsSinceEpoch;
use super::*;
use crate::backup::time::testutil::MillisecondsSinceEpoch;
impl proto::LinkPreview {
fn test_data() -> Self {

View File

@ -258,9 +258,8 @@ mod test {
use test_case::test_case;
use crate::backup::time::testutil::MillisecondsSinceEpoch;
use super::*;
use crate::backup::time::testutil::MillisecondsSinceEpoch;
impl FromStr for MobAmount {
type Err = ParseError;

View File

@ -141,12 +141,11 @@ impl TryFrom<proto::quote::QuotedAttachment> for QuotedAttachment {
mod test {
use test_case::test_case;
use super::*;
use crate::backup::chat::testutil::TestContext;
use crate::backup::recipient::FullRecipientData;
use crate::backup::time::testutil::MillisecondsSinceEpoch;
use super::*;
impl proto::quote::QuotedAttachment {
fn test_data() -> Self {
Self {

View File

@ -85,12 +85,11 @@ impl<R: Clone, C: Lookup<RecipientId, R>> TryFromWith<proto::StandardMessage, C>
#[cfg(test)]
mod test {
use super::*;
use crate::backup::chat::testutil::TestContext;
use crate::backup::recipient::FullRecipientData;
use crate::backup::time::{Duration, Timestamp};
use super::*;
impl proto::StandardMessage {
pub(crate) fn test_data() -> Self {
Self {

View File

@ -54,12 +54,11 @@ impl<R: Clone, C: Lookup<RecipientId, R>> TryFromWith<proto::StickerMessage, C>
mod test {
use test_case::test_case;
use super::*;
use crate::backup::chat::testutil::TestContext;
use crate::backup::chat::ReactionError;
use crate::backup::recipient::FullRecipientData;
use super::*;
impl proto::StickerMessage {
pub(crate) fn test_data() -> Self {
Self {

View File

@ -8,6 +8,7 @@ use std::sync::Arc;
use nonzero_ext::nonzero;
use once_cell::sync::Lazy;
use super::chat_style::CustomChatColor;
use crate::backup::chat::chat_style::CustomColorId;
use crate::backup::chat::PinOrder;
use crate::backup::frame::RecipientId;
@ -17,8 +18,6 @@ use crate::backup::time::Timestamp;
use crate::backup::{BackupMeta, Purpose};
use crate::proto::backup as proto;
use super::chat_style::CustomChatColor;
pub(super) struct TestContext(pub(super) BackupMeta);
impl Default for TestContext {

View File

@ -84,9 +84,8 @@ impl TryFrom<proto::Text> for MessageText {
#[cfg(test)]
mod test {
use crate::backup::chat::testutil::TEST_MESSAGE_TEXT;
use super::*;
use crate::backup::chat::testutil::TEST_MESSAGE_TEXT;
impl proto::Text {
pub(crate) fn test_data() -> Self {

View File

@ -167,12 +167,11 @@ mod test {
use assert_matches::assert_matches;
use test_case::test_case;
use super::*;
use crate::backup::call::CallError;
use crate::backup::chat::testutil::TestContext;
use crate::proto::backup::chat_update_message::Update as ChatUpdateProto;
use super::*;
impl proto::SimpleChatUpdate {
pub(crate) fn test_data() -> Self {
Self {

View File

@ -94,11 +94,10 @@ impl<R: Clone, C: Lookup<RecipientId, R>> TryFromWith<proto::StandardMessage, C>
mod test {
use test_case::test_case;
use super::*;
use crate::backup::chat::testutil::TestContext;
use crate::backup::recipient::FullRecipientData;
use super::*;
#[test]
fn valid_voice_message() {
assert_eq!(

View File

@ -276,9 +276,8 @@ mod test {
use hex_literal::hex;
use test_case::test_case;
use crate::backup::time::testutil::MillisecondsSinceEpoch;
use super::*;
use crate::backup::time::testutil::MillisecondsSinceEpoch;
impl proto::file_pointer::BackupLocator {
fn test_data() -> Self {

View File

@ -475,11 +475,10 @@ mod test {
use protobuf::EnumOrUnknown;
use test_case::test_case;
use super::*;
use crate::backup::method::{Lookup, Store};
use crate::backup::FullRecipientData;
use super::*;
impl proto::Recipient {
pub(crate) const TEST_ID: u64 = 11111;
pub(crate) fn test_data() -> Self {

Some files were not shown because too many files have changed in this diff Show More