@@ -44,6 +44,7 @@ import { logger } from "../../src/logger";
44
44
import { emitPromise } from "../test-utils/test-utils" ;
45
45
import { defer } from "../../src/utils" ;
46
46
import { KnownMembership } from "../../src/@types/membership" ;
47
+ import { SyncCryptoCallbacks } from "../../src/common-crypto/CryptoBackend" ;
47
48
48
49
declare module "../../src/@types/event" {
49
50
interface AccountDataEvents {
@@ -57,6 +58,7 @@ describe("SlidingSyncSdk", () => {
57
58
let httpBackend : MockHttpBackend | undefined ;
58
59
let sdk : SlidingSyncSdk | undefined ;
59
60
let mockSlidingSync : SlidingSync | undefined ;
61
+ let syncCryptoCallback : SyncCryptoCallbacks | undefined ;
60
62
const selfUserId = "@alice:localhost" ;
61
63
const selfAccessToken = "aseukfgwef" ;
62
64
@@ -126,8 +128,9 @@ describe("SlidingSyncSdk", () => {
126
128
mockSlidingSync = mockifySlidingSync ( new SlidingSync ( "" , new Map ( ) , { } , client , 0 ) ) ;
127
129
if ( testOpts . withCrypto ) {
128
130
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 ;
131
134
}
132
135
httpBackend ! . when ( "GET" , "/_matrix/client/v3/pushrules" ) . respond ( 200 , { } ) ;
133
136
sdk = new SlidingSyncSdk ( mockSlidingSync , client , testOpts , syncOpts ) ;
@@ -640,13 +643,6 @@ describe("SlidingSyncSdk", () => {
640
643
ext = findExtension ( "e2ee" ) ;
641
644
} ) ;
642
645
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
-
650
646
it ( "gets enabled on the initial request only" , ( ) => {
651
647
expect ( ext . onRequest ( true ) ) . toEqual ( {
652
648
enabled : true ,
@@ -655,28 +651,28 @@ describe("SlidingSyncSdk", () => {
655
651
} ) ;
656
652
657
653
it ( "can update device lists" , ( ) => {
658
- client ! . crypto ! . processDeviceLists = jest . fn ( ) ;
654
+ syncCryptoCallback ! . processDeviceLists = jest . fn ( ) ;
659
655
ext . onResponse ( {
660
656
device_lists : {
661
657
changed : [ "@alice:localhost" ] ,
662
658
left : [ "@bob:localhost" ] ,
663
659
} ,
664
660
} ) ;
665
- expect ( client ! . crypto ! . processDeviceLists ) . toHaveBeenCalledWith ( {
661
+ expect ( syncCryptoCallback ! . processDeviceLists ) . toHaveBeenCalledWith ( {
666
662
changed : [ "@alice:localhost" ] ,
667
663
left : [ "@bob:localhost" ] ,
668
664
} ) ;
669
665
} ) ;
670
666
671
667
it ( "can update OTK counts and unused fallback keys" , ( ) => {
672
- client ! . crypto ! . processKeyCounts = jest . fn ( ) ;
668
+ syncCryptoCallback ! . processKeyCounts = jest . fn ( ) ;
673
669
ext . onResponse ( {
674
670
device_one_time_keys_count : {
675
671
signed_curve25519 : 42 ,
676
672
} ,
677
673
device_unused_fallback_key_types : [ "signed_curve25519" ] ,
678
674
} ) ;
679
- expect ( client ! . crypto ! . processKeyCounts ) . toHaveBeenCalledWith ( { signed_curve25519 : 42 } , [
675
+ expect ( syncCryptoCallback ! . processKeyCounts ) . toHaveBeenCalledWith ( { signed_curve25519 : 42 } , [
680
676
"signed_curve25519" ,
681
677
] ) ;
682
678
} ) ;
0 commit comments