@@ -16,8 +16,12 @@ limitations under the License.
16
16
17
17
import "fake-indexeddb/auto" ;
18
18
import { IDBFactory } from "fake-indexeddb" ;
19
+ import fetchMock from "fetch-mock-jest" ;
19
20
20
- import { createClient } from "../../../src" ;
21
+ import { createClient , IndexedDBCryptoStore } from "../../../src" ;
22
+ import { populateStore } from "../../test-utils/test_indexeddb_cryptostore_dump" ;
23
+
24
+ jest . setTimeout ( 15000 ) ;
21
25
22
26
afterEach ( ( ) => {
23
27
// reset fake-indexeddb after each test, to make sure we don't leak connections
@@ -88,6 +92,47 @@ describe("MatrixClient.initRustCrypto", () => {
88
92
await matrixClient . initRustCrypto ( ) ;
89
93
await matrixClient . initRustCrypto ( ) ;
90
94
} ) ;
95
+
96
+ it ( "should migrate from libolm" , async ( ) => {
97
+ fetchMock . get ( "path:/_matrix/client/v3/room_keys/version" , {
98
+ auth_data : {
99
+ public_key : "q+HZiJdHl2Yopv9GGvv7EYSzDMrAiRknK4glSdoaomI" ,
100
+ signatures : {
101
+ "@vdhtest200713:matrix.org" : {
102
+ "ed25519:gh9fGr39eNZUdWynEMJ/q/WZq/Pk/foFxHXFBFm18ZI" :
103
+ "reDp6Mu+j+tfUL3/T6f5OBT3N825Lzpc43vvG+RvjX6V+KxXzodBQArgCoeEHLtL9OgSBmNrhTkSOX87MWCKAw" ,
104
+ "ed25519:KMFSTJSMLB" :
105
+ "F8tyV5W6wNi0GXTdSg+gxSCULQi0EYxdAAqfkyNq58KzssZMw5i+PRA0aI2b+D7NH/aZaJrtiYNHJ0gWLSQvAw" ,
106
+ } ,
107
+ } ,
108
+ } ,
109
+ version : "7" ,
110
+ algorithm : "m.megolm_backup.v1.curve25519-aes-sha2" ,
111
+ etag : "1" ,
112
+ count : 79 ,
113
+ } ) ;
114
+
115
+ const testStoreName = "test-store" ;
116
+ await populateStore ( testStoreName ) ;
117
+ const cryptoStore = new IndexedDBCryptoStore ( indexedDB , testStoreName ) ;
118
+
119
+ const matrixClient = createClient ( {
120
+ baseUrl : "http://test.server" ,
121
+ userId : "@vdhtest200713:matrix.org" ,
122
+ deviceId : "KMFSTJSMLB" ,
123
+ cryptoStore,
124
+ pickleKey : "+1k2Ppd7HIisUY824v7JtV3/oEE4yX0TqtmNPyhaD7o" ,
125
+ } ) ;
126
+
127
+ await matrixClient . initRustCrypto ( ) ;
128
+
129
+ // Do some basic checks on the imported data
130
+ const deviceKeys = await matrixClient . getCrypto ( ) ! . getOwnDeviceKeys ( ) ;
131
+ expect ( deviceKeys . curve25519 ) . toEqual ( "LKv0bKbc0EC4h0jknbemv3QalEkeYvuNeUXVRgVVTTU" ) ;
132
+ expect ( deviceKeys . ed25519 ) . toEqual ( "qK70DEqIXq7T+UU3v/al47Ab4JkMEBLpNrTBMbS5rrw" ) ;
133
+
134
+ expect ( await matrixClient . getCrypto ( ) ! . getActiveSessionBackupVersion ( ) ) . toEqual ( "7" ) ;
135
+ } ) ;
91
136
} ) ;
92
137
93
138
describe ( "MatrixClient.clearStores" , ( ) => {
0 commit comments