Fully move to protobufjs

This commit is contained in:
Fedor Indutny 2021-07-13 11:54:53 -07:00 committed by GitHub
parent 20ea409d9e
commit 570fb182d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
46 changed files with 1133 additions and 12401 deletions

View file

@ -3,38 +3,32 @@
import { assert } from 'chai';
import { arePinnedConversationsEqual } from '../../util/arePinnedConversationsEqual';
import { PinnedConversationClass } from '../../textsecure.d';
import { SignalService as Proto } from '../../protobuf';
import PinnedConversation = Proto.AccountRecord.IPinnedConversation;
describe('arePinnedConversationsEqual', () => {
it('is equal if both have same values at same indices', () => {
const localValue = [
{
identifier: 'contact' as const,
contact: {
uuid: '72313cde-2784-4a6f-a92a-abbe23763a60',
e164: '+13055551234',
},
toArrayBuffer: () => new ArrayBuffer(0),
},
{
identifier: 'groupMasterKey' as const,
groupMasterKey: new ArrayBuffer(32),
toArrayBuffer: () => new ArrayBuffer(0),
groupMasterKey: new Uint8Array(32),
},
];
const remoteValue = [
{
identifier: 'contact' as const,
contact: {
uuid: '72313cde-2784-4a6f-a92a-abbe23763a60',
e164: '+13055551234',
},
toArrayBuffer: () => new ArrayBuffer(0),
},
{
identifier: 'groupMasterKey' as const,
groupMasterKey: new ArrayBuffer(32),
toArrayBuffer: () => new ArrayBuffer(0),
groupMasterKey: new Uint8Array(32),
},
];
@ -44,38 +38,30 @@ describe('arePinnedConversationsEqual', () => {
it('is not equal if values are mixed', () => {
const localValue = [
{
identifier: 'contact' as const,
contact: {
uuid: '72313cde-2784-4a6f-a92a-abbe23763a60',
e164: '+13055551234',
},
toArrayBuffer: () => new ArrayBuffer(0),
},
{
identifier: 'contact' as const,
contact: {
uuid: 'f59a9fed-9e91-4bb4-a015-d49e58b47e25',
e164: '+17865554321',
},
toArrayBuffer: () => new ArrayBuffer(0),
},
];
const remoteValue = [
{
identifier: 'contact' as const,
contact: {
uuid: 'f59a9fed-9e91-4bb4-a015-d49e58b47e25',
e164: '+17865554321',
},
toArrayBuffer: () => new ArrayBuffer(0),
},
{
identifier: 'contact' as const,
contact: {
uuid: '72313cde-2784-4a6f-a92a-abbe23763a60',
e164: '+13055551234',
},
toArrayBuffer: () => new ArrayBuffer(0),
},
];
@ -85,34 +71,28 @@ describe('arePinnedConversationsEqual', () => {
it('is not equal if lengths are not same', () => {
const localValue = [
{
identifier: 'contact' as const,
contact: {
uuid: '72313cde-2784-4a6f-a92a-abbe23763a60',
e164: '+13055551234',
},
toArrayBuffer: () => new ArrayBuffer(0),
},
];
const remoteValue: Array<PinnedConversationClass> = [];
const remoteValue: Array<PinnedConversation> = [];
assert.isFalse(arePinnedConversationsEqual(localValue, remoteValue));
});
it('is not equal if content does not match', () => {
const localValue = [
{
identifier: 'contact' as const,
contact: {
uuid: '72313cde-2784-4a6f-a92a-abbe23763a60',
e164: '+13055551234',
},
toArrayBuffer: () => new ArrayBuffer(0),
},
];
const remoteValue = [
{
identifier: 'groupMasterKey' as const,
groupMasterKey: new ArrayBuffer(32),
toArrayBuffer: () => new ArrayBuffer(0),
groupMasterKey: new Uint8Array(32),
},
];
assert.isFalse(arePinnedConversationsEqual(localValue, remoteValue));

View file

@ -2,6 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
import { assert } from 'chai';
import Long from 'long';
import {
getSafeLongFromTimestamp,
@ -9,8 +10,6 @@ import {
} from '../../util/timestampLongUtils';
describe('getSafeLongFromTimestamp', () => {
const { Long } = window.dcodeIO;
it('returns zero when passed undefined', () => {
assert(getSafeLongFromTimestamp(undefined).isZero());
});
@ -31,8 +30,6 @@ describe('getSafeLongFromTimestamp', () => {
});
describe('getTimestampFromLong', () => {
const { Long } = window.dcodeIO;
it('returns zero when passed 0 Long', () => {
assert.equal(getTimestampFromLong(Long.fromNumber(0)), 0);
});