Skip to content

Commit 7a3f26d

Browse files
committed
fixing rpc client tests
1 parent 72223c1 commit 7a3f26d

File tree

2 files changed

+18
-21
lines changed

2 files changed

+18
-21
lines changed

deltachat-rpc-client/tests/test_securejoin.py

+17-20
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ def test_qr_setup_contact(acfactory, tmp_path) -> None:
1616
alice.wait_for_securejoin_inviter_success()
1717

1818
# Test that Alice verified Bob's profile.
19-
alice_contact_bob = alice.get_contact_by_addr(bob.get_config("addr"))
19+
alice_contact_bob = alice.create_contact(bob)
2020
alice_contact_bob_snapshot = alice_contact_bob.get_snapshot()
2121
assert alice_contact_bob_snapshot.is_verified
2222

2323
bob.wait_for_securejoin_joiner_success()
2424

2525
# Test that Bob verified Alice's profile.
26-
bob_contact_alice = bob.get_contact_by_addr(alice.get_config("addr"))
26+
bob_contact_alice = bob.create_contact(bob)
2727
bob_contact_alice_snapshot = bob_contact_alice.get_snapshot()
2828
assert bob_contact_alice_snapshot.is_verified
2929

@@ -84,7 +84,7 @@ def test_qr_securejoin(acfactory, protect):
8484
bob.wait_for_securejoin_joiner_success()
8585

8686
# Test that Alice verified Bob's profile.
87-
alice_contact_bob = alice.get_contact_by_addr(bob.get_config("addr"))
87+
alice_contact_bob = alice.create_contact(bob)
8888
alice_contact_bob_snapshot = alice_contact_bob.get_snapshot()
8989
assert alice_contact_bob_snapshot.is_verified
9090

@@ -93,15 +93,15 @@ def test_qr_securejoin(acfactory, protect):
9393
assert snapshot.chat.get_basic_snapshot().is_protected == protect
9494

9595
# Test that Bob verified Alice's profile.
96-
bob_contact_alice = bob.get_contact_by_addr(alice.get_config("addr"))
96+
bob_contact_alice = bob.create_contact(alice)
9797
bob_contact_alice_snapshot = bob_contact_alice.get_snapshot()
9898
assert bob_contact_alice_snapshot.is_verified
9999

100100
# Start second Alice device.
101101
# Alice observes securejoin protocol and verifies Bob on second device.
102102
alice2.start_io()
103103
alice2.wait_for_securejoin_inviter_success()
104-
alice2_contact_bob = alice2.get_contact_by_addr(bob.get_config("addr"))
104+
alice2_contact_bob = alice2.create_contact(bob)
105105
alice2_contact_bob_snapshot = alice2_contact_bob.get_snapshot()
106106
assert alice2_contact_bob_snapshot.is_verified
107107

@@ -227,7 +227,7 @@ def test_verified_group_recovery(acfactory) -> None:
227227
ac2.wait_for_securejoin_joiner_success()
228228

229229
# ac1 has ac2 directly verified.
230-
ac1_contact_ac2 = ac1.get_contact_by_addr(ac2.get_config("addr"))
230+
ac1_contact_ac2 = ac1.create_contact(ac2)
231231
assert ac1_contact_ac2.get_snapshot().verifier_id == SpecialContactId.SELF
232232

233233
logging.info("ac3 joins verified group")
@@ -278,7 +278,7 @@ def test_verified_group_recovery(acfactory) -> None:
278278

279279

280280
def test_verified_group_member_added_recovery(acfactory) -> None:
281-
"""Tests verified group recovery by reverifiying than removing and adding a member back."""
281+
"""Tests verified group recovery by reverifying than removing and adding a member back."""
282282
ac1, ac2, ac3 = acfactory.get_online_accounts(3)
283283

284284
logging.info("ac1 creates verified group")
@@ -291,7 +291,7 @@ def test_verified_group_member_added_recovery(acfactory) -> None:
291291
ac2.wait_for_securejoin_joiner_success()
292292

293293
# ac1 has ac2 directly verified.
294-
ac1_contact_ac2 = ac1.get_contact_by_addr(ac2.get_config("addr"))
294+
ac1_contact_ac2 = ac1.create_contact(ac2)
295295
assert ac1_contact_ac2.get_snapshot().verifier_id == SpecialContactId.SELF
296296

297297
logging.info("ac3 joins verified group")
@@ -319,7 +319,7 @@ def test_verified_group_member_added_recovery(acfactory) -> None:
319319

320320
ac1.wait_for_incoming_msg_event() # Hi!
321321

322-
ac3_contact_ac2 = ac3.get_contact_by_addr(ac2.get_config("addr"))
322+
ac3_contact_ac2 = ac3.create_contact(ac2)
323323
ac3_chat.remove_contact(ac3_contact_ac2)
324324

325325
msg_id = ac2.wait_for_incoming_msg_event().msg_id
@@ -354,19 +354,16 @@ def test_verified_group_member_added_recovery(acfactory) -> None:
354354
snapshot = ac1.get_message_by_id(ac1.wait_for_incoming_msg_event().msg_id).get_snapshot()
355355
assert snapshot.text == "Works again!"
356356

357-
ac1_contact_ac2 = ac1.get_contact_by_addr(ac2.get_config("addr"))
357+
ac1_contact_ac2 = ac1.create_contact(ac2)
358+
ac1_contact_ac3 = ac1.create_contact(ac3)
358359
ac1_contact_ac2_snapshot = ac1_contact_ac2.get_snapshot()
359360
assert ac1_contact_ac2_snapshot.is_verified
360-
assert ac1_contact_ac2_snapshot.verifier_id == ac1.get_contact_by_addr(ac3.get_config("addr")).id
361-
362-
# ac2 is now verified by ac3 for ac1
363-
ac1_contact_ac3 = ac1.get_contact_by_addr(ac3.get_config("addr"))
364-
assert ac1_contact_ac2.get_snapshot().verifier_id == ac1_contact_ac3.id
361+
assert ac1_contact_ac2_snapshot.verifier_id == ac1_contact_ac3.id
365362

366363

367364
def test_qr_join_chat_with_pending_bobstate_issue4894(acfactory):
368365
"""Regression test for
369-
issue <https://github.com/deltachat/deltachat-core-rust/issues/4894>.
366+
issue <https://github.com/chatmail/core/issues/4894>.
370367
"""
371368
ac1, ac2, ac3, ac4 = acfactory.get_online_accounts(4)
372369

@@ -400,12 +397,12 @@ def test_qr_join_chat_with_pending_bobstate_issue4894(acfactory):
400397
logging.info("ac2 now has pending bobstate but ac1 is shutoff")
401398

402399
# we meanwhile expect ac3/ac2 verification started in the beginning to have completed
403-
assert ac3.get_contact_by_addr(ac2.get_config("addr")).get_snapshot().is_verified
404-
assert ac2.get_contact_by_addr(ac3.get_config("addr")).get_snapshot().is_verified
400+
assert ac3.create_contact(ac2).get_snapshot().is_verified
401+
assert ac2.create_contact(ac3).get_snapshot().is_verified
405402

406403
logging.info("ac3: create a verified group VG with ac2")
407404
vg = ac3.create_group("ac3-created", protect=True)
408-
vg.add_contact(ac3.get_contact_by_addr(ac2.get_config("addr")))
405+
vg.add_contact(ac3.create_contact(ac2))
409406

410407
# ensure ac2 receives message in VG
411408
vg.send_text("hello")
@@ -443,7 +440,7 @@ def test_qr_new_group_unblocked(acfactory):
443440
ac1.wait_for_securejoin_inviter_success()
444441

445442
ac1_new_chat = ac1.create_group("Another group")
446-
ac1_new_chat.add_contact(ac1.get_contact_by_addr(ac2.get_config("addr")))
443+
ac1_new_chat.add_contact(ac1.create_contact(ac2))
447444
# Receive "Member added" message.
448445
ac2.wait_for_incoming_msg_event()
449446

deltachat-rpc-client/tests/test_something.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def test_account(acfactory) -> None:
170170
assert alice.get_size()
171171
assert alice.is_configured()
172172
assert not alice.get_avatar()
173-
assert alice.get_contact_by_addr(bob_addr) == alice_contact_bob
173+
assert alice.get_contact_by_addr(bob_addr) == None # There is no email-contact, only PGP-contact
174174
assert alice.get_contacts()
175175
assert alice.get_contacts(snapshot=True)
176176
assert alice.self_contact

0 commit comments

Comments
 (0)