@@ -44,6 +44,7 @@ import { logger } from "../../src/logger";
4444import { emitPromise } from "../test-utils/test-utils" ;
4545import { defer } from "../../src/utils" ;
4646import { KnownMembership } from "../../src/@types/membership" ;
47+ import { SyncCryptoCallbacks } from "../../src/common-crypto/CryptoBackend" ;
4748
4849declare module "../../src/@types/event" {
4950 interface AccountDataEvents {
@@ -57,6 +58,7 @@ describe("SlidingSyncSdk", () => {
5758 let httpBackend : MockHttpBackend | undefined ;
5859 let sdk : SlidingSyncSdk | undefined ;
5960 let mockSlidingSync : SlidingSync | undefined ;
61+ let syncCryptoCallback : SyncCryptoCallbacks | undefined ;
6062 const selfUserId = "@alice:localhost" ;
6163 const selfAccessToken = "aseukfgwef" ;
6264
@@ -126,8 +128,9 @@ describe("SlidingSyncSdk", () => {
126128 mockSlidingSync = mockifySlidingSync ( new SlidingSync ( "" , new Map ( ) , { } , client , 0 ) ) ;
127129 if ( testOpts . withCrypto ) {
128130 httpBackend ! . when ( "GET" , "/room_keys/version" ) . respond ( 404 , { } ) ;
129- await client ! . initLegacyCrypto ( ) ;
130- syncOpts . cryptoCallbacks = syncOpts . crypto = client ! . crypto ;
131+ await client ! . initRustCrypto ( { useIndexedDB : false } ) ;
132+ syncCryptoCallback = client ! . getCrypto ( ) as unknown as SyncCryptoCallbacks ;
133+ syncOpts . cryptoCallbacks = syncCryptoCallback ;
131134 }
132135 httpBackend ! . when ( "GET" , "/_matrix/client/v3/pushrules" ) . respond ( 200 , { } ) ;
133136 sdk = new SlidingSyncSdk ( mockSlidingSync , client , testOpts , syncOpts ) ;
@@ -640,13 +643,6 @@ describe("SlidingSyncSdk", () => {
640643 ext = findExtension ( "e2ee" ) ;
641644 } ) ;
642645
643- afterAll ( async ( ) => {
644- // needed else we do some async operations in the background which can cause Jest to whine:
645- // "Cannot log after tests are done. Did you forget to wait for something async in your test?"
646- // Attempted to log "Saving device tracking data null"."
647- client ! . crypto ! . stop ( ) ;
648- } ) ;
649-
650646 it ( "gets enabled on the initial request only" , ( ) => {
651647 expect ( ext . onRequest ( true ) ) . toEqual ( {
652648 enabled : true ,
@@ -655,28 +651,28 @@ describe("SlidingSyncSdk", () => {
655651 } ) ;
656652
657653 it ( "can update device lists" , ( ) => {
658- client ! . crypto ! . processDeviceLists = jest . fn ( ) ;
654+ syncCryptoCallback ! . processDeviceLists = jest . fn ( ) ;
659655 ext . onResponse ( {
660656 device_lists : {
661657 changed : [ "@alice:localhost" ] ,
662658 left : [ "@bob:localhost" ] ,
663659 } ,
664660 } ) ;
665- expect ( client ! . crypto ! . processDeviceLists ) . toHaveBeenCalledWith ( {
661+ expect ( syncCryptoCallback ! . processDeviceLists ) . toHaveBeenCalledWith ( {
666662 changed : [ "@alice:localhost" ] ,
667663 left : [ "@bob:localhost" ] ,
668664 } ) ;
669665 } ) ;
670666
671667 it ( "can update OTK counts and unused fallback keys" , ( ) => {
672- client ! . crypto ! . processKeyCounts = jest . fn ( ) ;
668+ syncCryptoCallback ! . processKeyCounts = jest . fn ( ) ;
673669 ext . onResponse ( {
674670 device_one_time_keys_count : {
675671 signed_curve25519 : 42 ,
676672 } ,
677673 device_unused_fallback_key_types : [ "signed_curve25519" ] ,
678674 } ) ;
679- expect ( client ! . crypto ! . processKeyCounts ) . toHaveBeenCalledWith ( { signed_curve25519 : 42 } , [
675+ expect ( syncCryptoCallback ! . processKeyCounts ) . toHaveBeenCalledWith ( { signed_curve25519 : 42 } , [
680676 "signed_curve25519" ,
681677 ] ) ;
682678 } ) ;
0 commit comments