Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
grunch committed Dec 1, 2023
1 parent 36516d8 commit 7ab603f
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,11 @@ async fn main() -> Result<()> {
#[cfg(test)]
mod tests {
use mostro_core::message::Message;
use mostro_core::order::SmallOrder;
use std::time::{SystemTime, UNIX_EPOCH};

#[test]
fn test_order_deserialize_serialize() {
let sample_order = r#"{"kind":"Sell","status":"Pending","amount":100,"fiat_code":"XXX","fiat_amount":10,"payment_method":"belo","premium":1,"created_at":0}"#;
let order = SmallOrder::from_json(sample_order).unwrap();
let json_order = order.as_json().unwrap();
assert_eq!(sample_order, json_order);
}

#[test]
fn test_message_deserialize_serialize() {
let sample_message = r#"{"version":0,"order_id":"7dd204d2-d06c-4406-a3d9-4415f4a8b9c9","pubkey":null,"action":"TakeSell","content":{"PaymentRequest":[null,"lnbc1..."]}}"#;
let sample_message = r#"{"Order":{"version":1,"id":"7dd204d2-d06c-4406-a3d9-4415f4a8b9c9","pubkey":null,"action":"FiatSent","content":null}}"#;
let message = Message::from_json(sample_message).unwrap();
assert!(message.verify());
let json_message = message.as_json().unwrap();
Expand All @@ -87,7 +78,7 @@ mod tests {

#[test]
fn test_wrong_message_should_fail() {
let sample_message = r#"{"version":0,"action":"TakeSell","content":{"Order":{"kind":"Sell","status":"Pending","amount":100,"fiat_code":"XXX","fiat_amount":10,"payment_method":"belo","premium":1,"payment_request":null,"created_at":1640839235}}}"#;
let sample_message = r#"{"Order":{"version":1,"pubkey":null,"action":"TakeSell","content":{"Order":{"kind":"Sell","status":"Pending","amount":100,"fiat_code":"XXX","fiat_amount":10,"payment_method":"SEPA","premium":1,"payment_request":null,"created_at":1640839235}}}}"#;
let message = Message::from_json(sample_message).unwrap();
assert!(!message.verify());
}
Expand Down

0 comments on commit 7ab603f

Please sign in to comment.