@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
14
14
limitations under the License.
15
15
*/
16
16
17
+ import debug from "debug" ;
17
18
import * as RustSdkCryptoJs from "@matrix-org/matrix-sdk-crypto-wasm" ;
18
19
import {
19
20
BaseMigrationData ,
@@ -31,6 +32,7 @@ import { RustCrypto } from "../../../src/rust-crypto/rust-crypto";
31
32
import { initRustCrypto } from "../../../src/rust-crypto" ;
32
33
import {
33
34
type AccountDataEvents ,
35
+ DebugLogger ,
34
36
type Device ,
35
37
DeviceVerification ,
36
38
type EmptyObject ,
@@ -68,7 +70,6 @@ import {
68
70
import * as testData from "../../test-utils/test-data" ;
69
71
import { E2EKeyReceiver } from "../../test-utils/E2EKeyReceiver" ;
70
72
import { E2EKeyResponder } from "../../test-utils/E2EKeyResponder" ;
71
- import { logger } from "../../../src/logger" ;
72
73
import { OutgoingRequestsManager } from "../../../src/rust-crypto/OutgoingRequestsManager" ;
73
74
import { ClientEvent , type ClientEventHandlerMap } from "../../../src/client" ;
74
75
import { type Curve25519AuthData } from "../../../src/crypto-api/keybackup" ;
@@ -117,6 +118,7 @@ describe("initRustCrypto", () => {
117
118
const testOlmMachine = makeTestOlmMachine ( ) ;
118
119
jest . spyOn ( OlmMachine , "initFromStore" ) . mockResolvedValue ( testOlmMachine ) ;
119
120
121
+ const logger = new DebugLogger ( debug ( "matrix-js-sdk:test:initRustCrypto" ) ) ;
120
122
await initRustCrypto ( {
121
123
logger,
122
124
http : { } as MatrixClient [ "http" ] ,
@@ -140,6 +142,7 @@ describe("initRustCrypto", () => {
140
142
jest . spyOn ( OlmMachine , "initFromStore" ) . mockResolvedValue ( testOlmMachine ) ;
141
143
142
144
const storeKey = new Uint8Array ( 32 ) ;
145
+ const logger = new DebugLogger ( debug ( "matrix-js-sdk:test:initRustCrypto" ) ) ;
143
146
await initRustCrypto ( {
144
147
logger,
145
148
http : { } as MatrixClient [ "http" ] ,
@@ -162,6 +165,7 @@ describe("initRustCrypto", () => {
162
165
const testOlmMachine = makeTestOlmMachine ( ) ;
163
166
jest . spyOn ( OlmMachine , "initFromStore" ) . mockResolvedValue ( testOlmMachine ) ;
164
167
168
+ const logger = new DebugLogger ( debug ( "matrix-js-sdk:test:initRustCrypto" ) ) ;
165
169
await initRustCrypto ( {
166
170
logger,
167
171
http : { } as MatrixClient [ "http" ] ,
@@ -186,7 +190,7 @@ describe("initRustCrypto", () => {
186
190
jest . spyOn ( OlmMachine , "initFromStore" ) . mockResolvedValue ( testOlmMachine ) ;
187
191
188
192
await initRustCrypto ( {
189
- logger,
193
+ logger : new DebugLogger ( debug ( "matrix-js-sdk:test:initRustCrypto" ) ) ,
190
194
http : { } as MatrixClient [ "http" ] ,
191
195
userId : TEST_USER ,
192
196
deviceId : TEST_DEVICE_ID ,
@@ -251,9 +255,10 @@ describe("initRustCrypto", () => {
251
255
jest . spyOn ( RustSdkCryptoJs . BackupDecryptionKey , "fromBase64" ) . mockReturnValue ( mockBackupDecryptionKey ) ;
252
256
253
257
function legacyMigrationProgressListener ( progress : number , total : number ) : void {
254
- logger . log ( `migrated ${ progress } of ${ total } ` ) ;
258
+ // console .log(`migrated ${progress} of ${total}`);
255
259
}
256
260
261
+ const logger = new DebugLogger ( debug ( "matrix-js-sdk:test:initRustCrypto" ) ) ;
257
262
await initRustCrypto ( {
258
263
logger,
259
264
http : makeMatrixHttpApi ( ) ,
@@ -358,11 +363,11 @@ describe("initRustCrypto", () => {
358
363
fetchMock . get ( "path:/_matrix/client/v3/room_keys/version" , 404 ) ;
359
364
360
365
function legacyMigrationProgressListener ( progress : number , total : number ) : void {
361
- logger . log ( `migrated ${ progress } of ${ total } ` ) ;
366
+ // console .log(`migrated ${progress} of ${total}`);
362
367
}
363
368
364
369
await initRustCrypto ( {
365
- logger,
370
+ logger : new DebugLogger ( debug ( "matrix-js-sdk:test:initRustCrypto" ) ) ,
366
371
http : makeMatrixHttpApi ( ) ,
367
372
userId : TEST_USER ,
368
373
deviceId : TEST_DEVICE_ID ,
@@ -400,6 +405,7 @@ describe("initRustCrypto", () => {
400
405
) ;
401
406
402
407
const PICKLE_KEY = "pickle1234" ;
408
+ const logger = new DebugLogger ( debug ( "matrix-js-sdk:test:initRustCrypto" ) ) ;
403
409
await initRustCrypto ( {
404
410
logger,
405
411
http : makeMatrixHttpApi ( ) ,
@@ -813,7 +819,7 @@ describe("RustCrypto", () => {
813
819
} as unknown as OlmMachine ;
814
820
815
821
const rustCrypto = new RustCrypto (
816
- logger ,
822
+ new DebugLogger ( debug ( "matrix-js-sdk:test:RustCrypto" ) ) ,
817
823
mockOlmMachine ,
818
824
fetchMock as unknown as MatrixHttpApi < any > ,
819
825
TEST_USER ,
@@ -898,6 +904,7 @@ describe("RustCrypto", () => {
898
904
makeOutgoingRequest : jest . fn ( ) ,
899
905
} as unknown as Mocked < OutgoingRequestProcessor > ;
900
906
907
+ const logger = new DebugLogger ( debug ( "matrix-js-sdk:test:RustCrypto" ) ) ;
901
908
const outgoingRequestsManager = new OutgoingRequestsManager ( logger , olmMachine , outgoingRequestProcessor ) ;
902
909
903
910
rustCrypto = new RustCrypto (
@@ -957,7 +964,11 @@ describe("RustCrypto", () => {
957
964
958
965
const outgoingRequestProcessor = { } as unknown as OutgoingRequestProcessor ;
959
966
rustCrypto [ "outgoingRequestProcessor" ] = outgoingRequestProcessor ;
960
- const outgoingRequestsManager = new OutgoingRequestsManager ( logger , olmMachine , outgoingRequestProcessor ) ;
967
+ const outgoingRequestsManager = new OutgoingRequestsManager (
968
+ new DebugLogger ( debug ( "matrix-js-sdk:test:RustCrypto" ) ) ,
969
+ olmMachine ,
970
+ outgoingRequestProcessor ,
971
+ ) ;
961
972
rustCrypto [ "outgoingRequestsManager" ] = outgoingRequestsManager ;
962
973
963
974
// The second time we do a /keys/upload, the `device_keys` property
@@ -1015,7 +1026,7 @@ describe("RustCrypto", () => {
1015
1026
getRoomEventEncryptionInfo : jest . fn ( ) ,
1016
1027
} as unknown as Mocked < RustSdkCryptoJs . OlmMachine > ;
1017
1028
rustCrypto = new RustCrypto (
1018
- logger ,
1029
+ new DebugLogger ( debug ( "matrix-js-sdk:test:RustCrypto" ) ) ,
1019
1030
olmMachine ,
1020
1031
{ } as MatrixClient [ "http" ] ,
1021
1032
TEST_USER ,
@@ -1228,7 +1239,7 @@ describe("RustCrypto", () => {
1228
1239
getDevice : jest . fn ( ) ,
1229
1240
} as unknown as Mocked < RustSdkCryptoJs . OlmMachine > ;
1230
1241
rustCrypto = new RustCrypto (
1231
- logger ,
1242
+ new DebugLogger ( debug ( "matrix-js-sdk:test:RustCrypto" ) ) ,
1232
1243
olmMachine ,
1233
1244
{ } as MatrixClient [ "http" ] ,
1234
1245
TEST_USER ,
@@ -1471,7 +1482,7 @@ describe("RustCrypto", () => {
1471
1482
getIdentity : jest . fn ( ) ,
1472
1483
} as unknown as Mocked < RustSdkCryptoJs . OlmMachine > ;
1473
1484
rustCrypto = new RustCrypto (
1474
- logger ,
1485
+ new DebugLogger ( debug ( "matrix-js-sdk:test:RustCrypto" ) ) ,
1475
1486
olmMachine ,
1476
1487
{ } as MatrixClient [ "http" ] ,
1477
1488
TEST_USER ,
@@ -1558,7 +1569,7 @@ describe("RustCrypto", () => {
1558
1569
getIdentity : jest . fn ( ) ,
1559
1570
} as unknown as Mocked < RustSdkCryptoJs . OlmMachine > ;
1560
1571
const rustCrypto = new RustCrypto (
1561
- logger ,
1572
+ new DebugLogger ( debug ( "matrix-js-sdk:test:RustCrypto" ) ) ,
1562
1573
olmMachine ,
1563
1574
{ } as MatrixClient [ "http" ] ,
1564
1575
TEST_USER ,
@@ -1630,7 +1641,7 @@ describe("RustCrypto", () => {
1630
1641
} as unknown as Mocked < RustSdkCryptoJs . OlmMachine > ;
1631
1642
1632
1643
const rustCrypto = new RustCrypto (
1633
- logger ,
1644
+ new DebugLogger ( debug ( "matrix-js-sdk:test:RustCrypto" ) ) ,
1634
1645
olmMachine ,
1635
1646
makeMatrixHttpApi ( ) ,
1636
1647
testData . TEST_USER_ID ,
@@ -2371,7 +2382,7 @@ async function makeTestRustCrypto(
2371
2382
cryptoCallbacks : CryptoCallbacks = { } as CryptoCallbacks ,
2372
2383
) : Promise < RustCrypto > {
2373
2384
return await initRustCrypto ( {
2374
- logger,
2385
+ logger : new DebugLogger ( debug ( "matrix-js-sdk:test:rust-crypto.spec" ) ) ,
2375
2386
http,
2376
2387
userId,
2377
2388
deviceId,
0 commit comments