From 4b61d2f458f3e7a920694c7b03fb4b3154fe436d Mon Sep 17 00:00:00 2001
From: Nicolas Werner <nicolas.werner@hotmail.de>
Date: Mon, 25 Jul 2022 13:45:05 +0200
Subject: [PATCH] Fix typing tests on servers caching the initial sync

See https://github.com/matrix-org/synapse/issues/13375
---
 .ci/synapse/Dockerfile | 3 +--
 Makefile               | 3 +--
 tests/client_api.cpp   | 8 ++++----
 3 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/.ci/synapse/Dockerfile b/.ci/synapse/Dockerfile
index 15c56d46a..789903fa0 100644
--- a/.ci/synapse/Dockerfile
+++ b/.ci/synapse/Dockerfile
@@ -1,5 +1,4 @@
-FROM matrixdotorg/synapse:v1.61.0
-# see https://github.com/matrix-org/synapse/issues/13375
+FROM matrixdotorg/synapse:v1.63.1
 
 COPY setup-synapse.sh /setup-synapse.sh
 COPY entrypoint.sh /entrypoint.sh
diff --git a/Makefile b/Makefile
index 88693ea43..b12b49a2a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,6 @@
 FILES=`find lib include tests examples -type f -type f \( -iname "*.cpp" -o -iname "*.hpp" \)`
 
-# see https://github.com/matrix-org/synapse/issues/13375
-SYNAPSE_IMAGE="matrixdotorg/synapse:v1.61.0"
+SYNAPSE_IMAGE="matrixdotorg/synapse:v1.63.1"
 
 DEPS_BUILD_DIR=.deps
 DEPS_SOURCE_DIR=deps
diff --git a/tests/client_api.cpp b/tests/client_api.cpp
index 1d27b8fec..c0e43ad0a 100644
--- a/tests/client_api.cpp
+++ b/tests/client_api.cpp
@@ -1033,7 +1033,8 @@ TEST(ClientAPI, Typing)
             alice->sync(opts, [room_id, alice](const mtx::responses::Sync &res, RequestErr err) {
                 check_error(err);
 
-                auto room = res.rooms.join.at(room_id);
+                auto room       = res.rooms.join.at(room_id);
+                auto next_batch = res.next_batch;
 
                 EXPECT_EQ(room.ephemeral.events.size(), 1);
                 EXPECT_EQ(std::get<mtx::events::EphemeralEvent<mtx::events::ephemeral::Typing>>(
@@ -1041,13 +1042,12 @@ TEST(ClientAPI, Typing)
                             .content.user_ids.front(),
                           "@alice:" + server_name());
 
-                alice->stop_typing(room_id, [alice, room_id](RequestErr err) {
+                alice->stop_typing(room_id, [alice, room_id, next_batch](RequestErr err) {
                     check_error(err);
 
-                    std::this_thread::sleep_for(std::chrono::milliseconds(500));
-
                     SyncOpts opts;
                     opts.timeout = 0;
+                    opts.since   = next_batch;
                     alice->sync(opts, [room_id](const mtx::responses::Sync &res, RequestErr err) {
                         check_error(err);
                         auto room = res.rooms.join.at(room_id);
-- 
GitLab