diff --git a/monero-harness/src/lib.rs b/monero-harness/src/lib.rs index 067b69da..f53f5c74 100644 --- a/monero-harness/src/lib.rs +++ b/monero-harness/src/lib.rs @@ -20,15 +20,9 @@ //! every BLOCK_TIME_SECS seconds. //! //! Also provides standalone JSON RPC clients for monerod and monero-wallet-rpc. - pub mod image; pub mod rpc; -use anyhow::{anyhow, bail, Result}; -use std::time::Duration; -use testcontainers::{clients::Cli, core::Port, Container, Docker, RunArgs}; -use tokio::time; - use crate::{ image::{ MONEROD_DAEMON_CONTAINER_NAME, MONEROD_DEFAULT_NETWORK, MONEROD_RPC_PORT, WALLET_RPC_PORT, @@ -38,6 +32,10 @@ use crate::{ wallet::{self, GetAddress, Refreshed, Transfer}, }, }; +use anyhow::{anyhow, bail, Result}; +use std::time::Duration; +use testcontainers::{clients::Cli, core::Port, Container, Docker, RunArgs}; +use tokio::time; /// How often we mine a block. const BLOCK_TIME_SECS: u64 = 1; diff --git a/swap/src/bitcoin.rs b/swap/src/bitcoin.rs index ea03470e..9948e5aa 100644 --- a/swap/src/bitcoin.rs +++ b/swap/src/bitcoin.rs @@ -1,3 +1,16 @@ +pub mod timelocks; +pub mod transactions; +pub mod wallet; + +pub use crate::bitcoin::{ + timelocks::Timelock, + transactions::{TxCancel, TxLock, TxPunish, TxRedeem, TxRefund}, +}; +pub use ::bitcoin::{util::amount::Amount, Address, Network, Transaction, Txid}; +pub use ecdsa_fun::{adaptor::EncryptedSignature, fun::Scalar, Signature}; +pub use wallet::Wallet; + +use crate::{bitcoin::timelocks::BlockHeight, config::Config, ExpiredTimelocks}; use ::bitcoin::{ hashes::{hex::ToHex, Hash}, secp256k1, @@ -13,20 +26,6 @@ use serde::{Deserialize, Serialize}; use sha2::Sha256; use std::str::FromStr; -use crate::{bitcoin::timelocks::BlockHeight, config::Config, ExpiredTimelocks}; - -pub use crate::bitcoin::{ - timelocks::Timelock, - transactions::{TxCancel, TxLock, TxPunish, TxRedeem, TxRefund}, -}; -pub use ::bitcoin::{util::amount::Amount, Address, Network, Transaction, Txid}; -pub use ecdsa_fun::{adaptor::EncryptedSignature, fun::Scalar, Signature}; -pub use wallet::Wallet; - -pub mod timelocks; -pub mod transactions; -pub mod wallet; - // TODO: Configurable tx-fee (note: parties have to agree prior to swapping) // Current reasoning: // tx with largest weight (as determined by get_weight() upon broadcast in e2e diff --git a/swap/src/bitcoin/transactions.rs b/swap/src/bitcoin/transactions.rs index d8d2c059..6ac7c9de 100644 --- a/swap/src/bitcoin/transactions.rs +++ b/swap/src/bitcoin/transactions.rs @@ -1,3 +1,7 @@ +use crate::bitcoin::{ + build_shared_output_descriptor, timelocks::Timelock, verify_sig, Address, Amount, + BuildTxLockPsbt, GetNetwork, PublicKey, Transaction, TX_FEE, +}; use ::bitcoin::{ util::{bip143::SigHashCache, psbt::PartiallySignedTransaction}, OutPoint, SigHash, SigHashType, TxIn, TxOut, Txid, @@ -8,11 +12,6 @@ use miniscript::{Descriptor, NullCtx}; use serde::{Deserialize, Serialize}; use std::collections::HashMap; -use crate::bitcoin::{ - build_shared_output_descriptor, timelocks::Timelock, verify_sig, Address, Amount, - BuildTxLockPsbt, GetNetwork, PublicKey, Transaction, TX_FEE, -}; - #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] pub struct TxLock { inner: Transaction, diff --git a/swap/src/bitcoin/wallet.rs b/swap/src/bitcoin/wallet.rs index 6cbc777b..cecfd62e 100644 --- a/swap/src/bitcoin/wallet.rs +++ b/swap/src/bitcoin/wallet.rs @@ -1,12 +1,3 @@ -use ::bitcoin::{util::psbt::PartiallySignedTransaction, Txid}; -use anyhow::{Context, Result}; -use async_trait::async_trait; -use backoff::{backoff::Constant as ConstantBackoff, future::FutureOperation as _}; -use bitcoin_harness::{bitcoind_rpc::PsbtBase64, BitcoindRpcApi}; -use reqwest::Url; -use std::time::Duration; -use tokio::time::interval; - use crate::{ bitcoin::{ timelocks::BlockHeight, Address, Amount, BroadcastSignedTransaction, BuildTxLockPsbt, @@ -15,6 +6,14 @@ use crate::{ }, config::Config, }; +use ::bitcoin::{util::psbt::PartiallySignedTransaction, Txid}; +use anyhow::{Context, Result}; +use async_trait::async_trait; +use backoff::{backoff::Constant as ConstantBackoff, future::FutureOperation as _}; +use bitcoin_harness::{bitcoind_rpc::PsbtBase64, BitcoindRpcApi}; +use reqwest::Url; +use std::time::Duration; +use tokio::time::interval; #[derive(Debug)] pub struct Wallet { diff --git a/swap/src/cli.rs b/swap/src/cli.rs index b762edd0..a2a48a48 100644 --- a/swap/src/cli.rs +++ b/swap/src/cli.rs @@ -1,9 +1,8 @@ +use crate::{bitcoin, monero}; use libp2p::{core::Multiaddr, PeerId}; use url::Url; use uuid::Uuid; -use crate::{bitcoin, monero}; - #[derive(structopt::StructOpt, Debug)] pub struct Options { // TODO: Default value should points to proper configuration folder in home folder diff --git a/swap/src/database.rs b/swap/src/database.rs index fa7a8b8a..33c02b0c 100644 --- a/swap/src/database.rs +++ b/swap/src/database.rs @@ -1,3 +1,6 @@ +pub use alice::Alice; +pub use bob::Bob; + use anyhow::{anyhow, bail, Context, Result}; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use std::{fmt::Display, path::Path}; @@ -6,9 +9,6 @@ use uuid::Uuid; mod alice; mod bob; -pub use alice::Alice; -pub use bob::Bob; - #[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] pub enum Swap { Alice(Alice), diff --git a/swap/src/lib.rs b/swap/src/lib.rs index 569148ba..ab951533 100644 --- a/swap/src/lib.rs +++ b/swap/src/lib.rs @@ -16,19 +16,20 @@ missing_copy_implementations )] -use serde::{Deserialize, Serialize}; -use std::fmt::{self, Display}; - pub mod bitcoin; pub mod config; pub mod database; -mod fs; pub mod monero; pub mod network; pub mod protocol; pub mod seed; pub mod trace; +mod fs; + +use serde::{Deserialize, Serialize}; +use std::fmt::{self, Display}; + pub type Never = std::convert::Infallible; /// XMR/BTC swap amounts. diff --git a/swap/src/monero.rs b/swap/src/monero.rs index 499e248d..1b65bc10 100644 --- a/swap/src/monero.rs +++ b/swap/src/monero.rs @@ -1,5 +1,10 @@ pub mod wallet; +pub use ::monero::{Network, PrivateKey, PublicKey}; +pub use curve25519_dalek::scalar::Scalar; +pub use wallet::Wallet; + +use crate::bitcoin; use ::bitcoin::hashes::core::fmt::Formatter; use anyhow::Result; use async_trait::async_trait; @@ -15,12 +20,6 @@ use std::{ str::FromStr, }; -use crate::bitcoin; - -pub use ::monero::{Network, PrivateKey, PublicKey}; -pub use curve25519_dalek::scalar::Scalar; -pub use wallet::Wallet; - pub const PICONERO_OFFSET: u64 = 1_000_000_000_000; pub fn private_key_from_secp256k1_scalar(scalar: bitcoin::Scalar) -> PrivateKey { diff --git a/swap/src/monero/wallet.rs b/swap/src/monero/wallet.rs index 7f5dec6c..2f26568d 100644 --- a/swap/src/monero/wallet.rs +++ b/swap/src/monero/wallet.rs @@ -1,3 +1,7 @@ +use crate::monero::{ + Amount, CreateWalletForOutput, InsufficientFunds, PrivateViewKey, PublicViewKey, Transfer, + TransferProof, TxHash, WatchForTransfer, +}; use ::monero::{Address, Network, PrivateKey, PublicKey}; use anyhow::Result; use async_trait::async_trait; @@ -12,11 +16,6 @@ use std::{ use tracing::info; use url::Url; -use crate::monero::{ - Amount, CreateWalletForOutput, InsufficientFunds, PrivateViewKey, PublicViewKey, Transfer, - TransferProof, TxHash, WatchForTransfer, -}; - #[derive(Debug)] pub struct Wallet { pub inner: wallet::Client, diff --git a/swap/src/network.rs b/swap/src/network.rs index 0b0a70df..917b9977 100644 --- a/swap/src/network.rs +++ b/swap/src/network.rs @@ -1,3 +1,7 @@ +pub mod peer_tracker; +pub mod request_response; +pub mod transport; + use crate::seed::SEED_LENGTH; use bitcoin::hashes::{sha256, Hash, HashEngine}; use futures::prelude::*; @@ -5,10 +9,6 @@ use libp2p::{core::Executor, identity::ed25519}; use std::pin::Pin; use tokio::runtime::Handle; -pub mod peer_tracker; -pub mod request_response; -pub mod transport; - #[allow(missing_debug_implementations)] pub struct TokioExecutor { pub handle: Handle, diff --git a/swap/src/protocol/alice.rs b/swap/src/protocol/alice.rs index e15d55a7..096d39c7 100644 --- a/swap/src/protocol/alice.rs +++ b/swap/src/protocol/alice.rs @@ -1,5 +1,14 @@ //! Run an XMR/BTC swap in the role of Alice. //! Alice holds XMR and wishes receive BTC. +pub use self::{ + event_loop::{EventLoop, EventLoopHandle}, + message0::Message0, + message1::Message1, + message2::Message2, + state::*, + swap::{run, run_until}, + swap_response::*, +}; use crate::{ bitcoin, config::Config, @@ -25,16 +34,6 @@ use std::{path::PathBuf, sync::Arc}; use tracing::{debug, info}; use uuid::Uuid; -pub use self::{ - event_loop::{EventLoop, EventLoopHandle}, - message0::Message0, - message1::Message1, - message2::Message2, - state::*, - swap::{run, run_until}, - swap_response::*, -}; - pub mod event_loop; mod message0; mod message1; diff --git a/swap/src/protocol/alice/event_loop.rs b/swap/src/protocol/alice/event_loop.rs index 6a643c63..a648d1a6 100644 --- a/swap/src/protocol/alice/event_loop.rs +++ b/swap/src/protocol/alice/event_loop.rs @@ -1,10 +1,3 @@ -use anyhow::{anyhow, Context, Result}; -use futures::FutureExt; -use libp2p::{ - core::Multiaddr, futures::StreamExt, request_response::ResponseChannel, PeerId, Swarm, -}; -use tokio::sync::mpsc::{Receiver, Sender}; - use crate::{ network::{request_response::AliceToBob, transport::SwapTransport, TokioExecutor}, protocol::{ @@ -13,6 +6,12 @@ use crate::{ bob, }, }; +use anyhow::{anyhow, Context, Result}; +use futures::FutureExt; +use libp2p::{ + core::Multiaddr, futures::StreamExt, request_response::ResponseChannel, PeerId, Swarm, +}; +use tokio::sync::mpsc::{Receiver, Sender}; #[allow(missing_debug_implementations)] pub struct Channels { diff --git a/swap/src/protocol/alice/message0.rs b/swap/src/protocol/alice/message0.rs index 76e57c1b..a58d95eb 100644 --- a/swap/src/protocol/alice/message0.rs +++ b/swap/src/protocol/alice/message0.rs @@ -1,3 +1,8 @@ +use crate::{ + bitcoin, monero, + network::request_response::{AliceToBob, BobToAlice, Codec, Message0Protocol, TIMEOUT}, + protocol::bob, +}; use libp2p::{ request_response::{ handler::RequestProtocol, ProtocolSupport, RequestResponse, RequestResponseConfig, @@ -14,12 +19,6 @@ use std::{ }; use tracing::{debug, error}; -use crate::{ - bitcoin, monero, - network::request_response::{AliceToBob, BobToAlice, Codec, Message0Protocol, TIMEOUT}, - protocol::bob, -}; - #[derive(Debug)] pub enum OutEvent { Msg { diff --git a/swap/src/protocol/alice/message1.rs b/swap/src/protocol/alice/message1.rs index c04faa9a..95050905 100644 --- a/swap/src/protocol/alice/message1.rs +++ b/swap/src/protocol/alice/message1.rs @@ -1,3 +1,7 @@ +use crate::{ + network::request_response::{AliceToBob, BobToAlice, Codec, Message1Protocol, TIMEOUT}, + protocol::bob, +}; use ecdsa_fun::{adaptor::EncryptedSignature, Signature}; use libp2p::{ request_response::{ @@ -15,11 +19,6 @@ use std::{ }; use tracing::{debug, error}; -use crate::{ - network::request_response::{AliceToBob, BobToAlice, Codec, Message1Protocol, TIMEOUT}, - protocol::bob, -}; - #[derive(Debug)] pub enum OutEvent { Msg { diff --git a/swap/src/protocol/alice/message2.rs b/swap/src/protocol/alice/message2.rs index 9b92758e..d383ff11 100644 --- a/swap/src/protocol/alice/message2.rs +++ b/swap/src/protocol/alice/message2.rs @@ -1,3 +1,8 @@ +use crate::{ + monero, + network::request_response::{AliceToBob, BobToAlice, Codec, Message2Protocol, TIMEOUT}, + protocol::bob, +}; use libp2p::{ request_response::{ handler::RequestProtocol, ProtocolSupport, RequestResponse, RequestResponseConfig, @@ -14,12 +19,6 @@ use std::{ }; use tracing::{debug, error}; -use crate::{ - monero, - network::request_response::{AliceToBob, BobToAlice, Codec, Message2Protocol, TIMEOUT}, - protocol::bob, -}; - #[derive(Debug)] pub enum OutEvent { Msg { diff --git a/swap/src/protocol/alice/message3.rs b/swap/src/protocol/alice/message3.rs index d5f6b563..9c85cc96 100644 --- a/swap/src/protocol/alice/message3.rs +++ b/swap/src/protocol/alice/message3.rs @@ -1,3 +1,7 @@ +use crate::{ + network::request_response::{AliceToBob, BobToAlice, Codec, Message3Protocol, TIMEOUT}, + protocol::bob, +}; use libp2p::{ request_response::{ handler::RequestProtocol, ProtocolSupport, RequestResponse, RequestResponseConfig, @@ -13,11 +17,6 @@ use std::{ }; use tracing::{debug, error}; -use crate::{ - network::request_response::{AliceToBob, BobToAlice, Codec, Message3Protocol, TIMEOUT}, - protocol::bob, -}; - #[derive(Debug)] pub enum OutEvent { Msg(bob::Message3), diff --git a/swap/src/protocol/alice/state.rs b/swap/src/protocol/alice/state.rs index 89f43d52..7c318772 100644 --- a/swap/src/protocol/alice/state.rs +++ b/swap/src/protocol/alice/state.rs @@ -1,15 +1,3 @@ -use anyhow::{anyhow, Context, Result}; -use ecdsa_fun::{ - adaptor::{Adaptor, EncryptedSignature}, - nonce::Deterministic, -}; -use libp2p::request_response::ResponseChannel; -use rand::{CryptoRng, RngCore}; -use serde::{Deserialize, Serialize}; -use sha2::Sha256; -use std::fmt; -use tracing::info; - use crate::{ bitcoin, bitcoin::{ @@ -22,6 +10,17 @@ use crate::{ protocol::{alice, bob}, ExpiredTimelocks, SwapAmounts, }; +use anyhow::{anyhow, Context, Result}; +use ecdsa_fun::{ + adaptor::{Adaptor, EncryptedSignature}, + nonce::Deterministic, +}; +use libp2p::request_response::ResponseChannel; +use rand::{CryptoRng, RngCore}; +use serde::{Deserialize, Serialize}; +use sha2::Sha256; +use std::fmt; +use tracing::info; #[derive(Debug)] pub enum AliceState { diff --git a/swap/src/protocol/alice/swap.rs b/swap/src/protocol/alice/swap.rs index 0b7ffae8..e753a54d 100644 --- a/swap/src/protocol/alice/swap.rs +++ b/swap/src/protocol/alice/swap.rs @@ -1,16 +1,5 @@ //! Run an XMR/BTC swap in the role of Alice. //! Alice holds XMR and wishes receive BTC. -use anyhow::{bail, Result}; -use async_recursion::async_recursion; -use futures::{ - future::{select, Either}, - pin_mut, -}; -use rand::{CryptoRng, RngCore}; -use std::sync::Arc; -use tracing::{error, info}; -use uuid::Uuid; - use crate::{ bitcoin, bitcoin::{TransactionBlockHeight, WaitForTransactionFinality, WatchForRawTransaction}, @@ -35,6 +24,16 @@ use crate::{ }, ExpiredTimelocks, }; +use anyhow::{bail, Result}; +use async_recursion::async_recursion; +use futures::{ + future::{select, Either}, + pin_mut, +}; +use rand::{CryptoRng, RngCore}; +use std::sync::Arc; +use tracing::{error, info}; +use uuid::Uuid; trait Rng: RngCore + CryptoRng + Send {} diff --git a/swap/src/protocol/bob/message0.rs b/swap/src/protocol/bob/message0.rs index d1b2a57a..3e956fe8 100644 --- a/swap/src/protocol/bob/message0.rs +++ b/swap/src/protocol/bob/message0.rs @@ -1,3 +1,8 @@ +use crate::{ + bitcoin, monero, + network::request_response::{AliceToBob, BobToAlice, Codec, Message0Protocol, TIMEOUT}, + protocol::{alice, bob}, +}; use libp2p::{ request_response::{ handler::RequestProtocol, ProtocolSupport, RequestResponse, RequestResponseConfig, @@ -14,12 +19,6 @@ use std::{ }; use tracing::{debug, error}; -use crate::{ - bitcoin, monero, - network::request_response::{AliceToBob, BobToAlice, Codec, Message0Protocol, TIMEOUT}, - protocol::{alice, bob}, -}; - #[derive(Clone, Debug, Serialize, Deserialize)] pub struct Message0 { pub(crate) B: bitcoin::PublicKey, diff --git a/swap/src/protocol/bob/message1.rs b/swap/src/protocol/bob/message1.rs index fbae5ace..f783af1d 100644 --- a/swap/src/protocol/bob/message1.rs +++ b/swap/src/protocol/bob/message1.rs @@ -1,3 +1,8 @@ +use crate::{ + bitcoin, + network::request_response::{AliceToBob, BobToAlice, Codec, Message1Protocol, TIMEOUT}, + protocol::alice, +}; use libp2p::{ request_response::{ handler::RequestProtocol, ProtocolSupport, RequestResponse, RequestResponseConfig, @@ -14,12 +19,6 @@ use std::{ }; use tracing::{debug, error}; -use crate::{ - bitcoin, - network::request_response::{AliceToBob, BobToAlice, Codec, Message1Protocol, TIMEOUT}, - protocol::alice, -}; - #[derive(Clone, Debug, Serialize, Deserialize)] pub struct Message1 { pub(crate) tx_lock: bitcoin::TxLock, diff --git a/swap/src/protocol/bob/message2.rs b/swap/src/protocol/bob/message2.rs index 62c55147..edda820e 100644 --- a/swap/src/protocol/bob/message2.rs +++ b/swap/src/protocol/bob/message2.rs @@ -1,3 +1,7 @@ +use crate::{ + network::request_response::{AliceToBob, BobToAlice, Codec, Message2Protocol, TIMEOUT}, + protocol::alice, +}; use ecdsa_fun::Signature; use libp2p::{ request_response::{ @@ -15,11 +19,6 @@ use std::{ }; use tracing::{debug, error}; -use crate::{ - network::request_response::{AliceToBob, BobToAlice, Codec, Message2Protocol, TIMEOUT}, - protocol::alice, -}; - #[derive(Clone, Debug, Serialize, Deserialize)] pub struct Message2 { pub(crate) tx_punish_sig: Signature, diff --git a/swap/src/protocol/bob/message3.rs b/swap/src/protocol/bob/message3.rs index 7c9e2df6..f9703ad1 100644 --- a/swap/src/protocol/bob/message3.rs +++ b/swap/src/protocol/bob/message3.rs @@ -1,3 +1,7 @@ +use crate::{ + bitcoin::EncryptedSignature, + network::request_response::{AliceToBob, BobToAlice, Codec, Message3Protocol, TIMEOUT}, +}; use libp2p::{ request_response::{ handler::RequestProtocol, ProtocolSupport, RequestResponse, RequestResponseConfig, @@ -14,11 +18,6 @@ use std::{ }; use tracing::error; -use crate::{ - bitcoin::EncryptedSignature, - network::request_response::{AliceToBob, BobToAlice, Codec, Message3Protocol, TIMEOUT}, -}; - #[derive(Clone, Debug, Serialize, Deserialize)] pub struct Message3 { pub tx_redeem_encsig: EncryptedSignature, diff --git a/swap/src/protocol/bob/state.rs b/swap/src/protocol/bob/state.rs index 5c8d348a..9e0de62e 100644 --- a/swap/src/protocol/bob/state.rs +++ b/swap/src/protocol/bob/state.rs @@ -1,14 +1,3 @@ -use anyhow::{anyhow, Result}; -use ecdsa_fun::{ - adaptor::{Adaptor, EncryptedSignature}, - nonce::Deterministic, - Signature, -}; -use rand::{CryptoRng, RngCore}; -use serde::{Deserialize, Serialize}; -use sha2::Sha256; -use std::fmt; - use crate::{ bitcoin::{ self, current_epoch, timelocks::Timelock, wait_for_cancel_timelock_to_expire, @@ -21,6 +10,16 @@ use crate::{ protocol::{alice, bob}, ExpiredTimelocks, SwapAmounts, }; +use anyhow::{anyhow, Result}; +use ecdsa_fun::{ + adaptor::{Adaptor, EncryptedSignature}, + nonce::Deterministic, + Signature, +}; +use rand::{CryptoRng, RngCore}; +use serde::{Deserialize, Serialize}; +use sha2::Sha256; +use std::fmt; #[derive(Debug, Clone)] pub enum BobState { diff --git a/swap/src/protocol/bob/swap.rs b/swap/src/protocol/bob/swap.rs index 208c978c..5cf65b5d 100644 --- a/swap/src/protocol/bob/swap.rs +++ b/swap/src/protocol/bob/swap.rs @@ -1,11 +1,3 @@ -use anyhow::{bail, Result}; -use async_recursion::async_recursion; -use rand::{rngs::OsRng, CryptoRng, RngCore}; -use std::sync::Arc; -use tokio::select; -use tracing::{debug, info}; -use uuid::Uuid; - use crate::{ bitcoin, config::Config, @@ -14,6 +6,13 @@ use crate::{ protocol::bob::{self, event_loop::EventLoopHandle, state::*, SwapRequest}, ExpiredTimelocks, SwapAmounts, }; +use anyhow::{bail, Result}; +use async_recursion::async_recursion; +use rand::{rngs::OsRng, CryptoRng, RngCore}; +use std::sync::Arc; +use tokio::select; +use tracing::{debug, info}; +use uuid::Uuid; pub fn is_complete(state: &BobState) -> bool { matches!( diff --git a/swap/tests/happy_path.rs b/swap/tests/happy_path.rs index 57789eed..435edfa8 100644 --- a/swap/tests/happy_path.rs +++ b/swap/tests/happy_path.rs @@ -1,8 +1,8 @@ +pub mod testutils; + use swap::protocol::{alice, bob}; use tokio::join; -pub mod testutils; - /// Run the following tests with RUST_MIN_STACK=10000000 #[tokio::test] diff --git a/swap/tests/happy_path_restart_alice.rs b/swap/tests/happy_path_restart_alice.rs index 1f298818..f557db8b 100644 --- a/swap/tests/happy_path_restart_alice.rs +++ b/swap/tests/happy_path_restart_alice.rs @@ -1,7 +1,7 @@ -use swap::protocol::{alice, alice::AliceState, bob}; - pub mod testutils; +use swap::protocol::{alice, alice::AliceState, bob}; + #[tokio::test] async fn given_alice_restarts_after_encsig_is_learned_resume_swap() { testutils::setup_test(|mut ctx| async move { diff --git a/swap/tests/happy_path_restart_bob_after_comm.rs b/swap/tests/happy_path_restart_bob_after_comm.rs index 93382734..ca6c62cc 100644 --- a/swap/tests/happy_path_restart_bob_after_comm.rs +++ b/swap/tests/happy_path_restart_bob_after_comm.rs @@ -1,7 +1,7 @@ -use swap::protocol::{alice, bob, bob::BobState}; - pub mod testutils; +use swap::protocol::{alice, bob, bob::BobState}; + #[tokio::test] async fn given_bob_restarts_after_encsig_is_sent_resume_swap() { testutils::setup_test(|mut ctx| async move { diff --git a/swap/tests/happy_path_restart_bob_before_comm.rs b/swap/tests/happy_path_restart_bob_before_comm.rs index bd190b4c..ffbbe4af 100644 --- a/swap/tests/happy_path_restart_bob_before_comm.rs +++ b/swap/tests/happy_path_restart_bob_before_comm.rs @@ -1,10 +1,10 @@ +pub mod testutils; + use swap::protocol::{ alice, bob, bob::{swap::is_xmr_locked, BobState}, }; -pub mod testutils; - #[tokio::test] async fn given_bob_restarts_after_xmr_is_locked_resume_swap() { testutils::setup_test(|mut ctx| async move { diff --git a/swap/tests/punish.rs b/swap/tests/punish.rs index cc7289c4..4262b4bd 100644 --- a/swap/tests/punish.rs +++ b/swap/tests/punish.rs @@ -1,10 +1,10 @@ +pub mod testutils; + use swap::protocol::{ alice, bob, bob::{swap::is_btc_locked, BobState}, }; -pub mod testutils; - /// Bob locks Btc and Alice locks Xmr. Bob does not act; he fails to send Alice /// the encsig and fail to refund or redeem. Alice punishes. #[tokio::test] diff --git a/swap/tests/refund_restart_alice.rs b/swap/tests/refund_restart_alice.rs index a4908c95..031efe48 100644 --- a/swap/tests/refund_restart_alice.rs +++ b/swap/tests/refund_restart_alice.rs @@ -1,7 +1,7 @@ -use swap::protocol::{alice, alice::AliceState, bob}; - pub mod testutils; +use swap::protocol::{alice, alice::AliceState, bob}; + /// Bob locks btc and Alice locks xmr. Alice fails to act so Bob refunds. Alice /// then also refunds. #[tokio::test]