diff --git a/package.json b/package.json index 0c39c8f403..25ae9392b3 100644 --- a/package.json +++ b/package.json @@ -240,7 +240,7 @@ "@indutny/parallel-prettier": "3.0.0", "@indutny/rezip-electron": "3.0.2", "@napi-rs/canvas": "0.1.61", - "@signalapp/mock-server": "17.0.1", + "@signalapp/mock-server": "18.0.0", "@storybook/addon-a11y": "8.4.4", "@storybook/addon-actions": "8.4.4", "@storybook/addon-controls": "8.4.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index dbf182f14a..4f45a9fa22 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -442,8 +442,8 @@ importers: specifier: 0.1.61 version: 0.1.61 '@signalapp/mock-server': - specifier: 17.0.1 - version: 17.0.1(bufferutil@4.0.9)(utf-8-validate@5.0.10) + specifier: 18.0.0 + version: 18.0.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) '@storybook/addon-a11y': specifier: 8.4.4 version: 8.4.4(storybook@8.4.4(bufferutil@4.0.9)(prettier@3.7.4)(utf-8-validate@5.0.10)) @@ -1711,8 +1711,8 @@ packages: peerDependencies: prettier: ^3.0.0 - '@indutny/protopiler@1.0.0-rc.24': - resolution: {integrity: sha512-qLKwdz+CXDg20I9wL+g7p6Zjo2EHvXFJFzft1useHeB9NYo4PSyBOmid1Ug5Lhc0klDycDv7vldEbx4sEV1Wzw==} + '@indutny/protopiler@2.0.2': + resolution: {integrity: sha512-AFUhU0wUcSdF1wlmK/vBlutKxFvQAwSkybB5/sQGpms17T8SfPgSrKTsPkMIX72s155V9RaygXOTgWBK2rR6pQ==} hasBin: true '@indutny/range-finder@1.3.4': @@ -3499,8 +3499,8 @@ packages: '@signalapp/minimask@1.0.1': resolution: {integrity: sha512-QAwo0joA60urTNbW9RIz6vLKQjy+jdVtH7cvY0wD9PVooD46MAjE40MLssp4xUJrph91n2XvtJ3pbEUDrmT2AA==} - '@signalapp/mock-server@17.0.1': - resolution: {integrity: sha512-uiPYsF0dD38ZCdkAKRMzNjaeT34JXeE5tq/nxAMnlcnlxpS5XXL0BbMhr0+S2dM2bXz0GmHpIHPyBLwTbXGlVw==} + '@signalapp/mock-server@18.0.0': + resolution: {integrity: sha512-YNmFyzBCW/nBjPBX6va5TPWnbg3A7euUHHUTk9wmDoAJ4A1gv+whDZGCfVmqI7l4Mhn9l4p5JSGkGUCpgUT/Pg==} '@signalapp/parchment-cjs@3.0.1': resolution: {integrity: sha512-hSBMQ1M7wE4GcC8ZeNtvpJF+DAJg3eIRRf1SiHS3I3Algav/sgJJNm6HIYm6muHuK7IJmuEjkL3ILSXgmu0RfQ==} @@ -10114,17 +10114,17 @@ packages: tar@6.2.1: resolution: {integrity: sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==} engines: {node: '>=10'} - deprecated: Old versions of tar are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me + deprecated: Old versions of tar are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exhorbitant rates) by contacting i@izs.me tar@7.4.3: resolution: {integrity: sha512-5S7Va8hKfV7W5U6g3aYxXmlPoZVAwUMy9AOKyF2fVuZa2UD3qZjg578OrLRt8PcNN1PleVaL/5/yYATNL0ICUw==} engines: {node: '>=18'} - deprecated: Old versions of tar are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me + deprecated: Old versions of tar are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exhorbitant rates) by contacting i@izs.me tar@7.5.2: resolution: {integrity: sha512-7NyxrTE4Anh8km8iEy7o0QYPs+0JKBTj5ZaqHg6B39erLg0qYXN3BijtShwbsNSvQ+LN75+KV+C4QR/f6Gwnpg==} engines: {node: '>=18'} - deprecated: Old versions of tar are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me + deprecated: Old versions of tar are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exhorbitant rates) by contacting i@izs.me telejson@7.2.0: resolution: {integrity: sha512-1QTEcJkJEhc8OnStBx/ILRu5J2p0GjvWsBx56bmZRqnrkdBMUe+nX92jxV+p3dB4CP6PZCdJMQJwCggkNBMzkQ==} @@ -11860,7 +11860,7 @@ snapshots: prettier: 3.7.4 rxjs: 6.6.7 - '@indutny/protopiler@1.0.0-rc.24': {} + '@indutny/protopiler@2.0.2': {} '@indutny/range-finder@1.3.4': dependencies: @@ -14287,10 +14287,10 @@ snapshots: '@signalapp/minimask@1.0.1': {} - '@signalapp/mock-server@17.0.1(bufferutil@4.0.9)(utf-8-validate@5.0.10)': + '@signalapp/mock-server@18.0.0(bufferutil@4.0.9)(utf-8-validate@5.0.10)': dependencies: '@indutny/parallel-prettier': 3.0.0(prettier@3.7.4) - '@indutny/protopiler': 1.0.0-rc.24 + '@indutny/protopiler': 2.0.2 '@signalapp/libsignal-client': 0.76.7 '@tus/file-store': 1.5.1 '@tus/server': 1.10.2 diff --git a/ts/test-mock/benchmarks/call_history_search_bench.node.ts b/ts/test-mock/benchmarks/call_history_search_bench.node.ts index a108a68402..0f9b091458 100644 --- a/ts/test-mock/benchmarks/call_history_search_bench.node.ts +++ b/ts/test-mock/benchmarks/call_history_search_bench.node.ts @@ -94,20 +94,23 @@ Bootstrap.benchmark(async (bootstrap: Bootstrap): Promise => { await phone.sendRaw( desktop, { - syncMessage: { - content: 'callEvent', - callEvent: { - conversationId: uuidToBytes(contact.device.aci), - callId: BigInt(timestamp), - timestamp: BigInt(timestamp), - type, - direction, - event, + content: { + syncMessage: { + content: { + callEvent: { + conversationId: uuidToBytes(contact.device.aci), + callId: BigInt(timestamp), + timestamp: BigInt(timestamp), + type, + direction, + event, + }, + }, + read: null, + stickerPackOperation: null, + viewed: null, + padding: null, }, - read: null, - stickerPackOperation: null, - viewed: null, - padding: null, }, pniSignatureMessage: null, senderKeyDistributionMessage: null, diff --git a/ts/test-mock/bootstrap.node.ts b/ts/test-mock/bootstrap.node.ts index 5af7952bb4..cb89c967a0 100644 --- a/ts/test-mock/bootstrap.node.ts +++ b/ts/test-mock/bootstrap.node.ts @@ -716,8 +716,9 @@ export class Bootstrap { return { size: data.byteLength, contentType, - attachmentIdentifier: 'cdnKey', - cdnKey, + attachmentIdentifier: { + cdnKey, + }, cdnNumber, key: keys, digest, diff --git a/ts/test-mock/helpers.node.ts b/ts/test-mock/helpers.node.ts index 4081933cce..4de778e355 100644 --- a/ts/test-mock/helpers.node.ts +++ b/ts/test-mock/helpers.node.ts @@ -151,36 +151,42 @@ function maybeWrapInSyncMessage({ }): Proto.Content.Params { return isSync ? { - syncMessage: { - sent: { - destinationServiceIdBinary: getDevice(to).aciBinary, - message: dataMessage, - timestamp: dataMessage.timestamp, - unidentifiedStatus: (sentTo ?? [to]).map(contact => ({ - destinationServiceIdBinary: getDevice(contact).aciBinary, - destination: getDevice(contact).number, - unidentified: null, - destinationPniIdentityKey: null, - destinationServiceId: null, - })), - destinationE164: null, - expirationStartTimestamp: null, - isRecipientUpdate: null, - storyMessage: null, - storyMessageRecipients: null, - editMessage: null, - destinationServiceId: null, + content: { + syncMessage: { + content: { + sent: { + destinationServiceIdBinary: getDevice(to).aciBinary, + message: dataMessage, + timestamp: dataMessage.timestamp, + unidentifiedStatus: (sentTo ?? [to]).map(contact => ({ + destinationServiceIdBinary: getDevice(contact).aciBinary, + destination: getDevice(contact).number, + unidentified: null, + destinationPniIdentityKey: null, + destinationServiceId: null, + })), + destinationE164: null, + expirationStartTimestamp: null, + isRecipientUpdate: null, + storyMessage: null, + storyMessageRecipients: null, + editMessage: null, + destinationServiceId: null, + }, + }, + read: null, + stickerPackOperation: null, + viewed: null, + padding: null, }, - read: null, - stickerPackOperation: null, - viewed: null, - padding: null, }, pniSignatureMessage: null, senderKeyDistributionMessage: null, } : { - dataMessage, + content: { + dataMessage, + }, pniSignatureMessage: null, senderKeyDistributionMessage: null, }; diff --git a/ts/test-mock/messaging/attachments_test.node.ts b/ts/test-mock/messaging/attachments_test.node.ts index 1fb05cc1b8..193bbee22d 100644 --- a/ts/test-mock/messaging/attachments_test.node.ts +++ b/ts/test-mock/messaging/attachments_test.node.ts @@ -470,7 +470,10 @@ describe('attachments', function (this: Mocha.Suite) { ]); const sentVideo = sentVideoAttachments[0]; - assert.deepStrictEqual(sentVideo.cdnKey, recentPointer.cdnKey); + assert.deepStrictEqual( + sentVideo.attachmentIdentifier, + recentPointer.attachmentIdentifier + ); assert.deepStrictEqual(sentVideo.cdnNumber, recentPointer.cdnNumber); assert.deepStrictEqual(sentVideo.key, recentPointer.key); assert.deepStrictEqual(sentVideo.digest, recentPointer.digest); @@ -483,7 +486,10 @@ describe('attachments', function (this: Mocha.Suite) { assert.notDeepEqual(sentVideo.fileName, recentPointer.fileName); const sentCat = sentCatAttachments[0]; - assert.notDeepEqual(sentCat.cdnKey, stalePointer.cdnKey); + assert.notDeepEqual( + sentCat.attachmentIdentifier, + stalePointer.attachmentIdentifier + ); assert.notDeepEqual(sentCat.key, stalePointer.key); assert.notDeepEqual(sentCat.digest, stalePointer.digest); }); diff --git a/ts/test-mock/messaging/backfill_test.node.ts b/ts/test-mock/messaging/backfill_test.node.ts index de39b93ffc..431e11f36f 100644 --- a/ts/test-mock/messaging/backfill_test.node.ts +++ b/ts/test-mock/messaging/backfill_test.node.ts @@ -32,13 +32,16 @@ function createResponse( response: Proto.SyncMessage.AttachmentBackfillResponse.Params ): Proto.Content.Params { return { - syncMessage: { - content: 'attachmentBackfillResponse', - attachmentBackfillResponse: response, - read: null, - stickerPackOperation: null, - viewed: null, - padding: null, + content: { + syncMessage: { + content: { + attachmentBackfillResponse: response, + }, + read: null, + stickerPackOperation: null, + viewed: null, + padding: null, + }, }, pniSignatureMessage: null, senderKeyDistributionMessage: null, @@ -106,21 +109,21 @@ describe('attachment backfill', function (this: Mocha.Suite) { attachments: [ { ...textAttachment, - attachmentIdentifier: 'cdnKey', - cdnKey: 'text-not-found', - cdnId: null, + attachmentIdentifier: { + cdnKey: 'text-not-found', + }, }, { ...catAttachment, - attachmentIdentifier: 'cdnKey', - cdnKey: 'cat-not-found', - cdnId: null, + attachmentIdentifier: { + cdnKey: 'cat-not-found', + }, }, { ...snowAttachment, - attachmentIdentifier: 'cdnKey', - cdnKey: 'snow-not-found', - cdnId: null, + attachmentIdentifier: { + cdnKey: 'snow-not-found', + }, }, ], timestamp, @@ -143,18 +146,18 @@ describe('attachment backfill', function (this: Mocha.Suite) { debug('waiting for backfill request'); const { syncMessage } = await phone.waitForSyncMessage(entry => { - return entry.syncMessage.content === 'attachmentBackfillRequest'; + return entry.syncMessage.content?.attachmentBackfillRequest != null; }); - assert.strictEqual(syncMessage.content, 'attachmentBackfillRequest'); - const request = syncMessage.attachmentBackfillRequest; + assert.ok(syncMessage.content?.attachmentBackfillRequest != null); + const request = syncMessage.content.attachmentBackfillRequest; assert(request != null); assert.deepEqual( - request.targetConversation?.threadServiceIdBinary, + request.targetConversation?.identifier?.threadServiceIdBinary, unknownContact.device.aciBinary ); assert.deepEqual( - request.targetMessage?.authorServiceIdBinary, + request.targetMessage?.author?.authorServiceIdBinary, unknownContact.device.aciBinary ); assert.strictEqual( @@ -178,9 +181,14 @@ describe('attachment backfill', function (this: Mocha.Suite) { createResponse({ targetConversation: request.targetConversation, targetMessage: request.targetMessage, - attachments: { - longText: { status: Status.PENDING }, - attachments: [{ status: Status.PENDING }, { status: Status.PENDING }], + data: { + attachments: { + longText: { data: { status: Status.PENDING } }, + attachments: [ + { data: { status: Status.PENDING } }, + { data: { status: Status.PENDING } }, + ], + }, }, }), { @@ -194,9 +202,14 @@ describe('attachment backfill', function (this: Mocha.Suite) { createResponse({ targetConversation: request.targetConversation, targetMessage: request.targetMessage, - attachments: { - longText: { attachment: textAttachment }, - attachments: [{ status: Status.PENDING }, { status: Status.PENDING }], + data: { + attachments: { + longText: { data: { attachment: textAttachment } }, + attachments: [ + { data: { status: Status.PENDING } }, + { data: { status: Status.PENDING } }, + ], + }, }, }), { @@ -212,12 +225,14 @@ describe('attachment backfill', function (this: Mocha.Suite) { createResponse({ targetConversation: request.targetConversation, targetMessage: request.targetMessage, - attachments: { - longText: { attachment: textAttachment }, - attachments: [ - { attachment: catAttachment }, - { status: Status.PENDING }, - ], + data: { + attachments: { + longText: { data: { attachment: textAttachment } }, + attachments: [ + { data: { attachment: catAttachment } }, + { data: { status: Status.PENDING } }, + ], + }, }, }), { @@ -238,12 +253,14 @@ describe('attachment backfill', function (this: Mocha.Suite) { createResponse({ targetConversation: request.targetConversation, targetMessage: request.targetMessage, - attachments: { - longText: { attachment: textAttachment }, - attachments: [ - { attachment: catAttachment }, - { status: Status.TERMINAL_ERROR }, - ], + data: { + attachments: { + longText: { data: { attachment: textAttachment } }, + attachments: [ + { data: { attachment: catAttachment } }, + { data: { status: Status.TERMINAL_ERROR } }, + ], + }, }, }), { @@ -277,9 +294,9 @@ describe('attachment backfill', function (this: Mocha.Suite) { attachments: [ { ...catAttachment, - attachmentIdentifier: 'cdnKey', - cdnKey: 'cat-not-found', - cdnId: null, + attachmentIdentifier: { + cdnKey: 'cat-not-found', + }, }, ], timestamp, @@ -319,9 +336,9 @@ describe('attachment backfill', function (this: Mocha.Suite) { attachments: [ { ...catAttachment, - attachmentIdentifier: 'cdnKey', - cdnKey: 'cat-not-found', - cdnId: null, + attachmentIdentifier: { + cdnKey: 'cat-not-found', + }, }, ], timestamp, @@ -344,18 +361,18 @@ describe('attachment backfill', function (this: Mocha.Suite) { debug('waiting for request'); const { syncMessage } = await phone.waitForSyncMessage(entry => { - return entry.syncMessage.content === 'attachmentBackfillRequest'; + return entry.syncMessage.content?.attachmentBackfillRequest != null; }); - assert.strictEqual(syncMessage.content, 'attachmentBackfillRequest'); - const request = syncMessage.attachmentBackfillRequest; + assert.ok(syncMessage.content?.attachmentBackfillRequest != null); + const request = syncMessage.content.attachmentBackfillRequest; assert(request != null); assert.deepEqual( - request.targetConversation?.threadServiceIdBinary, + request.targetConversation?.identifier?.threadServiceIdBinary, unknownContact.device.aciBinary ); assert.deepEqual( - request.targetMessage?.authorServiceIdBinary, + request.targetMessage?.author?.authorServiceIdBinary, unknownContact.device.aciBinary ); assert.strictEqual( @@ -371,8 +388,11 @@ describe('attachment backfill', function (this: Mocha.Suite) { createResponse({ targetConversation: request.targetConversation, targetMessage: request.targetMessage, - error: - Proto.SyncMessage.AttachmentBackfillResponse.Error.MESSAGE_NOT_FOUND, + data: { + error: + Proto.SyncMessage.AttachmentBackfillResponse.Error + .MESSAGE_NOT_FOUND, + }, }), { timestamp: bootstrap.getTimestamp(), @@ -405,9 +425,9 @@ describe('attachment backfill', function (this: Mocha.Suite) { emoji: '🐈', data: { ...catAttachment, - attachmentIdentifier: 'cdnKey', - cdnKey: 'cat-not-found', - cdnId: null, + attachmentIdentifier: { + cdnKey: 'cat-not-found', + }, }, }, timestamp, @@ -430,18 +450,18 @@ describe('attachment backfill', function (this: Mocha.Suite) { debug('waiting for backfill request'); const { syncMessage } = await phone.waitForSyncMessage(entry => { - return entry.syncMessage.content === 'attachmentBackfillRequest'; + return entry.syncMessage.content?.attachmentBackfillRequest != null; }); - assert.strictEqual(syncMessage.content, 'attachmentBackfillRequest'); - const request = syncMessage.attachmentBackfillRequest; + assert.ok(syncMessage.content?.attachmentBackfillRequest != null); + const request = syncMessage.content.attachmentBackfillRequest; assert.deepEqual( - request.targetConversation?.threadServiceIdBinary, + request.targetConversation?.identifier?.threadServiceIdBinary, unknownContact.device.aciBinary ); assert.deepEqual( - request.targetMessage?.authorServiceIdBinary, + request.targetMessage?.author?.authorServiceIdBinary, unknownContact.device.aciBinary ); assert.strictEqual( @@ -457,9 +477,11 @@ describe('attachment backfill', function (this: Mocha.Suite) { createResponse({ targetConversation: request.targetConversation, targetMessage: request.targetMessage, - attachments: { - attachments: [{ status: Status.PENDING }], - longText: null, + data: { + attachments: { + attachments: [{ data: { status: Status.PENDING } }], + longText: null, + }, }, }), { @@ -473,13 +495,17 @@ describe('attachment backfill', function (this: Mocha.Suite) { createResponse({ targetConversation: request.targetConversation, targetMessage: request.targetMessage, - attachments: { - longText: null, - attachments: [ - { - attachment: catAttachment, - }, - ], + data: { + attachments: { + longText: null, + attachments: [ + { + data: { + attachment: catAttachment, + }, + }, + ], + }, }, }), { @@ -511,9 +537,9 @@ describe('attachment backfill', function (this: Mocha.Suite) { fileName: 'snow.jpg', thumbnail: { ...snowAttachment, - attachmentIdentifier: 'cdnKey', - cdnKey: 'snow-not-found', - cdnId: null, + attachmentIdentifier: { + cdnKey: 'snow-not-found', + }, }, }, ], @@ -526,9 +552,9 @@ describe('attachment backfill', function (this: Mocha.Suite) { title: 'Signal', image: { ...catAttachment, - attachmentIdentifier: 'cdnKey', - cdnKey: 'cat-not-found', - cdnId: null, + attachmentIdentifier: { + cdnKey: 'cat-not-found', + }, }, description: null, date: null, diff --git a/ts/test-mock/messaging/edit_test.node.ts b/ts/test-mock/messaging/edit_test.node.ts index 0ef621d46b..9d5826ed04 100644 --- a/ts/test-mock/messaging/edit_test.node.ts +++ b/ts/test-mock/messaging/edit_test.node.ts @@ -32,7 +32,9 @@ export const debug = createDebug('mock:test:edit'); const ACI_1 = generateAci(); const ACI_1_BINARY = Aci.parseFromServiceIdString(ACI_1).getRawUuidBytes(); const UNPROCESSED_ATTACHMENT: Proto.AttachmentPointer.Params = { - cdnId: 123n, + attachmentIdentifier: { + cdnId: 123n, + }, key: new Uint8Array([1, 2, 3]), digest: new Uint8Array([4, 5, 6]), contentType: IMAGE_GIF, @@ -60,13 +62,17 @@ function wrap({ }>): Proto.Content.Params { if (dataMessage != null) { return { - dataMessage, + content: { + dataMessage, + }, pniSignatureMessage: null, senderKeyDistributionMessage: null, }; } return { - editMessage, + content: { + editMessage, + }, pniSignatureMessage: null, senderKeyDistributionMessage: null, }; @@ -631,9 +637,11 @@ describe('editing', function (this: Mocha.Suite) { await friend.sendRaw( desktop, { - receiptMessage: { - type: Proto.ReceiptMessage.Type.DELIVERY, - timestamp: [originalMessage.timestamp], + content: { + receiptMessage: { + type: Proto.ReceiptMessage.Type.DELIVERY, + timestamp: [originalMessage.timestamp], + }, }, pniSignatureMessage: null, senderKeyDistributionMessage: null, @@ -678,9 +686,11 @@ describe('editing', function (this: Mocha.Suite) { await friend.sendRaw( desktop, { - receiptMessage: { - type: Proto.ReceiptMessage.Type.READ, - timestamp: [originalMessage.timestamp], + content: { + receiptMessage: { + type: Proto.ReceiptMessage.Type.READ, + timestamp: [originalMessage.timestamp], + }, }, pniSignatureMessage: null, senderKeyDistributionMessage: null, @@ -773,9 +783,11 @@ describe('editing', function (this: Mocha.Suite) { await friend.sendRaw( desktop, { - receiptMessage: { - type: 1, - timestamp: [editMessageV3.dataMessage.timestamp], + content: { + receiptMessage: { + type: 1, + timestamp: [editMessageV3.dataMessage.timestamp], + }, }, pniSignatureMessage: null, senderKeyDistributionMessage: null, diff --git a/ts/test-mock/messaging/expire_timer_version_test.node.ts b/ts/test-mock/messaging/expire_timer_version_test.node.ts index 215ac556d5..b208bc8243 100644 --- a/ts/test-mock/messaging/expire_timer_version_test.node.ts +++ b/ts/test-mock/messaging/expire_timer_version_test.node.ts @@ -184,37 +184,41 @@ describe('messaging/expireTimerVersion', function (this: Mocha.Suite) { const timestamp = bootstrap.getTimestamp(); const destinationServiceIdBinary = stranger.device.aciBinary; const content: Proto.Content.Params = { - syncMessage: { - sent: { - destinationServiceIdBinary, - timestamp: BigInt(timestamp), - message: { - ...EMPTY_DATA_MESSAGE, - body: 'request', - timestamp: BigInt(timestamp), - expireTimer: scenario.ourTimer, - expireTimerVersion: scenario.ourVersion, - }, - unidentifiedStatus: [ - { + content: { + syncMessage: { + content: { + sent: { destinationServiceIdBinary, - unidentified: null, - destinationPniIdentityKey: null, + timestamp: BigInt(timestamp), + message: { + ...EMPTY_DATA_MESSAGE, + body: 'request', + timestamp: BigInt(timestamp), + expireTimer: scenario.ourTimer, + expireTimerVersion: scenario.ourVersion, + }, + unidentifiedStatus: [ + { + destinationServiceIdBinary, + unidentified: null, + destinationPniIdentityKey: null, + destinationServiceId: null, + }, + ], + destinationE164: null, + expirationStartTimestamp: null, + isRecipientUpdate: null, + storyMessage: null, + storyMessageRecipients: null, + editMessage: null, destinationServiceId: null, }, - ], - destinationE164: null, - expirationStartTimestamp: null, - isRecipientUpdate: null, - storyMessage: null, - storyMessageRecipients: null, - editMessage: null, - destinationServiceId: null, + }, + read: null, + stickerPackOperation: null, + viewed: null, + padding: null, }, - read: null, - stickerPackOperation: null, - viewed: null, - padding: null, }, pniSignatureMessage: null, senderKeyDistributionMessage: null, @@ -229,12 +233,14 @@ describe('messaging/expireTimerVersion', function (this: Mocha.Suite) { debug('Send a response message'); const timestamp = bootstrap.getTimestamp(); const content: Proto.Content.Params = { - dataMessage: { - ...EMPTY_DATA_MESSAGE, - body: 'response', - timestamp: BigInt(timestamp), - expireTimer: scenario.theirTimer, - expireTimerVersion: scenario.theirVersion, + content: { + dataMessage: { + ...EMPTY_DATA_MESSAGE, + body: 'response', + timestamp: BigInt(timestamp), + expireTimer: scenario.theirTimer, + expireTimerVersion: scenario.theirVersion, + }, }, pniSignatureMessage: null, senderKeyDistributionMessage: null, diff --git a/ts/test-mock/messaging/lightbox_test.node.ts b/ts/test-mock/messaging/lightbox_test.node.ts index bbdd9e55ce..0bd09d7010 100644 --- a/ts/test-mock/messaging/lightbox_test.node.ts +++ b/ts/test-mock/messaging/lightbox_test.node.ts @@ -136,14 +136,14 @@ describe('lightbox', function (this: Mocha.Suite) { async function expectLightboxImage( attachment: Proto.AttachmentPointer.Params ) { - assert.strictEqual( - attachment.attachmentIdentifier, - 'cdnKey', + assert.ok( + attachment.attachmentIdentifier?.cdnKey != null, 'Must have cdnKey' ); - strictAssert(attachment.cdnKey.length > 0, 'Must have valid cdnKey'); - const Object = LightboxContent.getByTestId(attachment.cdnKey); - debug(`Waiting for attachment with cdnKey ${attachment.cdnKey}`); + const { cdnKey } = attachment.attachmentIdentifier; + strictAssert(cdnKey.length > 0, 'Must have valid cdnKey'); + const Object = LightboxContent.getByTestId(cdnKey); + debug(`Waiting for attachment with cdnKey ${cdnKey}`); await expect(Object).toBeVisible(); } diff --git a/ts/test-mock/messaging/readSync_test.node.ts b/ts/test-mock/messaging/readSync_test.node.ts index f46ef7a1c0..ad07da9a3f 100644 --- a/ts/test-mock/messaging/readSync_test.node.ts +++ b/ts/test-mock/messaging/readSync_test.node.ts @@ -104,16 +104,18 @@ describe('readSync', function (this: Mocha.Suite) { await phone.sendRaw( desktop, { - syncMessage: { - content: null, - read: longTimestamps.map(timestamp => ({ - senderAciBinary, - timestamp, - senderAci: null, - })), - stickerPackOperation: null, - viewed: null, - padding: null, + content: { + syncMessage: { + content: null, + read: longTimestamps.map(timestamp => ({ + senderAciBinary, + timestamp, + senderAci: null, + })), + stickerPackOperation: null, + viewed: null, + padding: null, + }, }, pniSignatureMessage: null, senderKeyDistributionMessage: null, diff --git a/ts/test-mock/messaging/safety_number_test.node.ts b/ts/test-mock/messaging/safety_number_test.node.ts index 35d31a17ba..76b57f06e7 100644 --- a/ts/test-mock/messaging/safety_number_test.node.ts +++ b/ts/test-mock/messaging/safety_number_test.node.ts @@ -194,7 +194,7 @@ describe('safety number', function (this: Mocha.Suite) { debug('Getting a story'); const { storyMessage } = await alice.waitForStory(); - assert.strictEqual(storyMessage.attachment, 'textAttachment'); - assert.strictEqual(storyMessage.textAttachment.text, '123'); + assert.ok(storyMessage.attachment?.textAttachment != null); + assert.strictEqual(storyMessage.attachment.textAttachment.text, '123'); }); }); diff --git a/ts/test-mock/messaging/sendSync_test.node.ts b/ts/test-mock/messaging/sendSync_test.node.ts index ecc3c230ce..2242084e59 100644 --- a/ts/test-mock/messaging/sendSync_test.node.ts +++ b/ts/test-mock/messaging/sendSync_test.node.ts @@ -65,30 +65,34 @@ describe('sendSync', function (this: Mocha.Suite) { }, }; const content: Proto.Content.Params = { - syncMessage: { - sent: { - timestamp: BigInt(timestamp), - message: originalDataMessage, - unidentifiedStatus: members.map(member => ({ - destinationServiceIdBinary: member.device.aciBinary, - destination: member.device.number, - unidentified: null, - destinationPniIdentityKey: null, - destinationServiceId: null, - })), - destinationE164: null, - expirationStartTimestamp: null, - isRecipientUpdate: null, - storyMessage: null, - storyMessageRecipients: null, - editMessage: null, - destinationServiceIdBinary: null, - destinationServiceId: null, + content: { + syncMessage: { + content: { + sent: { + timestamp: BigInt(timestamp), + message: originalDataMessage, + unidentifiedStatus: members.map(member => ({ + destinationServiceIdBinary: member.device.aciBinary, + destination: member.device.number, + unidentified: null, + destinationPniIdentityKey: null, + destinationServiceId: null, + })), + destinationE164: null, + expirationStartTimestamp: null, + isRecipientUpdate: null, + storyMessage: null, + storyMessageRecipients: null, + editMessage: null, + destinationServiceIdBinary: null, + destinationServiceId: null, + }, + }, + read: null, + stickerPackOperation: null, + viewed: null, + padding: null, }, - read: null, - stickerPackOperation: null, - viewed: null, - padding: null, }, pniSignatureMessage: null, senderKeyDistributionMessage: null, diff --git a/ts/test-mock/messaging/stories_test.node.ts b/ts/test-mock/messaging/stories_test.node.ts index b0bff50f41..779db3d790 100644 --- a/ts/test-mock/messaging/stories_test.node.ts +++ b/ts/test-mock/messaging/stories_test.node.ts @@ -142,50 +142,56 @@ describe('story/messaging', function (this: Mocha.Suite) { await phone.sendRaw( desktop, { - syncMessage: { - sent: { - timestamp: BigInt(sentAt), - expirationStartTimestamp: BigInt(sentAt), - storyMessage: { - textAttachment: { - text: 'hello', - textStyle: null, - textForegroundColor: null, - textBackgroundColor: null, - preview: null, - background: null, + content: { + syncMessage: { + content: { + sent: { + timestamp: BigInt(sentAt), + expirationStartTimestamp: BigInt(sentAt), + storyMessage: { + attachment: { + textAttachment: { + text: 'hello', + textStyle: null, + textForegroundColor: null, + textBackgroundColor: null, + preview: null, + background: null, + }, + }, + allowsReplies: true, + profileKey: null, + group: null, + bodyRanges: null, + }, + storyMessageRecipients: [ + { + destinationServiceIdBinary: first.device.aciBinary, + distributionListIds: [DISTRIBUTION1], + isAllowedToReply: true, + destinationServiceId: null, + }, + { + destinationServiceIdBinary: second.device.aciBinary, + distributionListIds: [DISTRIBUTION2], + isAllowedToReply: true, + destinationServiceId: null, + }, + ], + destinationE164: null, + message: null, + unidentifiedStatus: null, + isRecipientUpdate: null, + editMessage: null, + destinationServiceIdBinary: null, + destinationServiceId: null, }, - allowsReplies: true, - profileKey: null, - group: null, - bodyRanges: null, }, - storyMessageRecipients: [ - { - destinationServiceIdBinary: first.device.aciBinary, - distributionListIds: [DISTRIBUTION1], - isAllowedToReply: true, - destinationServiceId: null, - }, - { - destinationServiceIdBinary: second.device.aciBinary, - distributionListIds: [DISTRIBUTION2], - isAllowedToReply: true, - destinationServiceId: null, - }, - ], - destinationE164: null, - message: null, - unidentifiedStatus: null, - isRecipientUpdate: null, - editMessage: null, - destinationServiceIdBinary: null, - destinationServiceId: null, + read: null, + stickerPackOperation: null, + viewed: null, + padding: null, }, - read: null, - stickerPackOperation: null, - viewed: null, - padding: null, }, pniSignatureMessage: null, senderKeyDistributionMessage: null, @@ -197,15 +203,17 @@ describe('story/messaging', function (this: Mocha.Suite) { await first.sendRaw( desktop, { - dataMessage: { - ...EMPTY_DATA_MESSAGE, - body: 'first reply', - storyContext: { - authorAciBinary: phone.device.aciRawUuid, - sentTimestamp: BigInt(sentAt), - authorAci: null, + content: { + dataMessage: { + ...EMPTY_DATA_MESSAGE, + body: 'first reply', + storyContext: { + authorAciBinary: phone.device.aciRawUuid, + sentTimestamp: BigInt(sentAt), + authorAci: null, + }, + timestamp: BigInt(sentAt + 1), }, - timestamp: BigInt(sentAt + 1), }, pniSignatureMessage: null, senderKeyDistributionMessage: null, @@ -215,15 +223,17 @@ describe('story/messaging', function (this: Mocha.Suite) { await second.sendRaw( desktop, { - dataMessage: { - ...EMPTY_DATA_MESSAGE, - body: 'second reply', - storyContext: { - authorAciBinary: phone.device.aciRawUuid, - sentTimestamp: BigInt(sentAt), - authorAci: null, + content: { + dataMessage: { + ...EMPTY_DATA_MESSAGE, + body: 'second reply', + storyContext: { + authorAciBinary: phone.device.aciRawUuid, + sentTimestamp: BigInt(sentAt), + authorAci: null, + }, + timestamp: BigInt(sentAt + 2), }, - timestamp: BigInt(sentAt + 2), }, pniSignatureMessage: null, senderKeyDistributionMessage: null, @@ -279,20 +289,22 @@ describe('story/messaging', function (this: Mocha.Suite) { await contacts[0].sendRaw( desktop, { - dataMessage: { - ...EMPTY_DATA_MESSAGE, - body: 'first reply', - storyContext: { - authorAciBinary: desktop.aciRawUuid, - sentTimestamp: BigInt(sentAt), - authorAci: null, + content: { + dataMessage: { + ...EMPTY_DATA_MESSAGE, + body: 'first reply', + storyContext: { + authorAciBinary: desktop.aciRawUuid, + sentTimestamp: BigInt(sentAt), + authorAci: null, + }, + groupV2: { + masterKey: group.masterKey, + revision: null, + groupChange: null, + }, + timestamp: BigInt(sentAt + 1), }, - groupV2: { - masterKey: group.masterKey, - revision: null, - groupChange: null, - }, - timestamp: BigInt(sentAt + 1), }, pniSignatureMessage: null, senderKeyDistributionMessage: null, diff --git a/ts/test-mock/messaging/unknown_contact_test.node.ts b/ts/test-mock/messaging/unknown_contact_test.node.ts index 48633c5583..eef18c2fe8 100644 --- a/ts/test-mock/messaging/unknown_contact_test.node.ts +++ b/ts/test-mock/messaging/unknown_contact_test.node.ts @@ -46,18 +46,20 @@ describe('unknown contacts', function (this: Mocha.Suite) { debug('sending calling offer message'); await unknownContact.sendRaw(desktop, { - callMessage: { - offer: { - id: BigInt(Math.floor(Math.random() * 1e10)), - type: Proto.CallMessage.Offer.Type.OFFER_AUDIO_CALL, - opaque: new Uint8Array(0), + content: { + callMessage: { + offer: { + id: BigInt(Math.floor(Math.random() * 1e10)), + type: Proto.CallMessage.Offer.Type.OFFER_AUDIO_CALL, + opaque: new Uint8Array(0), + }, + answer: null, + iceUpdate: null, + busy: null, + hangup: null, + destinationDeviceId: null, + opaque: null, }, - answer: null, - iceUpdate: null, - busy: null, - hangup: null, - destinationDeviceId: null, - opaque: null, }, pniSignatureMessage: null, senderKeyDistributionMessage: null, @@ -102,17 +104,21 @@ describe('unknown contacts', function (this: Mocha.Suite) { debug('sending message request sync'); await phone.sendRaw(desktop, { - syncMessage: { - messageRequestResponse: { - type: Proto.SyncMessage.MessageRequestResponse.Type.ACCEPT, - threadAciBinary: unknownContact.device.aciRawUuid, - groupId: null, - threadAci: null, + content: { + syncMessage: { + content: { + messageRequestResponse: { + type: Proto.SyncMessage.MessageRequestResponse.Type.ACCEPT, + threadAciBinary: unknownContact.device.aciRawUuid, + groupId: null, + threadAci: null, + }, + }, + read: null, + stickerPackOperation: null, + viewed: null, + padding: null, }, - read: null, - stickerPackOperation: null, - viewed: null, - padding: null, }, pniSignatureMessage: null, senderKeyDistributionMessage: null, diff --git a/ts/test-mock/pnp/accept_gv2_invite_test.node.ts b/ts/test-mock/pnp/accept_gv2_invite_test.node.ts index 463775d760..075ae64511 100644 --- a/ts/test-mock/pnp/accept_gv2_invite_test.node.ts +++ b/ts/test-mock/pnp/accept_gv2_invite_test.node.ts @@ -214,13 +214,16 @@ describe('pnp/accept gv2 invite', function (this: Mocha.Suite) { // Verify that sync message was sent. const { syncMessage } = await phone.waitForSyncMessage(entry => { - if (entry.syncMessage.content !== 'sent') { + if (entry.syncMessage.content?.sent == null) { return false; } - return entry.syncMessage.sent.message?.groupV2?.groupChange != null; + return ( + entry.syncMessage.content.sent.message?.groupV2?.groupChange != null + ); }); - assert.strictEqual(syncMessage.content, 'sent'); - const groupChangeBuffer = syncMessage.sent.message?.groupV2?.groupChange; + assert.ok(syncMessage.content?.sent != null); + const groupChangeBuffer = + syncMessage.content.sent.message?.groupV2?.groupChange; assert.notEqual(groupChangeBuffer, null); const groupChange = Proto.GroupChange.decode( groupChangeBuffer ?? new Uint8Array(0) diff --git a/ts/test-mock/pnp/calling_test.node.ts b/ts/test-mock/pnp/calling_test.node.ts index a9c9bfd991..2c05dee81d 100644 --- a/ts/test-mock/pnp/calling_test.node.ts +++ b/ts/test-mock/pnp/calling_test.node.ts @@ -63,18 +63,20 @@ describe('pnp/calling', function (this: Mocha.Suite) { await stranger.sendRaw( desktop, { - callMessage: { - offer: { - id: null, - type: null, - opaque: new Uint8Array(1), + content: { + callMessage: { + offer: { + id: null, + type: null, + opaque: new Uint8Array(1), + }, + answer: null, + iceUpdate: null, + busy: null, + hangup: null, + destinationDeviceId: null, + opaque: null, }, - answer: null, - iceUpdate: null, - busy: null, - hangup: null, - destinationDeviceId: null, - opaque: null, }, pniSignatureMessage: null, senderKeyDistributionMessage: null, diff --git a/ts/test-mock/pnp/merge_test.node.ts b/ts/test-mock/pnp/merge_test.node.ts index 430217570f..92b116746b 100644 --- a/ts/test-mock/pnp/merge_test.node.ts +++ b/ts/test-mock/pnp/merge_test.node.ts @@ -404,7 +404,7 @@ describe('pnp/merge', function (this: Mocha.Suite) { let pniContacts = 0; let aciContacts = 0; for (const record of added) { - assert.strictEqual(record.record, 'contact'); + assert.ok(record.contact != null); const { contact } = record; @@ -427,7 +427,7 @@ describe('pnp/merge', function (this: Mocha.Suite) { } assert.strictEqual(aciContacts, 1); assert.strictEqual(pniContacts, 1); - assert.strictEqual(removed[0].record, 'contact'); + assert.ok(removed[0].contact != null); assert.deepEqual( removed[0].contact.pniBinary, @@ -561,37 +561,41 @@ describe('pnp/merge', function (this: Mocha.Suite) { const destinationServiceIdBinary = pniContact.device[`${key}Binary`]; const destination = key === 'pni' ? pniContact.device.number : undefined; const content: Proto.Content.Params = { - syncMessage: { - sent: { - destinationServiceIdBinary, - destinationE164: destination ?? null, - timestamp: BigInt(timestamp), - message: { - ...EMPTY_DATA_MESSAGE, - timestamp: BigInt(timestamp), - flags: Proto.DataMessage.Flags.EXPIRATION_TIMER_UPDATE, - expireTimer: key === 'pni' ? 90 * 24 * 3600 : 60 * 24 * 3600, - expireTimerVersion: key === 'pni' ? 3 : 4, - }, - unidentifiedStatus: [ - { + content: { + syncMessage: { + content: { + sent: { destinationServiceIdBinary, - unidentified: null, - destinationPniIdentityKey: null, + destinationE164: destination ?? null, + timestamp: BigInt(timestamp), + message: { + ...EMPTY_DATA_MESSAGE, + timestamp: BigInt(timestamp), + flags: Proto.DataMessage.Flags.EXPIRATION_TIMER_UPDATE, + expireTimer: key === 'pni' ? 90 * 24 * 3600 : 60 * 24 * 3600, + expireTimerVersion: key === 'pni' ? 3 : 4, + }, + unidentifiedStatus: [ + { + destinationServiceIdBinary, + unidentified: null, + destinationPniIdentityKey: null, + destinationServiceId: null, + }, + ], + expirationStartTimestamp: null, + isRecipientUpdate: null, + storyMessage: null, + storyMessageRecipients: null, + editMessage: null, destinationServiceId: null, }, - ], - expirationStartTimestamp: null, - isRecipientUpdate: null, - storyMessage: null, - storyMessageRecipients: null, - editMessage: null, - destinationServiceId: null, + }, + read: null, + stickerPackOperation: null, + viewed: null, + padding: null, }, - read: null, - stickerPackOperation: null, - viewed: null, - padding: null, }, pniSignatureMessage: null, senderKeyDistributionMessage: null, diff --git a/ts/test-mock/pnp/pni_change_test.node.ts b/ts/test-mock/pnp/pni_change_test.node.ts index d18e2032ac..ec35d3d0d0 100644 --- a/ts/test-mock/pnp/pni_change_test.node.ts +++ b/ts/test-mock/pnp/pni_change_test.node.ts @@ -138,7 +138,7 @@ describe('pnp/PNI Change', function (this: Mocha.Suite) { const updated = await phone.setStorageState( state .removeRecord(item => { - if (item.record.record !== 'contact') { + if (item.record.contact == null) { return false; } return item.record.contact.pniBinary?.length @@ -242,7 +242,7 @@ describe('pnp/PNI Change', function (this: Mocha.Suite) { const updated = await phone.setStorageState( state .removeRecord(item => { - if (item.record.record !== 'contact') { + if (item.record.contact == null) { return false; } return item.record.contact.pniBinary?.length @@ -351,7 +351,7 @@ describe('pnp/PNI Change', function (this: Mocha.Suite) { const updated = await phone.setStorageState( state .removeRecord(item => { - if (item.record.record !== 'contact') { + if (item.record.contact == null) { return false; } return item.record.contact.pniBinary?.length @@ -489,7 +489,7 @@ describe('pnp/PNI Change', function (this: Mocha.Suite) { const updated = await phone.setStorageState( state .removeRecord(item => { - if (item.record.record !== 'contact') { + if (item.record.contact == null) { return false; } return item.record.contact.pniBinary?.length @@ -528,7 +528,7 @@ describe('pnp/PNI Change', function (this: Mocha.Suite) { const updated = await phone.setStorageState( state .removeRecord(item => { - if (item.record.record !== 'contact') { + if (item.record.contact == null) { return false; } return item.record.contact.pniBinary?.length diff --git a/ts/test-mock/pnp/pni_signature_test.node.ts b/ts/test-mock/pnp/pni_signature_test.node.ts index 5688071b5e..28c301c490 100644 --- a/ts/test-mock/pnp/pni_signature_test.node.ts +++ b/ts/test-mock/pnp/pni_signature_test.node.ts @@ -277,31 +277,36 @@ describe('pnp/PNI Signature', function (this: Mocha.Suite) { timestamp: BigInt(timestamp), }; const content: Proto.Content.Params = { - syncMessage: { - sent: { - destinationServiceIdBinary, - destinationE164, - timestamp: BigInt(timestamp), - message: originalDataMessage, - unidentifiedStatus: [ - { + content: { + syncMessage: { + content: { + sent: { destinationServiceIdBinary, - destinationPniIdentityKey: destinationPniIdentityKey.serialize(), - unidentified: null, + destinationE164, + timestamp: BigInt(timestamp), + message: originalDataMessage, + unidentifiedStatus: [ + { + destinationServiceIdBinary, + destinationPniIdentityKey: + destinationPniIdentityKey.serialize(), + unidentified: null, + destinationServiceId: null, + }, + ], + expirationStartTimestamp: null, + isRecipientUpdate: null, + storyMessage: null, + storyMessageRecipients: null, + editMessage: null, destinationServiceId: null, }, - ], - expirationStartTimestamp: null, - isRecipientUpdate: null, - storyMessage: null, - storyMessageRecipients: null, - editMessage: null, - destinationServiceId: null, + }, + read: null, + stickerPackOperation: null, + viewed: null, + padding: null, }, - read: null, - stickerPackOperation: null, - viewed: null, - padding: null, }, pniSignatureMessage: null, senderKeyDistributionMessage: null, diff --git a/ts/test-mock/pnp/pni_unlink_test.node.ts b/ts/test-mock/pnp/pni_unlink_test.node.ts index a6056065c0..d536f96032 100644 --- a/ts/test-mock/pnp/pni_unlink_test.node.ts +++ b/ts/test-mock/pnp/pni_unlink_test.node.ts @@ -87,13 +87,16 @@ describe('pnp/PNI DecryptionError unlink', function (this: Mocha.Suite) { phone.sendRaw( desktop, { - syncMessage: { - content: 'pniChangeNumber', - pniChangeNumber, - read: null, - stickerPackOperation: null, - viewed: null, - padding: null, + content: { + syncMessage: { + content: { + pniChangeNumber, + }, + read: null, + stickerPackOperation: null, + viewed: null, + padding: null, + }, }, pniSignatureMessage: null, senderKeyDistributionMessage: null, @@ -108,13 +111,16 @@ describe('pnp/PNI DecryptionError unlink', function (this: Mocha.Suite) { phone.sendRaw( desktop, { - syncMessage: { - content: 'pniChangeNumber', - pniChangeNumber, - read: null, - stickerPackOperation: null, - viewed: null, - padding: null, + content: { + syncMessage: { + content: { + pniChangeNumber, + }, + read: null, + stickerPackOperation: null, + viewed: null, + padding: null, + }, }, pniSignatureMessage: null, senderKeyDistributionMessage: null, diff --git a/ts/test-mock/pnp/username_test.node.ts b/ts/test-mock/pnp/username_test.node.ts index 8c0e088ebb..f36e3dbc96 100644 --- a/ts/test-mock/pnp/username_test.node.ts +++ b/ts/test-mock/pnp/username_test.node.ts @@ -147,14 +147,14 @@ describe('pnp/username', function (this: Mocha.Suite) { 'only one record must be removed' ); - assert.strictEqual(added[0].record, 'contact'); + assert.ok(added[0].contact != null); assert.deepEqual( added[0].contact.aciBinary, usernameContact.device.aciRawUuid ); assert.strictEqual(added[0].contact.username, ''); - assert.strictEqual(removed[0].record, 'contact'); + assert.ok(removed[0].contact != null); assert.deepEqual( removed[0].contact.aciBinary, usernameContact.device.aciRawUuid @@ -235,7 +235,7 @@ describe('pnp/username', function (this: Mocha.Suite) { assert.strictEqual(added.length, 1, 'only one record must be added'); assert.strictEqual(removed.length, 1, 'only one record must be removed'); - assert.strictEqual(added[0]?.record, 'account'); + assert.ok(added[0]?.account != null); assert.strictEqual(added[0].account.username, username); const { usernameLink } = added[0].account; if (!usernameLink) { @@ -287,11 +287,7 @@ describe('pnp/username', function (this: Mocha.Suite) { assert.strictEqual(added.length, 1, 'only one record must be added'); assert.strictEqual(removed.length, 1, 'only one record must be removed'); - assert.strictEqual( - added[0]?.record, - 'account', - 'expected updated account' - ); + assert.ok(added[0]?.account != null, 'expected updated account'); assert.strictEqual(added[0].account.username, '', 'clears username'); assert.strictEqual( added[0].account.usernameLink?.entropy?.length ?? 0, diff --git a/ts/test-mock/rate-limit/story_test.node.ts b/ts/test-mock/rate-limit/story_test.node.ts index a1bafdd39f..4022058171 100644 --- a/ts/test-mock/rate-limit/story_test.node.ts +++ b/ts/test-mock/rate-limit/story_test.node.ts @@ -125,8 +125,10 @@ describe('story/no-sender-key', function (this: Mocha.Suite) { storyMessage.profileKey ?? new Uint8Array(0) ) ); - assert.strictEqual(storyMessage.attachment, 'textAttachment'); - assert.strictEqual(storyMessage.textAttachment.text, '123'); + assert.strictEqual( + storyMessage.attachment?.textAttachment?.text, + '123' + ); }) ); }); diff --git a/ts/test-mock/storage/drop_test.node.ts b/ts/test-mock/storage/drop_test.node.ts index 045dc2c07e..960a73a440 100644 --- a/ts/test-mock/storage/drop_test.node.ts +++ b/ts/test-mock/storage/drop_test.node.ts @@ -91,7 +91,7 @@ describe('storage service', function (this: Mocha.Suite) { assert.isTrue( nextState.hasRecord(({ type, record }) => { - if (type !== IdentifierType.GROUPV2 || record.record !== 'groupV2') { + if (type !== IdentifierType.GROUPV2 || record.groupV2 == null) { return false; } diff --git a/ts/test-mock/storage/fixtures.node.ts b/ts/test-mock/storage/fixtures.node.ts index 22ededd12a..e6f92924bf 100644 --- a/ts/test-mock/storage/fixtures.node.ts +++ b/ts/test-mock/storage/fixtures.node.ts @@ -196,7 +196,6 @@ export function getStickerPackLink(pack: StickerPackType): string { } type StickerRecord = StorageStateRecord<{ - record: 'stickerPack'; stickerPack: Proto.StickerPackRecord.Params; }>; @@ -205,7 +204,7 @@ export function getStickerPackRecordPredicate( ): (record: StorageStateRecord) => record is StickerRecord { return (stateRecord: StorageStateRecord): stateRecord is StickerRecord => { const { type, record } = stateRecord; - if (record.record !== 'stickerPack') { + if (record.stickerPack == null) { return false; } if (type !== IdentifierType.STICKER_PACK) { @@ -241,7 +240,6 @@ export async function storeStickerPacks( } type CallLinkRecord = StorageStateRecord<{ - record: 'callLink'; callLink: Proto.CallLinkRecord.Params; }>; @@ -250,7 +248,7 @@ export function getCallLinkRecordPredicate( ): (record: StorageStateRecord) => record is CallLinkRecord { return (stateRecord: StorageStateRecord): stateRecord is CallLinkRecord => { const { type, record } = stateRecord; - if (record.record !== 'callLink') { + if (record.callLink == null) { return false; } @@ -265,7 +263,6 @@ export function getCallLinkRecordPredicate( } type ChatFolderRecord = StorageStateRecord<{ - record: 'chatFolder'; chatFolder: Proto.ChatFolderRecord.Params; }>; @@ -276,7 +273,7 @@ export function getChatFolderRecordPredicate( ): (record: StorageStateRecord) => record is ChatFolderRecord { return (stateRecord): stateRecord is ChatFolderRecord => { const { type, record } = stateRecord; - if (record.record !== 'chatFolder') { + if (record.chatFolder == null) { return false; } diff --git a/ts/test-mock/storage/notification_profiles_test.node.ts b/ts/test-mock/storage/notification_profiles_test.node.ts index 43959904d1..206c8972a0 100644 --- a/ts/test-mock/storage/notification_profiles_test.node.ts +++ b/ts/test-mock/storage/notification_profiles_test.node.ts @@ -106,7 +106,7 @@ describe('storage service/notification profiles', function (this: Mocha.Suite) { let profileId: Uint8Array | undefined; const profilewasAdded = thirdState.hasRecord(record => { - if (record.record.record !== 'notificationProfile') { + if (record.record.notificationProfile == null) { return false; } @@ -152,7 +152,7 @@ describe('storage service/notification profiles', function (this: Mocha.Suite) { }); const profileScheduleIsOff = fourthState.hasRecord(record => { - if (record.record.record !== 'notificationProfile') { + if (record.record.notificationProfile == null) { return false; } assert.ok(record.type === IdentifierType.NOTIFICATION_PROFILE); @@ -184,18 +184,15 @@ describe('storage service/notification profiles', function (this: Mocha.Suite) { }); const acountRecordHasOverride = fifthState.hasRecord(record => { - if (record.record.record !== 'account') { + if (record.record.account == null) { return false; } const { notificationProfileManualOverride } = record.record.account; - if (notificationProfileManualOverride?.override == null) { - return false; - } - if (notificationProfileManualOverride.override !== 'enabled') { + if (notificationProfileManualOverride?.override?.enabled == null) { return false; } - const { id } = notificationProfileManualOverride.enabled; + const { id } = notificationProfileManualOverride.override.enabled; return Boolean( record.type === IdentifierType.ACCOUNT && @@ -297,9 +294,11 @@ describe('storage service/notification profiles', function (this: Mocha.Suite) { newState = newState.updateAccount({ notificationProfileManualOverride: { - enabled: { - id: notificationProfileId1, - endAtTimestampMs: null, + override: { + enabled: { + id: notificationProfileId1, + endAtTimestampMs: null, + }, }, }, }); @@ -344,18 +343,14 @@ describe('storage service/notification profiles', function (this: Mocha.Suite) { throw new Error('Notification profile sync is disabled!'); } - assert.strictEqual( - accountRecord?.notificationProfileManualOverride?.override, - 'enabled' - ); assert.deepEqual( - accountRecord.notificationProfileManualOverride.enabled.id, + accountRecord.notificationProfileManualOverride?.override?.enabled?.id, notificationProfileId1 ); let countOfProfiles = 0; secondState.hasRecord(record => { - if (record.record.record !== 'notificationProfile') { + if (record.record.notificationProfile == null) { return false; } const deletedTimestamp = @@ -479,9 +474,11 @@ describe('storage service/notification profiles', function (this: Mocha.Suite) { newState = newState.updateAccount({ notificationProfileManualOverride: { - enabled: { - id: notificationProfileId1, - endAtTimestampMs: null, + override: { + enabled: { + id: notificationProfileId1, + endAtTimestampMs: null, + }, }, }, notificationProfileSyncDisabled: false, @@ -524,7 +521,7 @@ describe('storage service/notification profiles', function (this: Mocha.Suite) { let countOfProfiles = 0; thirdState.hasRecord(record => { - if (record.record.record !== 'notificationProfile') { + if (record.record?.notificationProfile == null) { return false; } diff --git a/ts/test-mock/storage/sticker_test.node.ts b/ts/test-mock/storage/sticker_test.node.ts index 2fe8691fb8..90b6a240ac 100644 --- a/ts/test-mock/storage/sticker_test.node.ts +++ b/ts/test-mock/storage/sticker_test.node.ts @@ -196,7 +196,6 @@ describe('stickers', function (this: Mocha.Suite) { state.updateRecord( getStickerPackRecordPredicate(STICKER_PACKS[0]), record => ({ - record: 'stickerPack', stickerPack: { ...record.stickerPack, packKey: STICKER_PACKS[0].key, @@ -237,9 +236,8 @@ describe('stickers', function (this: Mocha.Suite) { const stickerPack = stateAfter.findRecord( getStickerPackRecordPredicate(STICKER_PACKS[1]) ); - assert.strictEqual( - stickerPack?.record.record, - 'stickerPack', + assert.ok( + stickerPack?.record.stickerPack != null, 'New storage state should have sticker pack record' ); assert.isTrue(