You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2026-01-03 23:22:30 +03:00
stop checking structure of exported data
it should suffice that the exported data allows to recreate a device that can do crypto
This commit is contained in:
@@ -84,15 +84,8 @@ describe("OlmDevice", function() {
|
||||
it('exports picked account and olm sessions', async function() {
|
||||
const sessionId = await setupSession(aliceOlmDevice, bobOlmDevice);
|
||||
|
||||
// At the time of writing, Jest only tests with in-memory DB,
|
||||
// but I manually checked that the exported data has the same structure
|
||||
// when coming from indexed DB
|
||||
const exported = await bobOlmDevice.export();
|
||||
expect(exported).toHaveProperty('pickleKey');
|
||||
expect(exported).toHaveProperty('pickledAccount');
|
||||
expect(exported).toHaveProperty('sessions');
|
||||
// At this moment only Alice (the “initiator” in setupSession)
|
||||
// has a session
|
||||
// At this moment only Alice (the “initiator” in setupSession) has a session
|
||||
expect(exported.sessions).toEqual([]);
|
||||
|
||||
const MESSAGE = "The olm or proteus is an aquatic salamander in the family Proteidae";
|
||||
@@ -113,19 +106,8 @@ describe("OlmDevice", function() {
|
||||
expect(decrypted.payload).toEqual(MESSAGE);
|
||||
|
||||
const exportedAgain = await bobRecreatedOlmDevice.export();
|
||||
expect(exportedAgain).toHaveProperty('pickleKey');
|
||||
expect(exportedAgain).toHaveProperty('pickledAccount');
|
||||
expect(exportedAgain).toHaveProperty('sessions');
|
||||
expect(Array.isArray(exportedAgain.sessions)).toBe(true);
|
||||
// this time we expect Bob to have a session to export
|
||||
expect(exportedAgain.sessions[0]).toEqual(
|
||||
expect.objectContaining({
|
||||
session: expect.any(String),
|
||||
lastReceivedMessageTs: expect.any(Number),
|
||||
deviceKey: expect.any(String),
|
||||
sessionId: expect.any(String),
|
||||
})
|
||||
);
|
||||
expect(exportedAgain.sessions).toHaveLength(1);
|
||||
|
||||
const MESSAGE_2 = "In contrast to most amphibians, the olm is entirely aquatic";
|
||||
const ciphertext_2 = await aliceOlmDevice.encryptMessage(
|
||||
@@ -137,7 +119,7 @@ describe("OlmDevice", function() {
|
||||
const bobRecreatedAgainOlmDevice = makeOlmDevice();
|
||||
bobRecreatedAgainOlmDevice.init(exportedAgain);
|
||||
|
||||
// Note: decrypted_2 does not have the same structure than decrypted
|
||||
// Note: "decrypted_2" does not have the same structure as "decrypted"
|
||||
const decrypted_2 = await bobRecreatedAgainOlmDevice.decryptMessage(
|
||||
aliceOlmDevice.deviceCurve25519Key,
|
||||
decrypted.session_id,
|
||||
@@ -145,7 +127,6 @@ describe("OlmDevice", function() {
|
||||
ciphertext_2.body,
|
||||
);
|
||||
expect(decrypted_2).toEqual(MESSAGE_2);
|
||||
|
||||
});
|
||||
|
||||
it("creates only one session at a time", async function() {
|
||||
|
||||
Reference in New Issue
Block a user