mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-08-01 19:16:10 -04:00
Move helper structs below tests
This commit is contained in:
parent
7ff57ff0d4
commit
a347dd8b97
1 changed files with 22 additions and 22 deletions
|
@ -492,28 +492,6 @@ mod tests {
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
struct MaxGiveable {
|
|
||||||
amounts: Vec<Amount>,
|
|
||||||
call_counter: usize,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl MaxGiveable {
|
|
||||||
fn new(amounts: Vec<Amount>) -> Self {
|
|
||||||
Self {
|
|
||||||
amounts,
|
|
||||||
call_counter: 0,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn give(&mut self) -> Result<Amount> {
|
|
||||||
let amount = self
|
|
||||||
.amounts
|
|
||||||
.get(self.call_counter)
|
|
||||||
.ok_or_else(|| anyhow::anyhow!("No more balances available"))?;
|
|
||||||
self.call_counter += 1;
|
|
||||||
Ok(*amount)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn given_no_balance_and_transfers_less_than_max_swaps_max_giveable() {
|
async fn given_no_balance_and_transfers_less_than_max_swaps_max_giveable() {
|
||||||
let _guard = subscriber::set_default(tracing_subscriber::fmt().with_test_writer().finish());
|
let _guard = subscriber::set_default(tracing_subscriber::fmt().with_test_writer().finish());
|
||||||
|
@ -712,6 +690,28 @@ mod tests {
|
||||||
assert!(matches!(error, tokio::time::error::Elapsed { .. }))
|
assert!(matches!(error, tokio::time::error::Elapsed { .. }))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct MaxGiveable {
|
||||||
|
amounts: Vec<Amount>,
|
||||||
|
call_counter: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl MaxGiveable {
|
||||||
|
fn new(amounts: Vec<Amount>) -> Self {
|
||||||
|
Self {
|
||||||
|
amounts,
|
||||||
|
call_counter: 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fn give(&mut self) -> Result<Amount> {
|
||||||
|
let amount = self
|
||||||
|
.amounts
|
||||||
|
.get(self.call_counter)
|
||||||
|
.ok_or_else(|| anyhow::anyhow!("No more balances available"))?;
|
||||||
|
self.call_counter += 1;
|
||||||
|
Ok(*amount)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn quote_with_max(btc: f64) -> BidQuote {
|
fn quote_with_max(btc: f64) -> BidQuote {
|
||||||
BidQuote {
|
BidQuote {
|
||||||
price: Amount::from_btc(0.001).unwrap(),
|
price: Amount::from_btc(0.001).unwrap(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue