Skip to content

Commit

Permalink
Fix redundant import warnings in nightly
Browse files Browse the repository at this point in the history
Miri wants it
  • Loading branch information
akoshelev committed Feb 20, 2024
1 parent 033eab6 commit 1076faf
Show file tree
Hide file tree
Showing 21 changed files with 98 additions and 49 deletions.
9 changes: 7 additions & 2 deletions ipa-core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,13 +426,18 @@ impl Debug for Http2Configurator {

#[cfg(all(test, unit_test))]
mod tests {
use std::time::Duration;

use hpke::{kem::X25519HkdfSha256, Kem};
use hyper::Uri;
use rand::rngs::StdRng;
use rand_core::SeedableRng;

use super::*;
use crate::{config::HpkeClientConfig, helpers::HelperIdentity, net::test::TestConfigBuilder};
use crate::{
config::{ClientConfig, HpkeClientConfig, Http2Configurator, HttpClientConfigurator},
helpers::HelperIdentity,
net::test::TestConfigBuilder,
};

const URI_1: &str = "http://localhost:3000";
const URI_2: &str = "http://localhost:3001";
Expand Down
7 changes: 5 additions & 2 deletions ipa-core/src/ff/curve_points.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,12 @@ mod test {
use rand::{thread_rng, Rng};
use typenum::U32;

use super::*;
use crate::{
ff::{curve_points::RP25519, ec_prime_field::Fp25519, Serializable},
ff::{
curve_points::{NonCanonicalEncoding, RP25519},
ec_prime_field::Fp25519,
Serializable,
},
secret_sharing::SharedValue,
};

Expand Down
1 change: 0 additions & 1 deletion ipa-core/src/helpers/buffers/ordering_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use std::{
collections::VecDeque,
fmt::Debug,
marker::PhantomData,
mem::drop,
num::NonZeroUsize,
pin::Pin,
task::{Context, Poll},
Expand Down
2 changes: 1 addition & 1 deletion ipa-core/src/helpers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,9 +556,9 @@ mod tests {
}

mod role_assignment_tests {
use super::*;
use crate::{
ff::Fp31,
helpers::{HelperIdentity, Role, RoleAssignment},
protocol::{basics::SecureMul, context::Context, RecordId},
rand::{thread_rng, Rng},
test_fixture::{Reconstruct, Runner, TestWorld, TestWorldConfig},
Expand Down
21 changes: 17 additions & 4 deletions ipa-core/src/helpers/transport/in_memory/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,18 +369,31 @@ impl Setup {

#[cfg(all(test, unit_test))]
mod tests {
use std::{io::ErrorKind, num::NonZeroUsize, panic::AssertUnwindSafe, sync::Mutex};
use std::{
collections::HashMap,
convert, io,
io::ErrorKind,
num::NonZeroUsize,
panic::AssertUnwindSafe,
sync::{Mutex, Weak},
task::Poll,
};

use futures_util::{stream::poll_immediate, FutureExt, StreamExt};
use tokio::sync::{mpsc::channel, oneshot};

use super::*;
use crate::{
ff::{FieldType, Fp31},
helpers::{
query::QueryType::TestMultiply, transport::in_memory::InMemoryNetwork, HelperIdentity,
OrderingSender,
query::{QueryConfig, QueryType::TestMultiply},
transport::in_memory::{
transport::{Addr, ConnectionTx, Error, InMemoryStream, InMemoryTransport},
InMemoryNetwork, Setup,
},
HelperIdentity, OrderingSender, RouteId, Transport, TransportCallbacks,
},
protocol::{step::Gate, QueryId},
sync::Arc,
};

const STEP: &str = "in-memory-transport";
Expand Down
5 changes: 4 additions & 1 deletion ipa-core/src/helpers/transport/stream/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,13 +460,16 @@ mod test {
use super::*;

mod unit_test {
use std::io;

use futures::{StreamExt, TryStreamExt};
use generic_array::GenericArray;
use typenum::Unsigned;

use super::*;
use crate::{
error::Error,
ff::{Fp31, Fp32BitPrime, Serializable},
helpers::RecordsStream,
secret_sharing::replicated::semi_honest::AdditiveShare,
};

Expand Down
7 changes: 4 additions & 3 deletions ipa-core/src/hpke/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,16 @@ pub(crate) fn seal_in_place<'a, R: CryptoRng + RngCore, K: PublicKeyRegistry>(
#[cfg(all(test, unit_test))]
mod tests {
use generic_array::GenericArray;
use hpke::{aead::AeadTag, Serializable};
use rand::rngs::StdRng;
use rand_core::{CryptoRng, RngCore, SeedableRng};
use typenum::Unsigned;

use super::*;
use crate::{
ff::{Gf40Bit, Serializable as IpaSerializable},
report::{Epoch, EventType},
secret_sharing::replicated::ReplicatedSecretSharing,
hpke::{open_in_place, seal_in_place, CryptError, Info, IpaAead, KeyPair, KeyRegistry},
report::{Epoch, EventType, KeyIdentifier},
secret_sharing::replicated::{semi_honest::AdditiveShare, ReplicatedSecretSharing},
};

type XorReplicated = AdditiveShare<Gf40Bit>;
Expand Down
2 changes: 1 addition & 1 deletion ipa-core/src/net/server/handlers/query/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ mod tests {
Body, StatusCode,
};

use super::*;
use crate::{
ff::FieldType,
helpers::{
query::{IpaQueryConfig, QueryConfig, QueryType},
TransportCallbacks,
},
net::{
http_serde,
server::handlers::query::test_helpers::{assert_req_fails_with, IntoFailingReq},
test::TestServer,
},
Expand Down
9 changes: 6 additions & 3 deletions ipa-core/src/net/server/handlers/query/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,17 @@ pub fn router(transport: Arc<HttpTransport>) -> Router {

#[cfg(all(test, unit_test))]
mod tests {
use axum::http::Request;
use axum::{http::Request, Extension};
use hyper::{Body, StatusCode};

use super::*;
use crate::{
helpers::{query::QueryInput, BytesStream, TransportCallbacks},
net::{
server::handlers::query::test_helpers::{assert_req_fails_with, IntoFailingReq},
http_serde,
server::handlers::query::{
input::handler,
test_helpers::{assert_req_fails_with, IntoFailingReq},
},
test::TestServer,
},
protocol::QueryId,
Expand Down
5 changes: 3 additions & 2 deletions ipa-core/src/net/server/handlers/query/prepare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,20 @@ pub fn router(transport: Arc<HttpTransport>) -> Router {
mod tests {
use std::future::ready;

use axum::http::Request;
use axum::{http::Request, Extension};
use hyper::{Body, StatusCode};

use super::*;
use crate::{
ff::FieldType,
helpers::{
query::{PrepareQuery, QueryConfig, QueryType::TestMultiply},
HelperIdentity, RoleAssignment, TransportCallbacks,
},
net::{
http_serde,
server::{
handlers::query::{
prepare::handler,
test_helpers::{assert_req_fails_with, IntoFailingReq},
MaybeExtensionExt,
},
Expand Down
9 changes: 6 additions & 3 deletions ipa-core/src/net/server/handlers/query/results.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,18 @@ pub fn router(transport: Arc<HttpTransport>) -> Router {
mod tests {
use std::future::ready;

use axum::http::Request;
use axum::{http::Request, Extension};
use hyper::StatusCode;

use super::*;
use crate::{
ff::Fp31,
helpers::TransportCallbacks,
net::{
server::handlers::query::test_helpers::{assert_req_fails_with, IntoFailingReq},
http_serde,
server::handlers::query::{
results::handler,
test_helpers::{assert_req_fails_with, IntoFailingReq},
},
test::TestServer,
},
protocol::QueryId,
Expand Down
8 changes: 5 additions & 3 deletions ipa-core/src/net/server/handlers/query/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,17 @@ pub fn router(transport: Arc<HttpTransport>) -> Router {
mod tests {
use std::future::ready;

use axum::http::Request;
use axum::{http::Request, Extension, Json};
use hyper::StatusCode;

use super::*;
use crate::{
helpers::TransportCallbacks,
net::{
http_serde,
server::handlers::query::test_helpers::{assert_req_fails_with, IntoFailingReq},
server::handlers::query::{
status::handler,
test_helpers::{assert_req_fails_with, IntoFailingReq},
},
test::TestServer,
},
protocol::QueryId,
Expand Down
13 changes: 10 additions & 3 deletions ipa-core/src/protocol/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,18 @@ mod tests {
};
use typenum::Unsigned;

use super::*;
use crate::{
ff::{Field, Fp31, Serializable},
helpers::Direction,
protocol::{context::validator::Step::MaliciousProtocol, prss::SharedRandomness, RecordId},
helpers::{Direction, Role},
protocol::{
context::{
validator::Step::MaliciousProtocol, Context, UpgradableContext, UpgradedContext,
Validator,
},
prss::SharedRandomness,
step::{Gate, StepNarrow},
RecordId,
},
secret_sharing::replicated::{
malicious::{AdditiveShare as MaliciousReplicated, ExtendableField},
semi_honest::AdditiveShare as Replicated,
Expand Down
4 changes: 2 additions & 2 deletions ipa-core/src/protocol/dp/distributions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ impl From<BoxMuller> for RoundedBoxMuller {
mod tests {
use std::iter::repeat_with;

use rand::{distributions::Distribution, thread_rng};
use rand::{distributions::Distribution, thread_rng, Rng};
use rand_core::RngCore;

use super::*;
use crate::protocol::dp::distributions::{is_close, BoxMuller};

#[test]
fn dp_normal_distribution_sample_standard() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ where
mod test {
use std::{
array,
iter::{repeat, repeat_with, zip, Iterator},
iter::{repeat, repeat_with, zip},
time::Instant,
};

Expand Down
2 changes: 0 additions & 2 deletions ipa-core/src/protocol/prss/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,6 @@ impl EndpointSetup {

#[cfg(all(test, unit_test))]
pub mod test {
use std::mem::drop;

use rand::prelude::SliceRandom;

use super::{Generator, KeyExchange, SequentialSharedRandomness};
Expand Down
9 changes: 7 additions & 2 deletions ipa-core/src/query/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,17 @@ mod tests {
use futures_util::future::poll_immediate;
use tokio::sync::Barrier;

use super::*;
use crate::{
ff::FieldType,
helpers::{
query::QueryType::TestMultiply, HelperIdentity, InMemoryNetwork, PrepareQueryCallback,
query::{PrepareQuery, QueryConfig, QueryType::TestMultiply},
HelperIdentity, InMemoryNetwork, PrepareQueryCallback, RoleAssignment, Transport,
TransportCallbacks,
},
protocol::QueryId,
query::{
processor::Processor, state::StateError, NewQueryError, PrepareQueryError, QueryStatus,
},
};

fn prepare_query_callback<T, F, Fut>(cb: F) -> Box<dyn PrepareQueryCallback<T>>
Expand Down Expand Up @@ -466,6 +470,7 @@ mod tests {

mod prepare {
use super::*;
use crate::query::QueryStatusError;

fn prepare_query(identities: [HelperIdentity; 3]) -> PrepareQuery {
PrepareQuery {
Expand Down
14 changes: 11 additions & 3 deletions ipa-core/src/query/runner/oprf_ipa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,22 @@ where

#[cfg(all(test, unit_test))]
mod tests {
use std::iter::zip;
use std::{iter::zip, sync::Arc};

use rand::rngs::StdRng;
use rand_core::SeedableRng;

use super::*;
use crate::{
ff::{Field, Fp31},
ff::{
boolean_array::{BA20, BA3, BA8},
Field, Fp31,
},
helpers::{
query::{IpaQueryConfig, QuerySize},
BodyStream,
},
hpke::KeyRegistry,
query::runner::OprfIpaQuery,
report::{OprfReport, DEFAULT_KEY_ID},
secret_sharing::IntoShares,
test_fixture::{ipa::TestRawDataRecord, join3v, Reconstruct, TestWorld},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,11 +510,11 @@ mod tests {
proptest,
};

use super::*;
use crate::{
ff::{Field, Fp31, Fp32BitPrime},
secret_sharing::{
replicated::ReplicatedSecretSharing, SharedValue, StdArray, Vectorizable,
replicated::{semi_honest::AdditiveShare, ReplicatedSecretSharing},
SharedValue, StdArray, Vectorizable,
},
};

Expand Down
10 changes: 6 additions & 4 deletions ipa-core/src/seq_join/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,18 @@ pub use multi_thread::SequentialFutures;

#[cfg(all(test, any(unit_test, feature = "shuttle")))]
mod test {
use std::{convert::Infallible, iter::once, task::Poll};
use std::{convert::Infallible, iter::once, num::NonZeroUsize, task::Poll};

use futures::{
future::{lazy, BoxFuture},
stream::{iter, poll_immediate},
Future, StreamExt,
Future, Stream, StreamExt,
};

use super::*;
use crate::test_executor::run;
use crate::{
seq_join::{seq_join, seq_try_join_all},
test_executor::run,
};

async fn immediate(count: u32) {
let capacity = NonZeroUsize::new(3).unwrap();
Expand Down
4 changes: 0 additions & 4 deletions ipa-core/src/seq_join/multi_thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@ use futures::{stream::Fuse, StreamExt};
use pin_project::pin_project;
use tracing::{Instrument, Span};

use super::*;

#[cfg(feature = "shuttle")]
mod shuttle_spawner {
use shuttle_crate::future::{self, JoinError, JoinHandle};

use super::*;

/// Spawner implementation for Shuttle framework to run tests in parallel
pub(super) struct ShuttleSpawner;

Expand Down

0 comments on commit 1076faf

Please sign in to comment.