Move test functions out of lib

pull/2/head
rishflab 4 years ago
parent 61a8a3e428
commit bf576bf251

@ -88,19 +88,6 @@ pub enum State {
State6(State6),
}
// TODO: use macro or generics
pub fn is_state4(state: &State) -> bool {
matches!(state, State::State4 { .. })
}
// TODO: use macro or generics
pub fn is_state5(state: &State) -> bool {
matches!(state, State::State5 { .. })
}
// TODO: use macro or generics
pub fn is_state6(state: &State) -> bool {
matches!(state, State::State6 { .. })
}
macro_rules! impl_try_from_parent_state {
($type:ident) => {
impl TryFrom<State> for $type {

@ -124,16 +124,6 @@ impl_from_child_state!(State3);
impl_from_child_state!(State4);
impl_from_child_state!(State5);
// TODO: use macro or generics
pub fn is_state5(state: &State) -> bool {
matches!(state, State::State5 { .. })
}
// TODO: use macro or generics
pub fn is_state3(state: &State) -> bool {
matches!(state, State::State3 { .. })
}
#[derive(Debug)]
pub struct State0 {
b: bitcoin::SecretKey,

@ -144,16 +144,15 @@ pub async fn init_test<'a>(
#[cfg(test)]
mod tests {
use crate::{
harness,
harness::node::{run_alice_until, run_bob_until},
init_bitcoind, init_test,
};
use futures::future;
use monero_harness::Monero;
use rand::rngs::OsRng;
use testcontainers::clients::Cli;
use futures::future;
use std::convert::TryInto;
use testcontainers::clients::Cli;
use tracing_subscriber::util::SubscriberInitExt;
use xmr_btc::{
alice, bitcoin,
@ -184,10 +183,15 @@ mod tests {
run_alice_until(
&mut alice_node,
alice_state0.into(),
alice::is_state6,
harness::alice::is_state6,
&mut OsRng,
),
run_bob_until(
&mut bob_node,
bob_state0.into(),
harness::bob::is_state5,
&mut OsRng,
),
run_bob_until(&mut bob_node, bob_state0.into(), bob::is_state5, &mut OsRng),
)
.await
.unwrap();
@ -265,10 +269,15 @@ mod tests {
run_alice_until(
&mut alice_node,
alice_state0.into(),
alice::is_state5,
harness::alice::is_state5,
&mut OsRng,
),
run_bob_until(
&mut bob_node,
bob_state0.into(),
harness::bob::is_state3,
&mut OsRng,
),
run_bob_until(&mut bob_node, bob_state0.into(), bob::is_state3, &mut OsRng),
)
.await
.unwrap();
@ -346,10 +355,15 @@ mod tests {
run_alice_until(
&mut alice_node,
alice_state0.into(),
alice::is_state4,
harness::alice::is_state4,
&mut OsRng,
),
run_bob_until(
&mut bob_node,
bob_state0.into(),
harness::bob::is_state3,
&mut OsRng,
),
run_bob_until(&mut bob_node, bob_state0.into(), bob::is_state3, &mut OsRng),
)
.await
.unwrap();

@ -1,3 +1,36 @@
pub mod node;
pub mod transport;
pub mod wallet;
pub mod bob {
use xmr_btc::bob::State;
// TODO: use macro or generics
pub fn is_state5(state: &State) -> bool {
matches!(state, State::State5 { .. })
}
// TODO: use macro or generics
pub fn is_state3(state: &State) -> bool {
matches!(state, State::State3 { .. })
}
}
pub mod alice {
use xmr_btc::alice::State;
// TODO: use macro or generics
pub fn is_state4(state: &State) -> bool {
matches!(state, State::State4 { .. })
}
// TODO: use macro or generics
pub fn is_state5(state: &State) -> bool {
matches!(state, State::State5 { .. })
}
// TODO: use macro or generics
pub fn is_state6(state: &State) -> bool {
matches!(state, State::State6 { .. })
}
}

Loading…
Cancel
Save