You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-25 05:23:13 +03:00
fix unit tests
This commit is contained in:
@@ -16,6 +16,7 @@ limitations under the License.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {logger} from '../src/logger';
|
import {logger} from '../src/logger';
|
||||||
|
import * as utils from "../src/utils";
|
||||||
|
|
||||||
// try to load the olm library.
|
// try to load the olm library.
|
||||||
try {
|
try {
|
||||||
@@ -24,3 +25,11 @@ try {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.warn("unable to run crypto tests: libolm not available");
|
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');
|
||||||
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import {
|
|||||||
import {MemoryCryptoStore} from '../../../src/crypto/store/memory-crypto-store';
|
import {MemoryCryptoStore} from '../../../src/crypto/store/memory-crypto-store';
|
||||||
import 'fake-indexeddb/auto';
|
import 'fake-indexeddb/auto';
|
||||||
import 'jest-localstorage-mock';
|
import 'jest-localstorage-mock';
|
||||||
|
import {OlmDevice} from "../../../src/crypto/OlmDevice";
|
||||||
|
|
||||||
const userId = "@alice:example.com";
|
const userId = "@alice:example.com";
|
||||||
|
|
||||||
@@ -233,8 +234,9 @@ describe.each([
|
|||||||
|
|
||||||
it("should cache data to the store and retrieve it", async () => {
|
it("should cache data to the store and retrieve it", async () => {
|
||||||
await store.startup();
|
await store.startup();
|
||||||
|
const olmDevice = new OlmDevice(store);
|
||||||
const { getCrossSigningKeyCache, storeCrossSigningKeyCache } =
|
const { getCrossSigningKeyCache, storeCrossSigningKeyCache } =
|
||||||
createCryptoStoreCacheCallbacks(store);
|
createCryptoStoreCacheCallbacks(store, olmDevice);
|
||||||
await storeCrossSigningKeyCache("self_signing", testKey);
|
await storeCrossSigningKeyCache("self_signing", testKey);
|
||||||
|
|
||||||
// If we've not saved anything, don't expect anything
|
// If we've not saved anything, don't expect anything
|
||||||
|
|||||||
Reference in New Issue
Block a user