mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-04-20 07:56:05 -04:00
Move tests under src/
This commit is contained in:
parent
9eae0db9ac
commit
99e34bfc6b
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
@ -107,8 +107,8 @@ jobs:
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
run: cargo test --package monero-harness --all-features
|
||||
|
||||
- name: Run library tests for swap
|
||||
run: cargo test --package swap --lib --all-features
|
||||
- name: Run library tests for swap (without test containers)
|
||||
run: cargo test --package swap --lib
|
||||
|
||||
- name: Build binary
|
||||
run: |
|
||||
@ -160,7 +160,7 @@ jobs:
|
||||
key: rust-${{ env.TARGET }}-cargo-registry-directory-${{ hashFiles('Cargo.lock') }}-v1
|
||||
|
||||
- name: Run test ${{ matrix.test_name }}
|
||||
run: cargo test --package swap --all-features --test ${{ matrix.test_name }} ""
|
||||
run: cargo test --package swap --all-features --lib tests::${{ matrix.test_name }} ""
|
||||
env:
|
||||
MONERO_ADDITIONAL_SLEEP_PERIOD: 60000
|
||||
RUST_MIN_STACK: 16777216 # 16 MB. Default is 8MB. This is fine as in tests we start 2 programs: Alice and Bob.
|
||||
|
@ -40,6 +40,7 @@ sled = "0.34"
|
||||
structopt = "0.3"
|
||||
strum = { version = "0.20", features = ["derive"] }
|
||||
tempfile = "3"
|
||||
testcontainers = { version = "0.11", optional = true }
|
||||
thiserror = "1"
|
||||
time = "0.2"
|
||||
tokio = { version = "1.0", features = ["rt-multi-thread", "time", "macros", "sync"] }
|
||||
@ -59,4 +60,6 @@ port_check = "0.1"
|
||||
serde_cbor = "0.11"
|
||||
spectral = "0.6"
|
||||
tempfile = "3"
|
||||
testcontainers = "0.11"
|
||||
|
||||
[features]
|
||||
default = [ ]
|
||||
|
@ -27,3 +27,6 @@ pub mod trace;
|
||||
|
||||
mod fs;
|
||||
mod serde_peer_id;
|
||||
|
||||
#[cfg(all(test, feature = "testcontainers"))]
|
||||
mod tests;
|
||||
|
@ -37,6 +37,8 @@ pub mod trace;
|
||||
mod cli;
|
||||
mod fs;
|
||||
mod serde_peer_id;
|
||||
#[cfg(all(test, feature = "testcontainers"))]
|
||||
mod tests;
|
||||
|
||||
#[macro_use]
|
||||
extern crate prettytable;
|
||||
|
@ -1,6 +1,7 @@
|
||||
pub mod testutils;
|
||||
|
||||
use swap::protocol::{alice, bob};
|
||||
use crate::{
|
||||
protocol::{alice, bob},
|
||||
tests::testutils,
|
||||
};
|
||||
use testutils::SlowCancelConfig;
|
||||
use tokio::join;
|
||||
|
@ -1,6 +1,7 @@
|
||||
pub mod testutils;
|
||||
|
||||
use swap::protocol::{alice, alice::AliceState, bob};
|
||||
use crate::{
|
||||
protocol::{alice, alice::AliceState, bob},
|
||||
tests::testutils,
|
||||
};
|
||||
use testutils::{alice_run_until::is_encsig_learned, SlowCancelConfig};
|
||||
|
||||
#[tokio::test]
|
@ -1,6 +1,7 @@
|
||||
pub mod testutils;
|
||||
|
||||
use swap::protocol::{alice, bob, bob::BobState};
|
||||
use crate::{
|
||||
protocol::{alice, bob, bob::BobState},
|
||||
tests::testutils,
|
||||
};
|
||||
use testutils::{bob_run_until::is_encsig_sent, SlowCancelConfig};
|
||||
|
||||
#[tokio::test]
|
@ -1,6 +1,7 @@
|
||||
pub mod testutils;
|
||||
|
||||
use swap::protocol::{alice, bob, bob::BobState};
|
||||
use crate::{
|
||||
protocol::{alice, bob, bob::BobState},
|
||||
tests::testutils,
|
||||
};
|
||||
use testutils::{bob_run_until::is_lock_proof_received, SlowCancelConfig};
|
||||
|
||||
#[tokio::test]
|
@ -1,6 +1,7 @@
|
||||
pub mod testutils;
|
||||
|
||||
use swap::protocol::{alice, bob, bob::BobState};
|
||||
use crate::{
|
||||
protocol::{alice, bob, bob::BobState},
|
||||
tests::testutils,
|
||||
};
|
||||
use testutils::{bob_run_until::is_xmr_locked, SlowCancelConfig};
|
||||
|
||||
#[tokio::test]
|
9
swap/src/tests/mod.rs
Normal file
9
swap/src/tests/mod.rs
Normal file
@ -0,0 +1,9 @@
|
||||
mod happy_path;
|
||||
mod happy_path_restart_alice;
|
||||
mod happy_path_restart_bob_after_comm;
|
||||
mod happy_path_restart_bob_after_lock_proof_received;
|
||||
mod happy_path_restart_bob_before_comm;
|
||||
mod punish;
|
||||
mod refund_restart_alice;
|
||||
mod refund_restart_alice_cancelled;
|
||||
pub mod testutils;
|
@ -1,6 +1,7 @@
|
||||
pub mod testutils;
|
||||
|
||||
use swap::protocol::{alice, bob, bob::BobState};
|
||||
use crate::{
|
||||
protocol::{alice, bob, bob::BobState},
|
||||
tests::testutils,
|
||||
};
|
||||
use testutils::{bob_run_until::is_btc_locked, FastPunishConfig};
|
||||
|
||||
/// Bob locks Btc and Alice locks Xmr. Bob does not act; he fails to send Alice
|
@ -1,6 +1,7 @@
|
||||
pub mod testutils;
|
||||
|
||||
use swap::protocol::{alice, alice::AliceState, bob};
|
||||
use crate::{
|
||||
protocol::{alice, alice::AliceState, bob},
|
||||
tests::testutils,
|
||||
};
|
||||
use testutils::{alice_run_until::is_xmr_locked, FastCancelConfig};
|
||||
|
||||
/// Bob locks btc and Alice locks xmr. Alice fails to act so Bob refunds. Alice
|
@ -1,8 +1,7 @@
|
||||
pub mod testutils;
|
||||
|
||||
use swap::{
|
||||
use crate::{
|
||||
config,
|
||||
protocol::{alice, alice::AliceState, bob},
|
||||
tests::testutils,
|
||||
};
|
||||
use testutils::alice_run_until::is_encsig_learned;
|
||||
|
@ -1,11 +1,4 @@
|
||||
use crate::testutils;
|
||||
use bitcoin_harness::Bitcoind;
|
||||
use futures::Future;
|
||||
use get_port::get_port;
|
||||
use libp2p::{core::Multiaddr, PeerId};
|
||||
use monero_harness::{image, Monero};
|
||||
use std::{path::PathBuf, sync::Arc};
|
||||
use swap::{
|
||||
use crate::{
|
||||
bitcoin,
|
||||
bitcoin::Timelock,
|
||||
config,
|
||||
@ -13,7 +6,14 @@ use swap::{
|
||||
monero,
|
||||
protocol::{alice, alice::AliceState, bob, bob::BobState, SwapAmounts},
|
||||
seed::Seed,
|
||||
tests::testutils,
|
||||
};
|
||||
use bitcoin_harness::Bitcoind;
|
||||
use futures::Future;
|
||||
use get_port::get_port;
|
||||
use libp2p::{core::Multiaddr, PeerId};
|
||||
use monero_harness::{image, Monero};
|
||||
use std::{path::PathBuf, sync::Arc};
|
||||
use tempfile::tempdir;
|
||||
use testcontainers::{clients::Cli, Container};
|
||||
use tokio::task::JoinHandle;
|
||||
@ -415,13 +415,13 @@ async fn init_wallets(
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let xmr_wallet = Arc::new(swap::monero::Wallet {
|
||||
let xmr_wallet = Arc::new(crate::monero::Wallet {
|
||||
inner: monero.wallet(name).unwrap().client(),
|
||||
network: config.monero_network,
|
||||
});
|
||||
|
||||
let btc_wallet = Arc::new(
|
||||
swap::bitcoin::Wallet::new(name, bitcoind.node_url.clone(), config.bitcoin_network)
|
||||
crate::bitcoin::Wallet::new(name, bitcoind.node_url.clone(), config.bitcoin_network)
|
||||
.await
|
||||
.unwrap(),
|
||||
);
|
||||
@ -478,7 +478,7 @@ fn init_tracing() -> DefaultGuard {
|
||||
}
|
||||
|
||||
pub mod alice_run_until {
|
||||
use swap::protocol::alice::AliceState;
|
||||
use crate::protocol::alice::AliceState;
|
||||
|
||||
pub fn is_xmr_locked(state: &AliceState) -> bool {
|
||||
matches!(
|
||||
@ -496,7 +496,7 @@ pub mod alice_run_until {
|
||||
}
|
||||
|
||||
pub mod bob_run_until {
|
||||
use swap::protocol::bob::BobState;
|
||||
use crate::protocol::bob::BobState;
|
||||
|
||||
pub fn is_btc_locked(state: &BobState) -> bool {
|
||||
matches!(state, BobState::BtcLocked(..))
|
Loading…
x
Reference in New Issue
Block a user