|
@ -1,17 +1,9 @@ |
|
|
use crate::harness::flow::{is_next_none, next_cfd, next_order, next_some}; |
|
|
use crate::harness::flow::{is_next_none, next_cfd, next_order, next_some}; |
|
|
use crate::harness::mocks::{ |
|
|
use crate::harness::{assert_is_same_order, dummy_new_order, init_tracing, start_both}; |
|
|
mock_oracle_annoucement, mock_party_params, mock_wallet_sign_and_broadcast, |
|
|
use daemon::model::cfd::CfdState; |
|
|
}; |
|
|
use daemon::model::Usd; |
|
|
use crate::harness::start_both; |
|
|
|
|
|
use daemon::maker_cfd; |
|
|
|
|
|
use daemon::model::cfd::{CfdState, Order, Origin}; |
|
|
|
|
|
use daemon::model::{Price, Usd}; |
|
|
|
|
|
use maia::secp256k1_zkp::schnorrsig; |
|
|
use maia::secp256k1_zkp::schnorrsig; |
|
|
use rust_decimal_macros::dec; |
|
|
use rust_decimal_macros::dec; |
|
|
use tracing::subscriber::DefaultGuard; |
|
|
|
|
|
use tracing_subscriber::filter::LevelFilter; |
|
|
|
|
|
use tracing_subscriber::util::SubscriberInitExt; |
|
|
|
|
|
use tracing_subscriber::EnvFilter; |
|
|
|
|
|
mod harness; |
|
|
mod harness; |
|
|
|
|
|
|
|
|
#[tokio::test] |
|
|
#[tokio::test] |
|
@ -106,48 +98,3 @@ async fn taker_takes_order_and_maker_accepts_and_contract_setup() { |
|
|
assert!(matches!(taker_cfd.state, CfdState::PendingOpen { .. })); |
|
|
assert!(matches!(taker_cfd.state, CfdState::PendingOpen { .. })); |
|
|
assert!(matches!(maker_cfd.state, CfdState::PendingOpen { .. })); |
|
|
assert!(matches!(maker_cfd.state, CfdState::PendingOpen { .. })); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// The order cannot be directly compared in tests as the origin is different,
|
|
|
|
|
|
/// therefore wrap the assertion macro in a code that unifies the 'Origin'
|
|
|
|
|
|
fn assert_is_same_order(a: &Order, b: &Order) { |
|
|
|
|
|
// Assume the same origin
|
|
|
|
|
|
let mut a = a.clone(); |
|
|
|
|
|
let mut b = b.clone(); |
|
|
|
|
|
a.origin = Origin::Ours; |
|
|
|
|
|
b.origin = Origin::Ours; |
|
|
|
|
|
|
|
|
|
|
|
assert_eq!(a, b); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fn dummy_new_order() -> maker_cfd::NewOrder { |
|
|
|
|
|
maker_cfd::NewOrder { |
|
|
|
|
|
price: Price::new(dec!(50_000)).expect("unexpected failure"), |
|
|
|
|
|
min_quantity: Usd::new(dec!(5)), |
|
|
|
|
|
max_quantity: Usd::new(dec!(100)), |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fn init_tracing() -> DefaultGuard { |
|
|
|
|
|
let filter = EnvFilter::from_default_env() |
|
|
|
|
|
// apply warning level globally
|
|
|
|
|
|
.add_directive(format!("{}", LevelFilter::WARN).parse().unwrap()) |
|
|
|
|
|
// log traces from test itself
|
|
|
|
|
|
.add_directive( |
|
|
|
|
|
format!("happy_path={}", LevelFilter::DEBUG) |
|
|
|
|
|
.parse() |
|
|
|
|
|
.unwrap(), |
|
|
|
|
|
) |
|
|
|
|
|
.add_directive(format!("taker={}", LevelFilter::DEBUG).parse().unwrap()) |
|
|
|
|
|
.add_directive(format!("maker={}", LevelFilter::DEBUG).parse().unwrap()) |
|
|
|
|
|
.add_directive(format!("daemon={}", LevelFilter::DEBUG).parse().unwrap()) |
|
|
|
|
|
.add_directive(format!("rocket={}", LevelFilter::WARN).parse().unwrap()); |
|
|
|
|
|
|
|
|
|
|
|
let guard = tracing_subscriber::fmt() |
|
|
|
|
|
.with_env_filter(filter) |
|
|
|
|
|
.with_test_writer() |
|
|
|
|
|
.set_default(); |
|
|
|
|
|
|
|
|
|
|
|
tracing::info!("Running version: {}", env!("VERGEN_GIT_SEMVER_LIGHTWEIGHT")); |
|
|
|
|
|
|
|
|
|
|
|
guard |
|
|
|
|
|
} |
|
|
|
|
|