Skip to content

Commit

Permalink
Fixed formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
mstrug committed Nov 23, 2024
1 parent bca89ac commit 7c6983c
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions crates/shared/src/price_estimation/trade_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -581,11 +581,13 @@ mod tests {
sell_tokens_lost: BigRational::from_integer(500.into()),
};

let estimate = ensure_quote_accuracy(&low_threshold, &query, &Default::default(), &sell_more);
let estimate =
ensure_quote_accuracy(&low_threshold, &query, &Default::default(), &sell_more);
assert!(matches!(estimate, Err(Error::TooInaccurate)));

// passes with slightly higher tolerance
let estimate = ensure_quote_accuracy(&high_threshold, &query, &Default::default(), &sell_more);
let estimate =
ensure_quote_accuracy(&high_threshold, &query, &Default::default(), &sell_more);
assert!(estimate.is_ok());

let pay_out_more = SettleOutput {
Expand All @@ -595,11 +597,13 @@ mod tests {
sell_tokens_lost: BigRational::from_integer(0.into()),
};

let estimate = ensure_quote_accuracy(&low_threshold, &query, &Default::default(), &pay_out_more);
let estimate =
ensure_quote_accuracy(&low_threshold, &query, &Default::default(), &pay_out_more);
assert!(matches!(estimate, Err(Error::TooInaccurate)));

// passes with slightly higher tolerance
let estimate = ensure_quote_accuracy(&high_threshold, &query, &Default::default(), &pay_out_more);
let estimate =
ensure_quote_accuracy(&high_threshold, &query, &Default::default(), &pay_out_more);
assert!(estimate.is_ok());

let sell_less = SettleOutput {
Expand All @@ -609,7 +613,8 @@ mod tests {
sell_tokens_lost: BigRational::from_integer((-500).into()),
};
// Ending up with surplus in the buffers is always fine
let estimate = ensure_quote_accuracy(&low_threshold, &query, &Default::default(), &sell_less);
let estimate =
ensure_quote_accuracy(&low_threshold, &query, &Default::default(), &sell_less);
assert!(estimate.is_ok());

let pay_out_less = SettleOutput {
Expand All @@ -619,7 +624,8 @@ mod tests {
sell_tokens_lost: BigRational::from_integer(0.into()),
};
// Ending up with surplus in the buffers is always fine
let estimate = ensure_quote_accuracy(&low_threshold, &query, &Default::default(), &pay_out_less);
let estimate =
ensure_quote_accuracy(&low_threshold, &query, &Default::default(), &pay_out_less);
assert!(estimate.is_ok());
}
}

0 comments on commit 7c6983c

Please sign in to comment.