You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-12-01 04:43:29 +03:00
Merge pull request #1242 from matrix-org/foldleft/fix-bad-merge
Fixed up tests to match new way that crypto stores are created
This commit is contained in:
@@ -216,7 +216,7 @@ describe.each([
|
|||||||
() => new IndexedDBCryptoStore(undefined, "tests")],
|
() => new IndexedDBCryptoStore(undefined, "tests")],
|
||||||
["MemoryCryptoStore", () => {
|
["MemoryCryptoStore", () => {
|
||||||
const store = new IndexedDBCryptoStore(undefined, "tests");
|
const store = new IndexedDBCryptoStore(undefined, "tests");
|
||||||
store._backendPromise = Promise.resolve(new MemoryCryptoStore());
|
store._backend = new MemoryCryptoStore();
|
||||||
return store;
|
return store;
|
||||||
}],
|
}],
|
||||||
])("CrossSigning > createCryptoStoreCacheCallbacks [%s]", function(name, dbFactory) {
|
])("CrossSigning > createCryptoStoreCacheCallbacks [%s]", function(name, dbFactory) {
|
||||||
@@ -230,17 +230,18 @@ describe.each([
|
|||||||
await store.deleteAllData();
|
await store.deleteAllData();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should cache data to the store and retrieves it", async () => {
|
it("should cache data to the store and retrieve it", async () => {
|
||||||
|
await store.startup();
|
||||||
const { getCrossSigningKeyCache, storeCrossSigningKeyCache } =
|
const { getCrossSigningKeyCache, storeCrossSigningKeyCache } =
|
||||||
createCryptoStoreCacheCallbacks(store);
|
createCryptoStoreCacheCallbacks(store);
|
||||||
await storeCrossSigningKeyCache("master", testKey);
|
await storeCrossSigningKeyCache("self_signing", testKey);
|
||||||
|
|
||||||
// If we've not saved anything, don't expect anything
|
// If we've not saved anything, don't expect anything
|
||||||
// Definitely don't accidentally return the wrong key for the type
|
// Definitely don't accidentally return the wrong key for the type
|
||||||
const nokey = await getCrossSigningKeyCache("self", "");
|
const nokey = await getCrossSigningKeyCache("self", "");
|
||||||
expect(nokey).toBeNull();
|
expect(nokey).toBeNull();
|
||||||
|
|
||||||
const key = await getCrossSigningKeyCache("master", "");
|
const key = await getCrossSigningKeyCache("self_signing", "");
|
||||||
expect(key).toEqual(testKey);
|
expect(key).toEqual(testKey);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -313,9 +313,8 @@ export class IndexedDBCryptoStore {
|
|||||||
* @param {function(string)} func Called with the private key
|
* @param {function(string)} func Called with the private key
|
||||||
* @param {string} type A key type
|
* @param {string} type A key type
|
||||||
*/
|
*/
|
||||||
async getCrossSigningPrivateKey(txn, func, type) {
|
getCrossSigningPrivateKey(txn, func, type) {
|
||||||
const backend = await this._connect();
|
this._backend.getCrossSigningPrivateKey(txn, func, type);
|
||||||
return backend.getCrossSigningPrivateKey(txn, func, type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -336,9 +335,7 @@ export class IndexedDBCryptoStore {
|
|||||||
* @param {string} key keys object as getCrossSigningKeys()
|
* @param {string} key keys object as getCrossSigningKeys()
|
||||||
*/
|
*/
|
||||||
storeCrossSigningPrivateKey(txn, type, key) {
|
storeCrossSigningPrivateKey(txn, type, key) {
|
||||||
this._backendPromise.then(backend => {
|
this._backend.storeCrossSigningPrivateKey(txn, type, key);
|
||||||
backend.storeCrossSigningPrivateKey(txn, type, key);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Olm sessions
|
// Olm sessions
|
||||||
|
|||||||
Reference in New Issue
Block a user