Passive UUID support

Co-authored-by: Scott Nonnenberg <scott@signal.org>
This commit is contained in:
Ken Powers 2020-03-05 13:14:58 -08:00 committed by Scott Nonnenberg
parent f64ca0ed21
commit a90246cbe5
49 changed files with 2226 additions and 776 deletions

View file

@ -13,6 +13,7 @@ describe('ContactBuffer', () => {
const contactInfo = new textsecure.protobuf.ContactDetails({
name: 'Zero Cool',
number: '+10000000000',
uuid: '7198E1BD-1293-452A-A098-F982FF201902',
avatar: { contentType: 'image/jpeg', length: avatarLen },
});
const contactInfoBuffer = contactInfo.encode().toArrayBuffer();
@ -37,6 +38,7 @@ describe('ContactBuffer', () => {
count += 1;
assert.strictEqual(contact.name, 'Zero Cool');
assert.strictEqual(contact.number, '+10000000000');
assert.strictEqual(contact.uuid, '7198e1bd-1293-452a-a098-f982ff201902');
assert.strictEqual(contact.avatar.contentType, 'image/jpeg');
assert.strictEqual(contact.avatar.length, 255);
assert.strictEqual(contact.avatar.data.byteLength, 255);
@ -63,7 +65,13 @@ describe('GroupBuffer', () => {
const groupInfo = new textsecure.protobuf.GroupDetails({
id: new Uint8Array([1, 3, 3, 7]).buffer,
name: 'Hackers',
members: ['cereal', 'burn', 'phreak', 'joey'],
membersE164: ['cereal', 'burn', 'phreak', 'joey'],
members: [
{ uuid: '3EA23646-92E8-4604-8833-6388861971C1', e164: 'cereal' },
{ uuid: 'B8414169-7149-4736-8E3B-477191931301', e164: 'burn' },
{ uuid: '64C97B95-A782-4E1E-BBCC-5A4ACE8d71f6', e164: 'phreak' },
{ uuid: 'CA334652-C35B-4FDC-9CC7-5F2060C771EE', e164: 'joey' },
],
avatar: { contentType: 'image/jpeg', length: avatarLen },
});
const groupInfoBuffer = groupInfo.encode().toArrayBuffer();
@ -91,7 +99,21 @@ describe('GroupBuffer', () => {
group.id.toArrayBuffer(),
new Uint8Array([1, 3, 3, 7]).buffer
);
assert.sameMembers(group.members, ['cereal', 'burn', 'phreak', 'joey']);
assert.sameMembers(group.membersE164, [
'cereal',
'burn',
'phreak',
'joey',
]);
assert.sameDeepMembers(
group.members.map(({ uuid, e164 }) => ({ uuid, e164 })),
[
{ uuid: '3ea23646-92e8-4604-8833-6388861971c1', e164: 'cereal' },
{ uuid: 'b8414169-7149-4736-8e3b-477191931301', e164: 'burn' },
{ uuid: '64c97b95-a782-4e1e-bbcc-5a4ace8d71f6', e164: 'phreak' },
{ uuid: 'ca334652-c35b-4fdc-9cc7-5f2060c771ee', e164: 'joey' },
]
);
assert.strictEqual(group.avatar.contentType, 'image/jpeg');
assert.strictEqual(group.avatar.length, 255);
assert.strictEqual(group.avatar.data.byteLength, 255);