MCPcopy Create free account
hub / github.com/chatmail/core / test_execute_sync_items

Function test_execute_sync_items

src/sync.rs:619–652  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

617
618 #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
619 async fn test_execute_sync_items() -> Result<()> {
620 let t = TestContext::new_alice().await;
621
622 assert!(!token::exists(&t, Namespace::Auth, "yip-auth").await?);
623
624 let timestamp_sent = time();
625 let sync_items = t
626 .parse_sync_items(
627 r#"{"items":[
628{"timestamp":1631781315,"data":{"AlterChat":{"id":{"ContactAddr":"bob@example.net"},"action":"Block"}}},
629{"timestamp":1631781316,"data":{"AddQrToken":{"invitenumber":"yip-in","auth":"a"}}},
630{"timestamp":1631781316,"data":{"DeleteQrToken":{"invitenumber":"in","auth":"delete unexistent, shall continue"}}},
631{"timestamp":1631781316,"data":{"AddQrToken":{"invitenumber":"in","auth":"yip-auth"}}},
632{"timestamp":1631781316,"data":{"AddQrToken":{"invitenumber":"in","auth":"foo","grpid":"non-existent"}}},
633{"timestamp":1631781316,"data":{"AddQrToken":{"invitenumber":"in","auth":"directly deleted"}}},
634{"timestamp":1631781316,"data":{"DeleteQrToken":{"invitenumber":"in","auth":"directly deleted"}}}
635]}"#
636 .to_string(),
637 )
638 ?;
639 t.execute_sync_items(&sync_items, timestamp_sent).await;
640
641 assert!(
642 Contact::lookup_id_by_addr(&t, "bob@example.net", Origin::Unknown)
643 .await?
644 .is_none()
645 );
646 assert!(!token::exists(&t, Namespace::InviteNumber, "yip-in").await?);
647 assert!(!token::exists(&t, Namespace::Auth, "yip-auth").await?);
648 assert!(!token::exists(&t, Namespace::Auth, "non-existent").await?);
649 assert!(!token::exists(&t, Namespace::Auth, "directly deleted").await?);
650
651 Ok(())
652 }
653
654 #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
655 async fn test_send_sync_msg() -> Result<()> {

Callers

nothing calls this directly

Calls 3

timeFunction · 0.85
parse_sync_itemsMethod · 0.80
execute_sync_itemsMethod · 0.80

Tested by

no test coverage detected