1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-26 17:03:12 +03:00

More test fixing

* Change test for new storage layer
 * Always store device keys we download, even if we weren't
   tracking the user.
This commit is contained in:
David Baker
2018-01-17 18:49:33 +00:00
parent 5bab8647b6
commit 461acbcc81
2 changed files with 15 additions and 10 deletions

View File

@@ -154,11 +154,15 @@ function aliDownloadsKeys() {
// check that the localStorage is updated as we expect (not sure this is // check that the localStorage is updated as we expect (not sure this is
// an integration test, but meh) // an integration test, but meh)
return Promise.all([p1, p2]).then(function() { return Promise.all([p1, p2]).then(() => {
const devices = aliTestClient.storage.getEndToEndDevicesForUser(bobUserId); return aliTestClient.client._crypto._deviceList.saveIfDirty();
expect(devices[bobDeviceId].keys).toEqual(bobTestClient.deviceKeys.keys); }).then(() => {
expect(devices[bobDeviceId].verified). aliTestClient.cryptoStore.getEndToEndDeviceData(null, (data) => {
toBe(0); // DeviceVerification.UNVERIFIED const devices = data.devices[bobUserId];
expect(devices[bobDeviceId].keys).toEqual(bobTestClient.deviceKeys.keys);
expect(devices[bobDeviceId].verified).
toBe(0); // DeviceVerification.UNVERIFIED
});
}); });
} }

View File

@@ -193,8 +193,9 @@ export default class DeviceList {
} }
/** /**
* Download the keys for a list of users and stores the keys in the session * Ensures up to date keys for a list of users are stored in the session store,
* store. * downloading and storing them if they're not (or if forceDownload is
* true).
* @param {Array} userIds The users to fetch. * @param {Array} userIds The users to fetch.
* @param {bool} forceDownload Always download the keys even if cached. * @param {bool} forceDownload Always download the keys even if cached.
* *
@@ -427,7 +428,6 @@ export default class DeviceList {
for (const userId of Object.keys(this._deviceTrackingStatus)) { for (const userId of Object.keys(this._deviceTrackingStatus)) {
this._deviceTrackingStatus[userId] = TRACKING_STATUS_NOT_TRACKED; this._deviceTrackingStatus[userId] = TRACKING_STATUS_NOT_TRACKED;
} }
console.log("stopped tracking all: "+JSON.stringify(this._deviceTrackingStatus));
this._dirty = true; this._dirty = true;
} }
@@ -513,6 +513,9 @@ export default class DeviceList {
const finished = (newDevices) => { const finished = (newDevices) => {
users.forEach((u) => { users.forEach((u) => {
this._devices[u] = newDevices[u];
this._dirty = true;
// we may have queued up another download request for this user // we may have queued up another download request for this user
// since we started this request. If that happens, we should // since we started this request. If that happens, we should
// ignore the completion of the first one. // ignore the completion of the first one.
@@ -528,8 +531,6 @@ export default class DeviceList {
// we didn't get any new invalidations since this download started: // we didn't get any new invalidations since this download started:
// this user's device list is now up to date. // this user's device list is now up to date.
this._deviceTrackingStatus[u] = TRACKING_STATUS_UP_TO_DATE; this._deviceTrackingStatus[u] = TRACKING_STATUS_UP_TO_DATE;
this._devices[u] = newDevices[u];
this._dirty = true;
console.log("Device list for", u, "now up to date"); console.log("Device list for", u, "now up to date");
} else { } else {
this._deviceTrackingStatus[u] = TRACKING_STATUS_PENDING_DOWNLOAD; this._deviceTrackingStatus[u] = TRACKING_STATUS_PENDING_DOWNLOAD;