Introduce Service Id Types

Co-authored-by: Scott Nonnenberg <scott@signal.org>
This commit is contained in:
Fedor Indutny 2023-08-10 18:43:33 +02:00 committed by Jamie Kyle
parent 414c0a58d3
commit 366b875fd2
269 changed files with 5832 additions and 5550 deletions

View file

@ -2,21 +2,21 @@
// SPDX-License-Identifier: AGPL-3.0-only
import { assert } from 'chai';
import { UUID } from '../types/UUID';
import { generateAci } from '../types/ServiceId';
import { processSyncMessage } from '../textsecure/processSyncMessage';
describe('processSyncMessage', () => {
const destinationUuid = UUID.generate().toString();
const destinationServiceId = generateAci();
it('should normalize UUIDs in sent (aci)', () => {
it('should normalize UUIDs in sent', () => {
const out = processSyncMessage({
sent: {
destinationAci: destinationUuid.toUpperCase(),
destinationServiceId: destinationServiceId.toUpperCase(),
unidentifiedStatus: [
{
destinationAci: destinationUuid.toUpperCase(),
destinationServiceId: destinationServiceId.toUpperCase(),
},
],
},
@ -24,51 +24,12 @@ describe('processSyncMessage', () => {
assert.deepStrictEqual(out, {
sent: {
destinationUuid: {
aci: destinationUuid,
pni: undefined,
},
destinationServiceId,
storyMessageRecipients: undefined,
unidentifiedStatus: [
{
destinationUuid: {
aci: destinationUuid,
pni: undefined,
},
},
],
},
});
});
it('should normalize UUIDs in sent (pni)', () => {
const out = processSyncMessage({
sent: {
destinationPni: destinationUuid.toUpperCase(),
unidentifiedStatus: [
{
destinationPni: destinationUuid.toUpperCase(),
},
],
},
});
assert.deepStrictEqual(out, {
sent: {
destinationUuid: {
aci: undefined,
pni: destinationUuid,
},
storyMessageRecipients: undefined,
unidentifiedStatus: [
{
destinationUuid: {
aci: undefined,
pni: destinationUuid,
},
destinationServiceId,
},
],
},