1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-12-01 04:43:29 +03:00

Merge pull request #1242 from matrix-org/foldleft/fix-bad-merge

Fixed up tests to match new way that crypto stores are created
This commit is contained in:
Zoe
2020-03-02 15:01:27 +00:00
committed by GitHub
2 changed files with 8 additions and 10 deletions

View File

@@ -216,7 +216,7 @@ describe.each([
() => new IndexedDBCryptoStore(undefined, "tests")],
["MemoryCryptoStore", () => {
const store = new IndexedDBCryptoStore(undefined, "tests");
store._backendPromise = Promise.resolve(new MemoryCryptoStore());
store._backend = new MemoryCryptoStore();
return store;
}],
])("CrossSigning > createCryptoStoreCacheCallbacks [%s]", function(name, dbFactory) {
@@ -230,17 +230,18 @@ describe.each([
await store.deleteAllData();
});
it("should cache data to the store and retrieves it", async () => {
it("should cache data to the store and retrieve it", async () => {
await store.startup();
const { getCrossSigningKeyCache, storeCrossSigningKeyCache } =
createCryptoStoreCacheCallbacks(store);
await storeCrossSigningKeyCache("master", testKey);
await storeCrossSigningKeyCache("self_signing", testKey);
// If we've not saved anything, don't expect anything
// Definitely don't accidentally return the wrong key for the type
const nokey = await getCrossSigningKeyCache("self", "");
expect(nokey).toBeNull();
const key = await getCrossSigningKeyCache("master", "");
const key = await getCrossSigningKeyCache("self_signing", "");
expect(key).toEqual(testKey);
});
});

View File

@@ -313,9 +313,8 @@ export class IndexedDBCryptoStore {
* @param {function(string)} func Called with the private key
* @param {string} type A key type
*/
async getCrossSigningPrivateKey(txn, func, type) {
const backend = await this._connect();
return backend.getCrossSigningPrivateKey(txn, func, type);
getCrossSigningPrivateKey(txn, func, type) {
this._backend.getCrossSigningPrivateKey(txn, func, type);
}
/**
@@ -336,9 +335,7 @@ export class IndexedDBCryptoStore {
* @param {string} key keys object as getCrossSigningKeys()
*/
storeCrossSigningPrivateKey(txn, type, key) {
this._backendPromise.then(backend => {
backend.storeCrossSigningPrivateKey(txn, type, key);
});
this._backend.storeCrossSigningPrivateKey(txn, type, key);
}
// Olm sessions