diff --git a/spec/olm-loader.js b/spec/olm-loader.js index b06ecdffc..22f049aeb 100644 --- a/spec/olm-loader.js +++ b/spec/olm-loader.js @@ -16,6 +16,7 @@ limitations under the License. */ import {logger} from '../src/logger'; +import * as utils from "../src/utils"; // try to load the olm library. try { @@ -24,3 +25,11 @@ try { } catch (e) { logger.warn("unable to run crypto tests: libolm not available"); } + +// also try to set node crypto +try { + const crypto = require('crypto'); + utils.setCrypto(crypto); +} catch (err) { + console.log('nodejs was compiled without crypto support: some tests will fail'); +} diff --git a/spec/unit/crypto/CrossSigningInfo.spec.js b/spec/unit/crypto/CrossSigningInfo.spec.js index c49451ed8..92f80aa82 100644 --- a/spec/unit/crypto/CrossSigningInfo.spec.js +++ b/spec/unit/crypto/CrossSigningInfo.spec.js @@ -25,6 +25,7 @@ import { import {MemoryCryptoStore} from '../../../src/crypto/store/memory-crypto-store'; import 'fake-indexeddb/auto'; import 'jest-localstorage-mock'; +import {OlmDevice} from "../../../src/crypto/OlmDevice"; const userId = "@alice:example.com"; @@ -233,8 +234,9 @@ describe.each([ it("should cache data to the store and retrieve it", async () => { await store.startup(); + const olmDevice = new OlmDevice(store); const { getCrossSigningKeyCache, storeCrossSigningKeyCache } = - createCryptoStoreCacheCallbacks(store); + createCryptoStoreCacheCallbacks(store, olmDevice); await storeCrossSigningKeyCache("self_signing", testKey); // If we've not saved anything, don't expect anything