Change imports_granularity to module

This reduces the overall amount of LoC that imports take up in our
codebase by almost 100.
It also makes merge-conflicts less likely because there is less
grouping together of imports that may lead to layout changes which
in turn can cause merge conflicts.
This commit is contained in:
Thomas Eizinger 2021-03-04 11:28:58 +11:00
parent 2c8200621d
commit 6d9b21cb47
No known key found for this signature in database
GPG key ID: 651AC83A6C6C8B96
55 changed files with 389 additions and 483 deletions

View file

@ -1,7 +1,9 @@
pub mod testutils;
use swap::protocol::{bob, bob::BobState};
use testutils::{bob_run_until::is_btc_locked, FastCancelConfig};
use swap::protocol::bob;
use swap::protocol::bob::BobState;
use testutils::bob_run_until::is_btc_locked;
use testutils::FastCancelConfig;
#[tokio::test]
async fn given_bob_manually_refunds_after_btc_locked_bob_refunds() {

View file

@ -1,8 +1,10 @@
pub mod testutils;
use bob::cancel::CancelError;
use swap::protocol::{bob, bob::BobState};
use testutils::{bob_run_until::is_btc_locked, SlowCancelConfig};
use swap::protocol::bob;
use swap::protocol::bob::BobState;
use testutils::bob_run_until::is_btc_locked;
use testutils::SlowCancelConfig;
#[tokio::test]
async fn given_bob_manually_cancels_when_timelock_not_expired_errors() {

View file

@ -1,7 +1,9 @@
pub mod testutils;
use swap::protocol::{bob, bob::BobState};
use testutils::{bob_run_until::is_btc_locked, SlowCancelConfig};
use swap::protocol::bob;
use swap::protocol::bob::BobState;
use testutils::bob_run_until::is_btc_locked;
use testutils::SlowCancelConfig;
#[tokio::test]
async fn given_bob_manually_forces_cancel_when_timelock_not_expired_errors() {

View file

@ -1,7 +1,9 @@
pub mod testutils;
use swap::protocol::{bob, bob::BobState};
use testutils::{bob_run_until::is_xmr_locked, SlowCancelConfig};
use swap::protocol::bob;
use swap::protocol::bob::BobState;
use testutils::bob_run_until::is_xmr_locked;
use testutils::SlowCancelConfig;
#[tokio::test]
async fn given_bob_restarts_after_xmr_is_locked_resume_swap() {

View file

@ -1,8 +1,6 @@
use std::collections::HashMap;
use testcontainers::{
core::{Container, Docker, WaitForMessage},
Image,
};
use testcontainers::core::{Container, Docker, WaitForMessage};
use testcontainers::Image;
pub const RPC_USER: &str = "admin";
pub const RPC_PASSWORD: &str = "123";

View file

@ -1,10 +1,8 @@
use crate::testutils::bitcoind;
use bitcoin::Network;
use std::collections::HashMap;
use testcontainers::{
core::{Container, Docker, WaitForMessage},
Image,
};
use testcontainers::core::{Container, Docker, WaitForMessage};
use testcontainers::Image;
pub const HTTP_PORT: u16 = 60401;
pub const RPC_PORT: u16 = 3002;

View file

@ -4,30 +4,32 @@ mod electrs;
use crate::testutils;
use anyhow::{Context, Result};
use bitcoin_harness::{BitcoindRpcApi, Client};
use futures::{future::RemoteHandle, Future};
use futures::future::RemoteHandle;
use futures::Future;
use get_port::get_port;
use libp2p::{core::Multiaddr, PeerId};
use libp2p::core::Multiaddr;
use libp2p::PeerId;
use monero_harness::{image, Monero};
use std::{
convert::Infallible,
path::{Path, PathBuf},
sync::Arc,
time::Duration,
};
use swap::{
asb::{fixed_rate, fixed_rate::RATE},
bitcoin,
bitcoin::{CancelTimelock, PunishTimelock},
database::Database,
execution_params,
execution_params::{ExecutionParams, GetExecutionParams},
monero,
protocol::{alice, alice::AliceState, bob, bob::BobState},
seed::Seed,
};
use std::convert::Infallible;
use std::path::{Path, PathBuf};
use std::sync::Arc;
use std::time::Duration;
use swap::asb::fixed_rate;
use swap::asb::fixed_rate::RATE;
use swap::bitcoin::{CancelTimelock, PunishTimelock};
use swap::database::Database;
use swap::execution_params::{ExecutionParams, GetExecutionParams};
use swap::protocol::alice::AliceState;
use swap::protocol::bob::BobState;
use swap::protocol::{alice, bob};
use swap::seed::Seed;
use swap::{bitcoin, execution_params, monero};
use tempfile::tempdir;
use testcontainers::{clients::Cli, Container, Docker, RunArgs};
use tokio::{sync::mpsc, task::JoinHandle, time::interval};
use testcontainers::clients::Cli;
use testcontainers::{Container, Docker, RunArgs};
use tokio::sync::mpsc;
use tokio::task::JoinHandle;
use tokio::time::interval;
use tracing::dispatcher::DefaultGuard;
use tracing_log::LogTracer;
use url::Url;
@ -445,7 +447,8 @@ where
}
fn random_prefix() -> String {
use rand::{distributions::Alphanumeric, thread_rng, Rng};
use rand::distributions::Alphanumeric;
use rand::{thread_rng, Rng};
use std::iter;
const LEN: usize = 8;
let mut rng = thread_rng();