@@ -1760,7 +1760,7 @@ describe("crypto", () => {
17601760
17611761 beforeEach ( async ( ) => {
17621762 createSecretStorageKey . mockClear ( ) ;
1763- accountDataAccumulator = new AccountDataAccumulator ( ) ;
1763+ accountDataAccumulator = new AccountDataAccumulator ( syncResponder ) ;
17641764 expectAliceKeyQuery ( { device_keys : { "@alice:localhost" : { } } , failures : { } } ) ;
17651765 await startClientAndAwaitFirstSync ( ) ;
17661766 } ) ;
@@ -1787,28 +1787,18 @@ describe("crypto", () => {
17871787 repeat : 1 ,
17881788 overwriteRoutes : true ,
17891789 } ) ;
1790- accountDataAccumulator . sendSyncResponseWithUpdatedAccountData ( syncResponder ) ;
17911790 if ( content . key ) {
17921791 return content . key ;
17931792 }
17941793 }
17951794 }
17961795
1797- function awaitMegolmBackupKeyUpload ( ) : Promise < Record < string , { } > > {
1798- return new Promise ( ( resolve ) => {
1799- // Called when the megolm backup key is uploaded
1800- fetchMock . put (
1801- `express:/_matrix/client/v3/user/:userId/account_data/m.megolm_backup.v1` ,
1802- ( url : string , options : RequestInit ) => {
1803- const content = JSON . parse ( options . body as string ) ;
1804- // update account data for sync response
1805- accountDataAccumulator . accountDataEvents . set ( "m.megolm_backup.v1" , content ) ;
1806- resolve ( content . encrypted ) ;
1807- return { } ;
1808- } ,
1809- { overwriteRoutes : true } ,
1810- ) ;
1796+ async function awaitMegolmBackupKeyUpload ( ) : Promise < Record < string , { } > > {
1797+ const content = await accountDataAccumulator . interceptSetAccountData ( "m.megolm_backup.v1" , {
1798+ repeat : 1 ,
1799+ overwriteRoutes : true ,
18111800 } ) ;
1801+ return content . encrypted ;
18121802 }
18131803
18141804 function awaitAccountDataUpdate ( type : string ) : Promise < void > {
@@ -1866,9 +1856,6 @@ describe("crypto", () => {
18661856 // wait for bootstrapSecretStorage to finished
18671857 await bootstrapPromise ;
18681858
1869- // Return the newly created key in the sync response
1870- accountDataAccumulator . sendSyncResponseWithUpdatedAccountData ( syncResponder ) ;
1871-
18721859 // Finally ensure backup is working
18731860 await aliceClient . getCrypto ( ) ! . checkKeyBackupAndEnable ( ) ;
18741861
@@ -1928,9 +1915,6 @@ describe("crypto", () => {
19281915 expect ( keyContent . iv ) . toBeDefined ( ) ;
19291916 expect ( keyContent . mac ) . toBeDefined ( ) ;
19301917
1931- // Return the newly created key in the sync response
1932- accountDataAccumulator . sendSyncResponseWithUpdatedAccountData ( syncResponder ) ;
1933-
19341918 // Finally, wait for bootstrapSecretStorage to finished
19351919 await bootstrapPromise ;
19361920
@@ -1950,9 +1934,6 @@ describe("crypto", () => {
19501934 // Wait for the key to be uploaded in the account data
19511935 await awaitSecretStorageKeyStoredInAccountData ( ) ;
19521936
1953- // Return the newly created key in the sync response
1954- accountDataAccumulator . sendSyncResponseWithUpdatedAccountData ( syncResponder ) ;
1955-
19561937 // Wait for bootstrapSecretStorage to finished
19571938 await bootstrapPromise ;
19581939
@@ -1971,9 +1952,6 @@ describe("crypto", () => {
19711952 // Wait for the key to be uploaded in the account data
19721953 await awaitSecretStorageKeyStoredInAccountData ( ) ;
19731954
1974- // Return the newly created key in the sync response
1975- accountDataAccumulator . sendSyncResponseWithUpdatedAccountData ( syncResponder ) ;
1976-
19771955 // Wait for bootstrapSecretStorage to finished
19781956 await bootstrapPromise ;
19791957
@@ -1985,9 +1963,6 @@ describe("crypto", () => {
19851963 // Wait for the key to be uploaded in the account data
19861964 await awaitSecretStorageKeyStoredInAccountData ( ) ;
19871965
1988- // Return the newly created key in the sync response
1989- accountDataAccumulator . sendSyncResponseWithUpdatedAccountData ( syncResponder ) ;
1990-
19911966 // Wait for bootstrapSecretStorage to finished
19921967 await bootstrapPromise ;
19931968
@@ -2009,9 +1984,6 @@ describe("crypto", () => {
20091984 // Wait for the key to be uploaded in the account data
20101985 const secretStorageKey = await awaitSecretStorageKeyStoredInAccountData ( ) ;
20111986
2012- // Return the newly created key in the sync response
2013- accountDataAccumulator . sendSyncResponseWithUpdatedAccountData ( syncResponder ) ;
2014-
20151987 // Wait for the cross signing keys to be uploaded
20161988 const [ masterKey , userSigningKey , selfSigningKey ] = await Promise . all ( [
20171989 awaitCrossSigningKeyUpload ( "master" ) ,
0 commit comments