Removes groupv1 protos

This commit is contained in:
Josh Perez 2023-07-26 13:49:27 -04:00 committed by GitHub
parent 6c70cd450b
commit 8aac997b4f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 21 additions and 373 deletions

View file

@ -6,7 +6,7 @@ import protobuf from '../protobuf/wrap';
import * as Bytes from '../Bytes';
import { SignalService as Proto } from '../protobuf';
import { ContactBuffer, GroupBuffer } from '../textsecure/ContactsParser';
import { ContactBuffer } from '../textsecure/ContactsParser';
const { Writer } = protobuf;
@ -70,58 +70,4 @@ describe('ContactsParser', () => {
assert.strictEqual(count, 3);
});
});
describe('GroupBuffer', () => {
function getTestBuffer(): Uint8Array {
const avatarBuffer = generateAvatar();
const groupInfoBuffer = Proto.GroupDetails.encode({
id: new Uint8Array([1, 3, 3, 7]),
name: 'Hackers',
membersE164: ['cereal', 'burn', 'phreak', 'joey'],
avatar: { contentType: 'image/jpeg', length: avatarBuffer.length },
}).finish();
const writer = new Writer();
writer.bytes(groupInfoBuffer);
const prefixedGroup = writer.finish();
const chunks: Array<Uint8Array> = [];
for (let i = 0; i < 3; i += 1) {
chunks.push(prefixedGroup);
chunks.push(avatarBuffer);
}
return Bytes.concatenate(chunks);
}
it('parses an array buffer of groups', () => {
const bytes = getTestBuffer();
const groupBuffer = new GroupBuffer(bytes);
let group = groupBuffer.next();
let count = 0;
while (group !== undefined) {
count += 1;
assert.strictEqual(group.name, 'Hackers');
assert.deepEqual(group.id, new Uint8Array([1, 3, 3, 7]));
assert.sameMembers(group.membersE164, [
'cereal',
'burn',
'phreak',
'joey',
]);
assert.strictEqual(group.avatar?.contentType, 'image/jpeg');
assert.strictEqual(group.avatar?.length, 255);
assert.strictEqual(group.avatar?.data.byteLength, 255);
const avatarBytes = new Uint8Array(
group.avatar?.data || new Uint8Array(0)
);
for (let j = 0; j < 255; j += 1) {
assert.strictEqual(avatarBytes[j], j);
}
group = groupBuffer.next();
}
assert.strictEqual(count, 3);
});
});
});