mirror of
https://github.com/chatmail/core.git
synced 2026-04-18 05:56:31 +03:00
this PR adds the address to be used by the UI for `window.webxdc.selfAddr` to webxdc-info. UIs need to be changed accordingly and must not use configured_addr any longer. the address is created by sha256(private-key + rfc724_mid) , which results in different addresses for each webxdc, without the option to find out the real address of the user. this also returns the same address for a multi-device-setup - sending totally random self address around might be an alternative, however would require connectivity (both devices may be offline on first start). for existing app, after the change, there will be a new user, resulting eg. in a new highscore, otherwise, things should be mostly fine. this assumption is also important as we might change the thing another time when it comes to multi-transport. ftr, addresses look like `0f187e3f420748b03e3da76543e9a84ecff822687ce7e94f250c04c7c50398bc` now when this is merged, we need to adapt #6230 and file issues for all UI to use `info.selfAddr` closes #6216
59 lines
2.0 KiB
Python
59 lines
2.0 KiB
Python
from deltachat_rpc_client import EventType
|
|
|
|
|
|
def test_webxdc(acfactory) -> None:
|
|
alice, bob = acfactory.get_online_accounts(2)
|
|
|
|
bob_addr = bob.get_config("addr")
|
|
alice_contact_bob = alice.create_contact(bob_addr, "Bob")
|
|
alice_chat_bob = alice_contact_bob.create_chat()
|
|
alice_chat_bob.send_message(text="Let's play chess!", file="../test-data/webxdc/chess.xdc")
|
|
|
|
while True:
|
|
event = bob.wait_for_event()
|
|
if event.kind == EventType.INCOMING_MSG:
|
|
bob_chat_alice = bob.get_chat_by_id(event.chat_id)
|
|
message = bob.get_message_by_id(event.msg_id)
|
|
break
|
|
|
|
webxdc_info = message.get_webxdc_info()
|
|
assert webxdc_info == {
|
|
"document": None,
|
|
"icon": "icon.png",
|
|
"internetAccess": False,
|
|
"name": "Chess Board",
|
|
"sourceCodeUrl": None,
|
|
"summary": None,
|
|
"selfAddr": webxdc_info["selfAddr"],
|
|
}
|
|
|
|
status_updates = message.get_webxdc_status_updates()
|
|
assert status_updates == []
|
|
|
|
bob_chat_alice.accept()
|
|
message.send_webxdc_status_update({"payload": 42}, "")
|
|
message.send_webxdc_status_update({"payload": "Second update"}, "description")
|
|
|
|
status_updates = message.get_webxdc_status_updates()
|
|
assert status_updates == [
|
|
{"payload": 42, "serial": 1, "max_serial": 2},
|
|
{"payload": "Second update", "serial": 2, "max_serial": 2},
|
|
]
|
|
|
|
status_updates = message.get_webxdc_status_updates(1)
|
|
assert status_updates == [
|
|
{"payload": "Second update", "serial": 2, "max_serial": 2},
|
|
]
|
|
|
|
|
|
def test_webxdc_insert_lots_of_updates(acfactory) -> None:
|
|
alice, bob = acfactory.get_online_accounts(2)
|
|
|
|
bob_addr = bob.get_config("addr")
|
|
alice_contact_bob = alice.create_contact(bob_addr, "Bob")
|
|
alice_chat_bob = alice_contact_bob.create_chat()
|
|
message = alice_chat_bob.send_message(text="Let's play chess!", file="../test-data/webxdc/chess.xdc")
|
|
|
|
for i in range(2000):
|
|
message.send_webxdc_status_update({"payload": str(i)}, "description")
|