Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 1d67af5

Browse files
committed
fixup! Remove support for legacy crypto stack in StorageManager
1 parent c60c6e5 commit 1d67af5

File tree

1 file changed

+27
-72
lines changed

1 file changed

+27
-72
lines changed

test/utils/StorageManager-test.ts

Lines changed: 27 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import { IDBFactory } from "fake-indexeddb";
2020
import { IndexedDBCryptoStore } from "matrix-js-sdk/src/matrix";
2121

2222
import * as StorageManager from "../../src/utils/StorageManager";
23-
import SettingsStore from "../../src/settings/SettingsStore";
2423

2524
const LEGACY_CRYPTO_STORE_NAME = "matrix-js-sdk:crypto";
2625
const RUST_CRYPTO_STORE_NAME = "matrix-js-sdk::matrix-sdk-crypto";
@@ -77,98 +76,54 @@ describe("StorageManager", () => {
7776
indexedDB = new IDBFactory();
7877
});
7978

80-
describe("with `feature_rust_crypto` enabled", () => {
81-
beforeEach(() => {
82-
jest.spyOn(SettingsStore, "getValue").mockImplementation(async (key) => {
83-
if (key === "feature_rust_crypto") {
84-
return true;
85-
}
86-
throw new Error(`Unknown key ${key}`);
87-
});
88-
});
79+
it("should not be ok if sync store but no crypto store", async () => {
80+
const result = await StorageManager.checkConsistency();
81+
expect(result.healthy).toBe(true);
82+
expect(result.dataInCryptoStore).toBe(false);
83+
});
8984

90-
it("should not be ok if sync store but no crypto store", async () => {
91-
const result = await StorageManager.checkConsistency();
92-
expect(result.healthy).toBe(true);
93-
expect(result.dataInCryptoStore).toBe(false);
94-
});
85+
it("should be ok if sync store and a rust crypto store", async () => {
86+
await createDB(RUST_CRYPTO_STORE_NAME);
9587

96-
it("should be ok if sync store and a rust crypto store", async () => {
97-
await createDB(RUST_CRYPTO_STORE_NAME);
88+
const result = await StorageManager.checkConsistency();
89+
expect(result.healthy).toBe(true);
90+
expect(result.dataInCryptoStore).toBe(true);
91+
});
92+
93+
describe("without rust store", () => {
94+
it("should be ok if there is non migrated legacy crypto store", async () => {
95+
await populateLegacyStore(undefined);
9896

9997
const result = await StorageManager.checkConsistency();
10098
expect(result.healthy).toBe(true);
10199
expect(result.dataInCryptoStore).toBe(true);
102100
});
103101

104-
describe("without rust store", () => {
105-
it("should be ok if there is non migrated legacy crypto store", async () => {
106-
await populateLegacyStore(undefined);
107-
108-
const result = await StorageManager.checkConsistency();
109-
expect(result.healthy).toBe(true);
110-
expect(result.dataInCryptoStore).toBe(true);
111-
});
112-
113-
it("should be ok if legacy store in MigrationState `NOT_STARTED`", async () => {
114-
await populateLegacyStore(0 /* MigrationState.NOT_STARTED*/);
115-
116-
const result = await StorageManager.checkConsistency();
117-
expect(result.healthy).toBe(true);
118-
expect(result.dataInCryptoStore).toBe(true);
119-
});
120-
121-
it("should not be ok if MigrationState greater than `NOT_STARTED`", async () => {
122-
await populateLegacyStore(1 /*INITIAL_DATA_MIGRATED*/);
123-
124-
const result = await StorageManager.checkConsistency();
125-
expect(result.healthy).toBe(true);
126-
expect(result.dataInCryptoStore).toBe(false);
127-
});
102+
it("should be ok if legacy store in MigrationState `NOT_STARTED`", async () => {
103+
await populateLegacyStore(0 /* MigrationState.NOT_STARTED*/);
128104

129-
it("should not be healthy if no indexeddb", async () => {
130-
// eslint-disable-next-line no-global-assign
131-
indexedDB = {} as IDBFactory;
132-
133-
const result = await StorageManager.checkConsistency();
134-
expect(result.healthy).toBe(false);
135-
136-
// eslint-disable-next-line no-global-assign
137-
indexedDB = new IDBFactory();
138-
});
139-
});
140-
});
141-
142-
describe("with `feature_rust_crypto` disabled", () => {
143-
beforeEach(() => {
144-
jest.spyOn(SettingsStore, "getValue").mockImplementation(async (key) => {
145-
if (key === "feature_rust_crypto") {
146-
return false;
147-
}
148-
throw new Error(`Unknown key ${key}`);
149-
});
150-
});
151-
152-
it("should not be ok if sync store but no crypto store", async () => {
153105
const result = await StorageManager.checkConsistency();
154106
expect(result.healthy).toBe(true);
155-
expect(result.dataInCryptoStore).toBe(false);
107+
expect(result.dataInCryptoStore).toBe(true);
156108
});
157109

158-
it("should not be ok if sync store but no crypto store and a rust store", async () => {
159-
await createDB(RUST_CRYPTO_STORE_NAME);
110+
it("should not be ok if MigrationState greater than `NOT_STARTED`", async () => {
111+
await populateLegacyStore(1 /*INITIAL_DATA_MIGRATED*/);
160112

161113
const result = await StorageManager.checkConsistency();
162114
expect(result.healthy).toBe(true);
163115
expect(result.dataInCryptoStore).toBe(false);
164116
});
165117

166-
it("should be healthy if sync store and a legacy crypto store", async () => {
167-
await createDB(LEGACY_CRYPTO_STORE_NAME);
118+
it("should not be healthy if no indexeddb", async () => {
119+
// eslint-disable-next-line no-global-assign
120+
indexedDB = {} as IDBFactory;
168121

169122
const result = await StorageManager.checkConsistency();
170-
expect(result.healthy).toBe(true);
171-
expect(result.dataInCryptoStore).toBe(true);
123+
expect(result.healthy).toBe(false);
124+
125+
// eslint-disable-next-line no-global-assign
126+
indexedDB = new IDBFactory();
172127
});
173128
});
174129
});

0 commit comments

Comments
 (0)