Skip to content

Commit 57f4958

Browse files
committed
test(deltachat-rpc-client): test Account.{import,export}_self_keys
1 parent 3aeb57b commit 57f4958

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

deltachat-rpc-client/tests/test_something.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ def test_wait_next_messages(acfactory) -> None:
341341
assert snapshot.text == "Hello!"
342342

343343

344-
def test_import_export(acfactory, tmp_path) -> None:
344+
def test_import_export_backup(acfactory, tmp_path) -> None:
345345
alice = acfactory.new_configured_account()
346346
alice.export_backup(tmp_path)
347347

@@ -352,6 +352,31 @@ def test_import_export(acfactory, tmp_path) -> None:
352352
assert alice2.manager.get_system_info()
353353

354354

355+
def test_import_export_keys(acfactory, tmp_path) -> None:
356+
alice, bob = acfactory.get_online_accounts(2)
357+
358+
bob_addr = bob.get_config("addr")
359+
alice_contact_bob = alice.create_contact(bob_addr, "Bob")
360+
alice_chat_bob = alice_contact_bob.create_chat()
361+
alice_chat_bob.send_text("Hello Bob!")
362+
363+
snapshot = bob.get_message_by_id(bob.wait_for_incoming_msg_event().msg_id).get_snapshot()
364+
assert snapshot.text == "Hello Bob!"
365+
366+
# Alice resetups account, but keeps the key.
367+
alice_keys_path = tmp_path / "alice_keys"
368+
alice_keys_path.mkdir()
369+
alice.export_self_keys(alice_keys_path)
370+
alice = acfactory.resetup_account(alice)
371+
alice.import_self_keys(alice_keys_path)
372+
373+
snapshot.chat.accept()
374+
snapshot.chat.send_text("Hello Alice!")
375+
snapshot = alice.get_message_by_id(alice.wait_for_incoming_msg_event().msg_id).get_snapshot()
376+
assert snapshot.text == "Hello Alice!"
377+
assert snapshot.show_padlock
378+
379+
355380
def test_openrpc_command_line() -> None:
356381
"""Test that "deltachat-rpc-server --openrpc" command returns an OpenRPC specification."""
357382
out = subprocess.run(["deltachat-rpc-server", "--openrpc"], capture_output=True, check=True).stdout

0 commit comments

Comments
 (0)