()
| 861 | /// from the same Alice at the same time. |
| 862 | #[tokio::test(flavor = "multi_thread", worker_threads = 2)] |
| 863 | async fn test_parallel_securejoin() -> Result<()> { |
| 864 | let mut tcm = TestContextManager::new(); |
| 865 | let alice = &tcm.alice().await; |
| 866 | let bob = &tcm.bob().await; |
| 867 | |
| 868 | let alice_chat1_id = chat::create_group(alice, "First chat").await?; |
| 869 | let alice_chat2_id = chat::create_group(alice, "Second chat").await?; |
| 870 | |
| 871 | let qr1 = get_securejoin_qr(alice, Some(alice_chat1_id)).await?; |
| 872 | let qr2 = get_securejoin_qr(alice, Some(alice_chat2_id)).await?; |
| 873 | |
| 874 | // Bob scans both QR codes. |
| 875 | let bob_chat1_id = join_securejoin(bob, &qr1).await?; |
| 876 | let sent_vg_request1 = bob.pop_sent_msg().await; |
| 877 | |
| 878 | let bob_chat2_id = join_securejoin(bob, &qr2).await?; |
| 879 | let sent_vg_request2 = bob.pop_sent_msg().await; |
| 880 | |
| 881 | // Alice receives two `vg-request` messages |
| 882 | // and sends back two `vg-auth-required` messages. |
| 883 | alice.recv_msg_trash(&sent_vg_request1).await; |
| 884 | let sent_vg_auth_required1 = alice.pop_sent_msg().await; |
| 885 | |
| 886 | alice.recv_msg_trash(&sent_vg_request2).await; |
| 887 | let _sent_vg_auth_required2 = alice.pop_sent_msg().await; |
| 888 | |
| 889 | // Bob receives first `vg-auth-required` message. |
| 890 | // Bob has two securejoin processes started, |
| 891 | // so he should send two `vg-request-with-auth` messages. |
| 892 | bob.recv_msg_trash(&sent_vg_auth_required1).await; |
| 893 | |
| 894 | // Bob sends `vg-request-with-auth` messages. |
| 895 | let sent_vg_request_with_auth2 = bob.pop_sent_msg().await; |
| 896 | let sent_vg_request_with_auth1 = bob.pop_sent_msg().await; |
| 897 | |
| 898 | // Alice receives both `vg-request-with-auth` messages. |
| 899 | alice.recv_msg_trash(&sent_vg_request_with_auth1).await; |
| 900 | let sent_vg_member_added1 = alice.pop_sent_msg().await; |
| 901 | let joined_chat_id1 = bob.recv_msg(&sent_vg_member_added1).await.chat_id; |
| 902 | assert_eq!(joined_chat_id1, bob_chat1_id); |
| 903 | |
| 904 | alice.recv_msg_trash(&sent_vg_request_with_auth2).await; |
| 905 | let sent_vg_member_added2 = alice.pop_sent_msg().await; |
| 906 | let joined_chat_id2 = bob.recv_msg(&sent_vg_member_added2).await.chat_id; |
| 907 | assert_eq!(joined_chat_id2, bob_chat2_id); |
| 908 | |
| 909 | Ok(()) |
| 910 | } |
| 911 | |
| 912 | /// Tests Bob scanning setup contact QR codes of Alice and Fiona |
| 913 | /// concurrently. |
nothing calls this directly
no test coverage detected