From ead44e4014fa400961dc8fa7bb5a7503f8134b98 Mon Sep 17 00:00:00 2001 From: Sorunome Date: Thu, 21 May 2020 15:32:06 +0200 Subject: [PATCH] fix tests and stuffs --- lib/src/utils/device_keys_list.dart | 4 +--- test/client_test.dart | 2 +- test/device_keys_list_test.dart | 8 ++++---- test_driver/famedlysdk_test.dart | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/src/utils/device_keys_list.dart b/lib/src/utils/device_keys_list.dart index 162eb59c..8dbe4f1b 100644 --- a/lib/src/utils/device_keys_list.dart +++ b/lib/src/utils/device_keys_list.dart @@ -113,9 +113,7 @@ abstract class _SignedKey { } bool hasValidSignatureChain({Set visited}) { - if (visited == null) { - visited = Set(); - } + visited ??= {}; final setKey = '${userId};${identifier}'; if (visited.contains(setKey)) { return false; // prevent recursion diff --git a/test/client_test.dart b/test/client_test.dart index 2d5b66ea..4e6f0a1a 100644 --- a/test/client_test.dart +++ b/test/client_test.dart @@ -601,7 +601,7 @@ void main() { 'dSO80A01XiigH3uBiDVx/EjzaoycHcjq9lfQX0uWsqxl2giMIiSPR8a4d291W1ihKJL/a+myXS367WT6NAIcBA' } } - }); + }, matrix); test('startOutgoingOlmSessions', () async { expect(matrix.olmSessions.length, 0); if (olmEnabled) { diff --git a/test/device_keys_list_test.dart b/test/device_keys_list_test.dart index 08b83e29..c9de76e8 100644 --- a/test/device_keys_list_test.dart +++ b/test/device_keys_list_test.dart @@ -56,21 +56,21 @@ void main() { }; var userDeviceKeys = { - '@alice:example.com': DeviceKeysList.fromJson(rawListJson), + '@alice:example.com': DeviceKeysList.fromJson(rawListJson, null), }; var userDeviceKeyRaw = { '@alice:example.com': rawListJson, }; - expect(json.encode(DeviceKeys.fromJson(rawJson).toJson()), + expect(json.encode(DeviceKeys.fromJson(rawJson, null).toJson()), json.encode(rawJson)); - expect(json.encode(DeviceKeysList.fromJson(rawListJson).toJson()), + expect(json.encode(DeviceKeysList.fromJson(rawListJson, null).toJson()), json.encode(rawListJson)); var mapFromRaw = {}; for (final rawListEntry in userDeviceKeyRaw.entries) { mapFromRaw[rawListEntry.key] = - DeviceKeysList.fromJson(rawListEntry.value); + DeviceKeysList.fromJson(rawListEntry.value, null); } expect(mapFromRaw.toString(), userDeviceKeys.toString()); }); diff --git a/test_driver/famedlysdk_test.dart b/test_driver/famedlysdk_test.dart index fc145cd0..8d3c96f1 100644 --- a/test_driver/famedlysdk_test.dart +++ b/test_driver/famedlysdk_test.dart @@ -109,7 +109,7 @@ void test() async { assert(!testClientB .userDeviceKeys[testUserA].deviceKeys[testClientA.deviceID].blocked); await testClientA.userDeviceKeys[testUserB].deviceKeys[testClientB.deviceID] - .setVerified(true, testClientA); + .setVerified(true); print('++++ Check if own olm device is verified by default ++++'); assert(testClientA.userDeviceKeys.containsKey(testUserA));