fix: Don't wait for 5 milliseconds on every sync in our tests

This was added in 77be6102f6 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.
This commit is contained in:
Nicolas Werner 2024-10-07 19:00:58 +02:00
parent 2085964a68
commit b74dbdea4a
No known key found for this signature in database
GPG Key ID: B38119FF80087618
1 changed files with 5 additions and 4 deletions

View File

@ -127,10 +127,6 @@ class FakeMatrixApi extends BaseClient {
//print('\$method request to $action with Data: $data');
// Sync requests with timeout
if (data is Map<String, dynamic> && data['timeout'] is String) {
await Future.delayed(Duration(seconds: 5));
}
if (!servers.contains(request.url.origin)) {
return Response(
'<html><head></head><body>Not found ${request.url.origin}...</body></html>',
@ -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(),
};