From b74dbdea4a6b7e029b9b656880ce1528dcea0daa Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Mon, 7 Oct 2024 19:00:58 +0200 Subject: [PATCH] fix: Don't wait for 5 milliseconds on every sync in our tests This was added in 77be6102f6cbb2e01adc28f9caa3aa583f914235 without much documentation. I am pretty sure the intent was never to slow down every test by 5 seconds, so let's get rid of it and do more careful delays where it is useful (like specific sync requests for example). Makes the tests run 5 times faster (the whole suite!) on my device. --- lib/fake_matrix_api.dart | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/fake_matrix_api.dart b/lib/fake_matrix_api.dart index c78d1aae..d6951ea1 100644 --- a/lib/fake_matrix_api.dart +++ b/lib/fake_matrix_api.dart @@ -127,10 +127,6 @@ class FakeMatrixApi extends BaseClient { //print('\$method request to $action with Data: $data'); - // Sync requests with timeout - if (data is Map && data['timeout'] is String) { - await Future.delayed(Duration(seconds: 5)); - } if (!servers.contains(request.url.origin)) { return Response( 'Not found ${request.url.origin}...', @@ -202,6 +198,11 @@ class FakeMatrixApi extends BaseClient { '/client/v3/rooms/!1234%3AfakeServer.notExisting/state/')) { res = {'event_id': '\$event${_eventCounter++}'}; } else if (action.contains('/client/v3/sync')) { + // Sync requests with timeout + final timeout = request.url.queryParameters['timeout']; + if (timeout != null && timeout != '0') { + await Future.delayed(Duration(milliseconds: 50)); + } res = { 'next_batch': DateTime.now().millisecondsSinceEpoch.toString(), };