From 73e0f81e83a2e037fb39f26e6b943307eeb5dbc1 Mon Sep 17 00:00:00 2001 From: link2xt Date: Fri, 5 Dec 2025 21:16:25 +0000 Subject: [PATCH] test: port test_synchronize_member_list_on_group_rejoin to JSON-RPC --- deltachat-rpc-client/tests/test_something.py | 44 +++++++++++++++++ python/tests/test_0_complex_or_slow.py | 51 -------------------- 2 files changed, 44 insertions(+), 51 deletions(-) diff --git a/deltachat-rpc-client/tests/test_something.py b/deltachat-rpc-client/tests/test_something.py index d8177eca6..b272aa4d2 100644 --- a/deltachat-rpc-client/tests/test_something.py +++ b/deltachat-rpc-client/tests/test_something.py @@ -1012,3 +1012,47 @@ def test_message_exists(acfactory): ac1.remove() assert not message1.exists() assert not message2.exists() + + +def test_synchronize_member_list_on_group_rejoin(acfactory, log): + """ + Test that user recreates group member list when it joins the group again. + ac1 creates a group with two other accounts: ac2 and ac3 + Then it removes ac2, removes ac3 and adds ac2 back. + ac2 did not see that ac3 is removed, so it should rebuild member list from scratch. + """ + log.section("setting up accounts, accepted with each other") + ac1, ac2, ac3 = accounts = acfactory.get_online_accounts(3) + + log.section("ac1: creating group chat with 2 other members") + chat = ac1.create_group("title1") + chat.add_contact(ac2) + chat.add_contact(ac3) + + log.section("ac1: send message to new group chat") + msg = chat.send_text("hello") + assert chat.num_contacts() == 3 + + log.section("checking that the chat arrived correctly") + for ac in accounts[1:]: + msg = ac.wait_for_incoming_msg().get_snapshot() + assert msg.text == "hello" + assert msg.chat.num_contacts() == 3 + msg.chat.accept() + + log.section("ac1: removing ac2") + chat.remove_contact(ac2) + + log.section("ac2: wait for a message about removal from the chat") + ac2.wait_for_incoming_msg() + log.section("ac1: removing ac3") + chat.remove_contact(ac3) + + log.section("ac1: adding ac2 back") + chat.add_contact(ac2) + + log.section("ac2: check that ac3 is removed") + msg = ac2.wait_for_incoming_msg() + + assert chat.num_contacts() == 2 + assert msg.get_snapshot().chat.num_contacts() == 2 diff --git a/python/tests/test_0_complex_or_slow.py b/python/tests/test_0_complex_or_slow.py index 5a370e0f2..6d436e54b 100644 --- a/python/tests/test_0_complex_or_slow.py +++ b/python/tests/test_0_complex_or_slow.py @@ -1,4 +1,3 @@ -import sys import time import deltachat as dc @@ -63,56 +62,6 @@ class TestGroupStressTests: # Message should be encrypted because keys of other members are gossiped assert msg.is_encrypted() - def test_synchronize_member_list_on_group_rejoin(self, acfactory, lp): - """ - Test that user recreates group member list when it joins the group again. - ac1 creates a group with two other accounts: ac2 and ac3 - Then it removes ac2, removes ac3 and adds ac2 back. - ac2 did not see that ac3 is removed, so it should rebuild member list from scratch. - """ - lp.sec("setting up accounts, accepted with each other") - accounts = acfactory.get_online_accounts(3) - acfactory.introduce_each_other(accounts) - ac1, ac2, ac3 = accounts - - lp.sec("ac1: creating group chat with 2 other members") - chat = ac1.create_group_chat("title1", contacts=[ac2, ac3]) - assert not chat.is_promoted() - - lp.sec("ac1: send message to new group chat") - msg = chat.send_text("hello") - assert chat.is_promoted() and msg.is_encrypted() - - assert chat.num_contacts() == 3 - - lp.sec("checking that the chat arrived correctly") - for ac in accounts[1:]: - msg = ac._evtracker.wait_next_incoming_message() - assert msg.text == "hello" - print("chat is", msg.chat) - assert msg.chat.num_contacts() == 3 - - lp.sec("ac1: removing ac2") - chat.remove_contact(ac2) - - lp.sec("ac2: wait for a message about removal from the chat") - msg = ac2._evtracker.wait_next_incoming_message() - - lp.sec("ac1: removing ac3") - chat.remove_contact(ac3) - - lp.sec("ac1: adding ac2 back") - # Group is promoted, message is sent automatically - assert chat.is_promoted() - chat.add_contact(ac2) - - lp.sec("ac2: check that ac3 is removed") - msg = ac2._evtracker.wait_next_incoming_message() - - assert chat.num_contacts() == 2 - assert msg.chat.num_contacts() == 2 - acfactory.dump_imap_summary(sys.stdout) - def test_qr_verified_group_and_chatting(acfactory, lp): ac1, ac2, ac3 = acfactory.get_online_accounts(3)