Schedule dehydration on reload if the dehydration key is already cached locally (#29021)
* Schedule dehydration on reload * fix test and use the right function to check dehydration is enabled * use dehydration helper function when scheduling dehydration on restart * fix test by passing in client object
This commit is contained in:
@@ -86,6 +86,27 @@ describe("MatrixClientPeg", () => {
|
||||
expect(mockInitRustCrypto).toHaveBeenCalledWith({ storageKey: cryptoStoreKey });
|
||||
});
|
||||
|
||||
it("should try to start dehydration if dehydration is enabled", async () => {
|
||||
const mockInitRustCrypto = jest.spyOn(testPeg.safeGet(), "initRustCrypto").mockResolvedValue(undefined);
|
||||
const mockStartDehydration = jest.fn();
|
||||
jest.spyOn(testPeg.safeGet(), "getCrypto").mockReturnValue({
|
||||
isDehydrationSupported: jest.fn().mockResolvedValue(true),
|
||||
startDehydration: mockStartDehydration,
|
||||
setDeviceIsolationMode: jest.fn(),
|
||||
} as any);
|
||||
jest.spyOn(testPeg.safeGet(), "waitForClientWellKnown").mockResolvedValue({
|
||||
"m.homeserver": {
|
||||
base_url: "http://example.com",
|
||||
},
|
||||
"org.matrix.msc3814": true,
|
||||
} as any);
|
||||
|
||||
const cryptoStoreKey = new Uint8Array([1, 2, 3, 4]);
|
||||
await testPeg.start({ rustCryptoStoreKey: cryptoStoreKey });
|
||||
expect(mockInitRustCrypto).toHaveBeenCalledWith({ storageKey: cryptoStoreKey });
|
||||
expect(mockStartDehydration).toHaveBeenCalledWith({ onlyIfKeyCached: true, rehydrate: false });
|
||||
});
|
||||
|
||||
it("Should migrate existing login", async () => {
|
||||
const mockInitRustCrypto = jest.spyOn(testPeg.safeGet(), "initRustCrypto").mockResolvedValue(undefined);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user