@@ -1760,7 +1760,7 @@ describe("crypto", () => {
1760
1760
1761
1761
beforeEach ( async ( ) => {
1762
1762
createSecretStorageKey . mockClear ( ) ;
1763
- accountDataAccumulator = new AccountDataAccumulator ( ) ;
1763
+ accountDataAccumulator = new AccountDataAccumulator ( syncResponder ) ;
1764
1764
expectAliceKeyQuery ( { device_keys : { "@alice:localhost" : { } } , failures : { } } ) ;
1765
1765
await startClientAndAwaitFirstSync ( ) ;
1766
1766
} ) ;
@@ -1787,28 +1787,18 @@ describe("crypto", () => {
1787
1787
repeat : 1 ,
1788
1788
overwriteRoutes : true ,
1789
1789
} ) ;
1790
- accountDataAccumulator . sendSyncResponseWithUpdatedAccountData ( syncResponder ) ;
1791
1790
if ( content . key ) {
1792
1791
return content . key ;
1793
1792
}
1794
1793
}
1795
1794
}
1796
1795
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 ,
1811
1800
} ) ;
1801
+ return content . encrypted ;
1812
1802
}
1813
1803
1814
1804
function awaitAccountDataUpdate ( type : string ) : Promise < void > {
@@ -1866,9 +1856,6 @@ describe("crypto", () => {
1866
1856
// wait for bootstrapSecretStorage to finished
1867
1857
await bootstrapPromise ;
1868
1858
1869
- // Return the newly created key in the sync response
1870
- accountDataAccumulator . sendSyncResponseWithUpdatedAccountData ( syncResponder ) ;
1871
-
1872
1859
// Finally ensure backup is working
1873
1860
await aliceClient . getCrypto ( ) ! . checkKeyBackupAndEnable ( ) ;
1874
1861
@@ -1928,9 +1915,6 @@ describe("crypto", () => {
1928
1915
expect ( keyContent . iv ) . toBeDefined ( ) ;
1929
1916
expect ( keyContent . mac ) . toBeDefined ( ) ;
1930
1917
1931
- // Return the newly created key in the sync response
1932
- accountDataAccumulator . sendSyncResponseWithUpdatedAccountData ( syncResponder ) ;
1933
-
1934
1918
// Finally, wait for bootstrapSecretStorage to finished
1935
1919
await bootstrapPromise ;
1936
1920
@@ -1950,9 +1934,6 @@ describe("crypto", () => {
1950
1934
// Wait for the key to be uploaded in the account data
1951
1935
await awaitSecretStorageKeyStoredInAccountData ( ) ;
1952
1936
1953
- // Return the newly created key in the sync response
1954
- accountDataAccumulator . sendSyncResponseWithUpdatedAccountData ( syncResponder ) ;
1955
-
1956
1937
// Wait for bootstrapSecretStorage to finished
1957
1938
await bootstrapPromise ;
1958
1939
@@ -1971,9 +1952,6 @@ describe("crypto", () => {
1971
1952
// Wait for the key to be uploaded in the account data
1972
1953
await awaitSecretStorageKeyStoredInAccountData ( ) ;
1973
1954
1974
- // Return the newly created key in the sync response
1975
- accountDataAccumulator . sendSyncResponseWithUpdatedAccountData ( syncResponder ) ;
1976
-
1977
1955
// Wait for bootstrapSecretStorage to finished
1978
1956
await bootstrapPromise ;
1979
1957
@@ -1985,9 +1963,6 @@ describe("crypto", () => {
1985
1963
// Wait for the key to be uploaded in the account data
1986
1964
await awaitSecretStorageKeyStoredInAccountData ( ) ;
1987
1965
1988
- // Return the newly created key in the sync response
1989
- accountDataAccumulator . sendSyncResponseWithUpdatedAccountData ( syncResponder ) ;
1990
-
1991
1966
// Wait for bootstrapSecretStorage to finished
1992
1967
await bootstrapPromise ;
1993
1968
@@ -2009,9 +1984,6 @@ describe("crypto", () => {
2009
1984
// Wait for the key to be uploaded in the account data
2010
1985
const secretStorageKey = await awaitSecretStorageKeyStoredInAccountData ( ) ;
2011
1986
2012
- // Return the newly created key in the sync response
2013
- accountDataAccumulator . sendSyncResponseWithUpdatedAccountData ( syncResponder ) ;
2014
-
2015
1987
// Wait for the cross signing keys to be uploaded
2016
1988
const [ masterKey , userSigningKey , selfSigningKey ] = await Promise . all ( [
2017
1989
awaitCrossSigningKeyUpload ( "master" ) ,
0 commit comments