diff --git a/spec/unit/crypto/CrossSigningInfo.spec.js b/spec/unit/crypto/CrossSigningInfo.spec.js index 08572e846..92dfa50d3 100644 --- a/spec/unit/crypto/CrossSigningInfo.spec.js +++ b/spec/unit/crypto/CrossSigningInfo.spec.js @@ -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); }); }); diff --git a/src/crypto/store/indexeddb-crypto-store.js b/src/crypto/store/indexeddb-crypto-store.js index f9218abe4..6dfac53df 100644 --- a/src/crypto/store/indexeddb-crypto-store.js +++ b/src/crypto/store/indexeddb-crypto-store.js @@ -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