fix tests and stuffs

This commit is contained in:
Sorunome 2020-05-21 15:32:06 +02:00
parent af961b99dc
commit ead44e4014
No known key found for this signature in database
GPG key ID: B19471D07FC9BE9C
4 changed files with 7 additions and 9 deletions

View file

@ -113,9 +113,7 @@ abstract class _SignedKey {
} }
bool hasValidSignatureChain({Set<String> visited}) { bool hasValidSignatureChain({Set<String> visited}) {
if (visited == null) { visited ??= <String>{};
visited = Set<String>();
}
final setKey = '${userId};${identifier}'; final setKey = '${userId};${identifier}';
if (visited.contains(setKey)) { if (visited.contains(setKey)) {
return false; // prevent recursion return false; // prevent recursion

View file

@ -601,7 +601,7 @@ void main() {
'dSO80A01XiigH3uBiDVx/EjzaoycHcjq9lfQX0uWsqxl2giMIiSPR8a4d291W1ihKJL/a+myXS367WT6NAIcBA' 'dSO80A01XiigH3uBiDVx/EjzaoycHcjq9lfQX0uWsqxl2giMIiSPR8a4d291W1ihKJL/a+myXS367WT6NAIcBA'
} }
} }
}); }, matrix);
test('startOutgoingOlmSessions', () async { test('startOutgoingOlmSessions', () async {
expect(matrix.olmSessions.length, 0); expect(matrix.olmSessions.length, 0);
if (olmEnabled) { if (olmEnabled) {

View file

@ -56,21 +56,21 @@ void main() {
}; };
var userDeviceKeys = <String, DeviceKeysList>{ var userDeviceKeys = <String, DeviceKeysList>{
'@alice:example.com': DeviceKeysList.fromJson(rawListJson), '@alice:example.com': DeviceKeysList.fromJson(rawListJson, null),
}; };
var userDeviceKeyRaw = <String, dynamic>{ var userDeviceKeyRaw = <String, dynamic>{
'@alice:example.com': rawListJson, '@alice:example.com': rawListJson,
}; };
expect(json.encode(DeviceKeys.fromJson(rawJson).toJson()), expect(json.encode(DeviceKeys.fromJson(rawJson, null).toJson()),
json.encode(rawJson)); json.encode(rawJson));
expect(json.encode(DeviceKeysList.fromJson(rawListJson).toJson()), expect(json.encode(DeviceKeysList.fromJson(rawListJson, null).toJson()),
json.encode(rawListJson)); json.encode(rawListJson));
var mapFromRaw = <String, DeviceKeysList>{}; var mapFromRaw = <String, DeviceKeysList>{};
for (final rawListEntry in userDeviceKeyRaw.entries) { for (final rawListEntry in userDeviceKeyRaw.entries) {
mapFromRaw[rawListEntry.key] = mapFromRaw[rawListEntry.key] =
DeviceKeysList.fromJson(rawListEntry.value); DeviceKeysList.fromJson(rawListEntry.value, null);
} }
expect(mapFromRaw.toString(), userDeviceKeys.toString()); expect(mapFromRaw.toString(), userDeviceKeys.toString());
}); });

View file

@ -109,7 +109,7 @@ void test() async {
assert(!testClientB assert(!testClientB
.userDeviceKeys[testUserA].deviceKeys[testClientA.deviceID].blocked); .userDeviceKeys[testUserA].deviceKeys[testClientA.deviceID].blocked);
await testClientA.userDeviceKeys[testUserB].deviceKeys[testClientB.deviceID] await testClientA.userDeviceKeys[testUserB].deviceKeys[testClientB.deviceID]
.setVerified(true, testClientA); .setVerified(true);
print('++++ Check if own olm device is verified by default ++++'); print('++++ Check if own olm device is verified by default ++++');
assert(testClientA.userDeviceKeys.containsKey(testUserA)); assert(testClientA.userDeviceKeys.containsKey(testUserA));