Repository: chatmail/core (Rust)

Issue:
tests/test_webxdc.py::test_webxdc is flaky
The test currently randomly fails with this assertion:
```
acfactory = <deltachat_rpc_client.pytestplugin.ACFactory object at 0x7f9164707070>

    def test_webxdc(acfactory) -> None:
        alice, bob = acfactory.get_online_accounts(2)

        alice_contact_bob = alice.create_contact(bob, "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")

        event = bob.wait_for_incoming_msg_event()
        bob_chat_alice = bob.get_chat_by_id(event.chat_id)
        message = bob.get_message_by_id(event.msg_id)

        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"],
            "sendUpdateInterval": 1000,
            "sendUpdateMaxSize": 18874368,
        }
E       AssertionError: assert {'document': ...s Board', ...} == {'document': ...s Board', ...}
E
E         Omitting 8 identical items, use -vv to show
E         Differing items:
E         {'sendUpdateInterval': 10000} != {'sendUpdateInterval': 1000}
E
E         Full diff:
E           {...
E
E         ...Full output truncated (12 lines hidden), use '-vv' to show

tests/test_webxdc.py:13: AssertionError
```

The reason is that ratelimit depends on `is_chatmail` and whether `is_chatmail` is set depends on timing. `is_chatmail` is apparently not set by the time of first IDLE, but only when the folder is configured, and we do not configure folders immediately since https://github.com/chatmail/core/pull/7348
But rather than ensuring we set `is_chatmail`, we should just get rid of `is_chatmail` dependency, it will make even less sense for multitransport. Probably just set the same low limit for webxdc updates for everyone, chatmail or not.


Discussion:

Patch:
diff --git a/src/context.rs b/src/context.rs
index cfff416326..d149c7446b 100644
--- a/src/context.rs
+++ b/src/context.rs
@@ -453,7 +453,7 @@ impl Context {
             translated_stockstrings: stockstrings,
             events,
             scheduler: SchedulerState::new(),
-            ratelimit: RwLock::new(Ratelimit::new(Duration::new(60, 0), 6.0)), // Allow at least 1 message every 10 seconds + a burst of 6.
+            ratelimit: RwLock::new(Ratelimit::new(Duration::new(3, 0), 3.0)), // Allow at least 1 message every second + a burst of 3.
             quota: RwLock::new(None),
             new_msgs_notify,
             server_id: RwLock::new(None),
@@ -485,12 +485,6 @@ impl Context {
             return;
         }
 
-        if self.is_chatmail().await.unwrap_or_default() {
-            let mut lock = self.ratelimit.write().await;
-            // Allow at least 1 message every second + a burst of 3.
-            *lock = Ratelimit::new(Duration::new(3, 0), 3.0);
-        }
-
         // The next line is mainly for iOS:
         // iOS starts a separate process for receiving notifications and if the user concurrently
         // starts the app, the UI process opens the database but waits with calling start_io()


Test patch:
diff --git a/src/webxdc/webxdc_tests.rs b/src/webxdc/webxdc_tests.rs
index cc205f3fc9..3a03d606f7 100644
--- a/src/webxdc/webxdc_tests.rs
+++ b/src/webxdc/webxdc_tests.rs
@@ -1289,7 +1289,7 @@ async fn test_get_webxdc_info() -> Result<()> {
     let info = instance.get_webxdc_info(&t).await?;
     assert_eq!(info.name, "minimal.xdc");
     assert_eq!(info.icon, WEBXDC_DEFAULT_ICON.to_string());
-    assert_eq!(info.send_update_interval, 10000);
+    assert_eq!(info.send_update_interval, 1000);
     assert_eq!(info.send_update_max_size, RECOMMENDED_FILE_SIZE as usize);
 
     let mut instance = create_webxdc_instance(