Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
grunch committed Dec 11, 2024
1 parent ec17876 commit 617548e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ mod tests {

#[test]
fn test_message_deserialize_serialize() {
let sample_message = r#"{"order":{"version":1,"request_id":1,"id":"7dd204d2-d06c-4406-a3d9-4415f4a8b9c9","action":"fiat-sent","content":null}}"#;
let sample_message = r#"{"order":{"version":1,"request_id":1,"trade_index":null,"id":"7dd204d2-d06c-4406-a3d9-4415f4a8b9c9","action":"fiat-sent","payload":null}}"#;
let message = Message::from_json(sample_message).unwrap();
assert!(message.verify());
let json_message = message.as_json().unwrap();
Expand All @@ -119,7 +119,7 @@ mod tests {

#[test]
fn test_wrong_message_should_fail() {
let sample_message = r#"{"order":{"version":1,"request_id":1,"action":"take-sell","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 sample_message = r#"{"order":{"version":1,"request_id":1,"action":"take-sell","payload":{"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
10 changes: 9 additions & 1 deletion src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,15 @@ mod tests {
initialize();
// Mock the send_dm function
let receiver_pubkey = Keys::generate().public_key();
let payload = "Test message".to_string();
let uuid = uuid!("308e1272-d5f4-47e6-bd97-3504baea9c23");
let message = Message::Order(MessageKind::new(
Some(uuid),
None,
None,
Action::FiatSent,
None,
));
let payload = message.as_json().unwrap();
let sender_keys = Keys::generate();
let result = send_dm(&receiver_pubkey, sender_keys, payload).await;
assert!(result.is_ok());
Expand Down

0 comments on commit 617548e

Please sign in to comment.