mirror of
https://github.com/chatmail/core.git
synced 2026-05-02 04:46:29 +03:00
Add python test for gossip optimization
This commit is contained in:
@@ -1221,6 +1221,40 @@ class TestOnlineAccount:
|
|||||||
assert not msg.is_encrypted()
|
assert not msg.is_encrypted()
|
||||||
ac1._evtracker.get_matching("DC_EVENT_SMTP_MESSAGE_SENT")
|
ac1._evtracker.get_matching("DC_EVENT_SMTP_MESSAGE_SENT")
|
||||||
|
|
||||||
|
def test_gossip_optimization(self, acfactory, lp):
|
||||||
|
"""Test that gossip timestamp is updated when someone else sends gossip,
|
||||||
|
so we don't have to send gossip ourselves.
|
||||||
|
"""
|
||||||
|
ac1, ac2, ac3 = acfactory.get_many_online_accounts(3)
|
||||||
|
|
||||||
|
acfactory.introduce_each_other([ac1, ac2])
|
||||||
|
acfactory.introduce_each_other([ac2, ac3])
|
||||||
|
|
||||||
|
lp.sec("ac1 creates a group chat with ac2")
|
||||||
|
group_chat = ac1.create_group_chat("hello")
|
||||||
|
group_chat.add_contact(ac2)
|
||||||
|
msg = group_chat.send_text("hi")
|
||||||
|
|
||||||
|
# No Autocrypt gossip was sent yet.
|
||||||
|
gossiped_timestamp = msg.chat.get_summary()["gossiped_timestamp"]
|
||||||
|
assert gossiped_timestamp == 0
|
||||||
|
|
||||||
|
msg = ac2._evtracker.wait_next_incoming_message()
|
||||||
|
assert msg.is_encrypted()
|
||||||
|
assert msg.text == "hi"
|
||||||
|
|
||||||
|
lp.sec("ac2 adds ac3 to the group")
|
||||||
|
msg.chat.add_contact(ac3)
|
||||||
|
|
||||||
|
lp.sec("ac1 receives message from ac2 and updates gossip timestamp")
|
||||||
|
msg = ac1._evtracker.wait_next_incoming_message()
|
||||||
|
assert msg.is_encrypted()
|
||||||
|
|
||||||
|
# ac1 has updated the gossip timestamp even though no gossip was sent by ac1.
|
||||||
|
# ac1 does not need to send gossip because ac2 already did it.
|
||||||
|
gossiped_timestamp = msg.chat.get_summary()["gossiped_timestamp"]
|
||||||
|
assert gossiped_timestamp == int(msg.time_sent.timestamp())
|
||||||
|
|
||||||
def test_gossip_encryption_preference(self, acfactory, lp):
|
def test_gossip_encryption_preference(self, acfactory, lp):
|
||||||
"""Test that encryption preference of group members is gossiped to new members.
|
"""Test that encryption preference of group members is gossiped to new members.
|
||||||
This is a Delta Chat extension to Autocrypt 1.1.0, which Autocrypt-Gossip headers
|
This is a Delta Chat extension to Autocrypt 1.1.0, which Autocrypt-Gossip headers
|
||||||
|
|||||||
Reference in New Issue
Block a user