From 5d8f9cf95047d228e1d45f0dade9d9ddad25969f Mon Sep 17 00:00:00 2001 From: Vincent Date: Fri, 26 Jun 2020 13:19:47 +1000 Subject: [PATCH 1/2] stratify-utils --- ts/test/session/utils/Promise_test.ts | 19 ++- ts/test/session/utils/String_test.ts | 99 +++++++++++- .../.syncthing.testUtils.js.map.tmp | 1 - .../test-utils/.syncthing.testUtils.js.tmp | 145 ------------------ ts/test/test-utils/utils/message.ts | 48 ++++++ 5 files changed, 159 insertions(+), 153 deletions(-) delete mode 100644 ts/test/test-utils/.syncthing.testUtils.js.map.tmp delete mode 100644 ts/test/test-utils/.syncthing.testUtils.js.tmp diff --git a/ts/test/session/utils/Promise_test.ts b/ts/test/session/utils/Promise_test.ts index 8d5b7fab7..c4ca24057 100644 --- a/ts/test/session/utils/Promise_test.ts +++ b/ts/test/session/utils/Promise_test.ts @@ -9,12 +9,23 @@ chai.use(chaiAsPromised); const { expect } = chai; - describe('Promise Utils', () => { const sandbox = sinon.createSandbox(); - let pollSpy: sinon.SinonSpy<[(done: (arg: any) => void) => Promise | void, (Partial | undefined)?], Promise>; - let waitForTaskSpy: sinon.SinonSpy<[(done: (arg: any) => void) => Promise | void, (number | undefined)?], Promise>; - let waitUntilSpy: sinon.SinonSpy<[() => Promise | boolean, (number | undefined)?], Promise>; + let pollSpy: sinon.SinonSpy< + [ + (done: (arg: any) => void) => Promise | void, + (Partial | undefined)? + ], + Promise + >; + let waitForTaskSpy: sinon.SinonSpy< + [(done: (arg: any) => void) => Promise | void, (number | undefined)?], + Promise + >; + let waitUntilSpy: sinon.SinonSpy< + [() => Promise | boolean, (number | undefined)?], + Promise + >; beforeEach(() => { pollSpy = sandbox.spy(PromiseUtils, 'poll'); diff --git a/ts/test/session/utils/String_test.ts b/ts/test/session/utils/String_test.ts index c21fe6556..f9b3be86d 100644 --- a/ts/test/session/utils/String_test.ts +++ b/ts/test/session/utils/String_test.ts @@ -82,7 +82,8 @@ describe('String Utils', () => { }); it('can encode huge string', async () => { - const testString = Array(Math.pow(2, 16)) + const stringSize = Math.pow(2, 16); + const testString = Array(stringSize) .fill('0') .join(''); @@ -127,8 +128,100 @@ describe('String Utils', () => { }); describe('decode', () => { - it('', async () => { - // + it('can decode empty buffer', async () => { + const buffer = new ByteBuffer(0); + + const encodings = ['base64', 'hex', 'binary', 'utf8'] as Array; + + // Each encoding should be valid + encodings.forEach(encoding => { + const decoded = StringUtils.decode(buffer, encoding); + + expect(decoded).to.exist; + expect(typeof decoded === String.name.toLowerCase()); + expect(decoded).to.have.length(0); + }); + }); + + it('can decode huge buffer', async () => { + const bytes = Math.pow(2, 16); + const bufferString = Array(bytes) + .fill('A') + .join(''); + const buffer = ByteBuffer.fromUTF8(bufferString); + + const encodings = ['base64', 'hex', 'binary', 'utf8'] as Array; + + // Each encoding should be valid + encodings.forEach(encoding => { + const decoded = StringUtils.decode(buffer, encoding); + + expect(decoded).to.exist; + expect(typeof decoded === String.name.toLowerCase()); + expect(decoded).to.have.length.greaterThan(0); + }); + }); + + it('can decode from ByteBuffer', async () => { + const buffer = ByteBuffer.fromUTF8('AAAAAAAAAA'); + + const encodings = ['base64', 'hex', 'binary', 'utf8'] as Array; + + // Each encoding should be valid + encodings.forEach(encoding => { + const decoded = StringUtils.decode(buffer, encoding); + + expect(decoded).to.exist; + expect(typeof decoded === String.name.toLowerCase()); + expect(decoded).to.have.length.greaterThan(0); + }); + }); + + it('can decode from Buffer', async () => { + const arrayBuffer = new ArrayBuffer(10); + const buffer = Buffer.from(arrayBuffer); + buffer.writeUInt8(0, 0); + + const encodings = ['base64', 'hex', 'binary', 'utf8'] as Array; + + // Each encoding should be valid + encodings.forEach(encoding => { + const decoded = StringUtils.decode(buffer, encoding); + + expect(decoded).to.exist; + expect(typeof decoded === String.name.toLowerCase()); + expect(decoded).to.have.length.greaterThan(0); + }); + }); + + it('can decode from ArrayBuffer', async () => { + const buffer = new ArrayBuffer(10); + + const encodings = ['base64', 'hex', 'binary', 'utf8'] as Array; + + // Each encoding should be valid + encodings.forEach(encoding => { + const decoded = StringUtils.decode(buffer, encoding); + + expect(decoded).to.exist; + expect(typeof decoded === String.name.toLowerCase()); + expect(decoded).to.have.length.greaterThan(0); + }); + }); + + it('can decode from Uint8Array', async () => { + const buffer = new Uint8Array(10); + + const encodings = ['base64', 'hex', 'binary', 'utf8'] as Array; + + // Each encoding should be valid + encodings.forEach(encoding => { + const decoded = StringUtils.decode(buffer, encoding); + + expect(decoded).to.exist; + expect(typeof decoded === String.name.toLowerCase()); + expect(decoded).to.have.length.greaterThan(0); + }); }); }); }); diff --git a/ts/test/test-utils/.syncthing.testUtils.js.map.tmp b/ts/test/test-utils/.syncthing.testUtils.js.map.tmp deleted file mode 100644 index 4b666e271..000000000 --- a/ts/test/test-utils/.syncthing.testUtils.js.map.tmp +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"testUtils.js","sourceRoot":"","sources":["testUtils.ts"],"names":[],"mappings":";;;;;;;;;AAAA,6CAA+B;AAC/B,+CAAiC;AAGjC,+BAAkC;AAElC,qDAA8D;AAC9D,8DAIyC;AAIzC,wBAA8B;AAE9B,MAAM,SAAS,GAAQ,MAAM,CAAC;AAC9B,MAAM,OAAO,GAAG,KAAK,CAAC,aAAa,EAAE,CAAC;AAEtC,qEAAqE;AACrE,oDAAoD;AACpD,+DAA+D;AAC/D,MAAM,IAAI,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;AAGjD;;;;;GAKG;AACH,SAAgB,QAAQ,CAA+B,EAAK;IAC1D,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AAChC,CAAC;AAFD,4BAEC;AAID;;;;;GAKG;AACH,SAAgB,UAAU,CACxB,EAAK,EACL,KAAqB;IAErB,gDAAgD;IAChD,IAAI,OAAO,SAAS,CAAC,MAAM,KAAK,WAAW,EAAE;QAC3C,SAAS,CAAC,MAAM,GAAG,EAAE,CAAC;KACvB;IAED,MAAM,GAAG,GAAG,CAAC,QAAwB,EA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W,EAAE,YAAY;YACzB,cAAc,EAAE,IAAI;YACpB,WAAW,EAAE,KAAK;YAClB,WAAW,EAAE,EAAE;YACf,UAAU,EAAE,KAAK;YACjB,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;YACrB,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;YACrB,eAAe,EAAE,CAAC,IAAI,CAAC,SAAS;SACjC,CAAC;IACJ,CAAC;IAEM,SAAS;QACd,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,gBAAgB;QACrB,OAAO,KAAK,CAAC;IACf,CAAC;IAEM,SAAS;QACd,OAAO,KAAK,CAAC;IACf,CAAC;IAEM,sBAAsB;QAC3B,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,YAAS,CAAC,kBAAkB,EAAE,CAAC,GAAG,CAAC;IACvE,CAAC;CACF;AAxCD,0DAwCC"} \ No newline at end of file diff --git a/ts/test/test-utils/.syncthing.testUtils.js.tmp b/ts/test/test-utils/.syncthing.testUtils.js.tmp deleted file mode 100644 index b4b3fd08c..000000000 --- a/ts/test/test-utils/.syncthing.testUtils.js.tmp +++ /dev/null @@ -1,145 +0,0 @@ -"use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const sinon = __importStar(require("sinon")); -const crypto = __importStar(require("crypto")); -const uuid_1 = require("uuid"); -const types_1 = require("../../../ts/session/types"); -const outgoing_1 = require("../../session/messages/outgoing"); -const _1 = require("."); -const globalAny = global; -const sandbox = sinon.createSandbox(); -// We have to do this in a weird way because Data uses module.exports -// which doesn't play well with sinon or ImportMock -// tslint:disable-next-line: no-require-imports no-var-requires -const Data = require('../../../js/modules/data'); -/** - * Stub a function inside Data. - * - * Note: This uses a custom sandbox. - * Please call `restoreStubs()` or `stub.restore()` to restore original functionality. - */ -function stubData(fn) { - return sandbox.stub(Data, fn); -} -exports.stubData = stubData; -/** - * Stub a window object. - * - * Note: This uses a custom sandbox. - * Please call `restoreStubs()` or `stub.restore()` to restore original functionality. - */ -function stubWindow(fn, value) { - // tslint:disable-next-line: no-typeof-undefined - if (typeof globalAny.window === 'undefined') { - globalAny.window = {}; - } - const set = (newValue) => { - globalAny.window[fn] = newValue; - }; - const get = () => { - return globalAny.window[fn]; - }; - globalAny.window[fn] = value; - return { - get, - set, - }; -} -exports.stubWindow = stubWindow; -function restoreStubs() { - globalAny.window = undefined; - sandbox.restore(); -} -exports.restoreStubs = restoreStubs; -function generateFakePubKey() { - // Generates a mock pubkey for testing - const numBytes = types_1.PubKey.PUBKEY_LEN / 2 - 1; - const hexBuffer = crypto.randomBytes(numBytes).toString('hex'); - const pubkeyString = `05${hexBuffer}`; - return new types_1.PubKey(pubkeyString); -} -exports.generateFakePubKey = generateFakePubKey; -function generateFakePubKeys(amount) { - const numPubKeys = amount > 0 ? Math.floor(amount) : 0; - // tslint:disable-next-line: no-unnecessary-callback-wrapper - return new Array(numPubKeys).fill(0).map(() => generateFakePubKey()); -} -exports.generateFakePubKeys = generateFakePubKeys; -function generateChatMessage(identifier) { - return new outgoing_1.ChatMessage({ - body: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', - identifier: (identifier !== null && identifier !== void 0 ? identifier : uuid_1.v4()), - timestamp: Date.now(), - attachments: undefined, - quote: undefined, - expireTimer: undefined, - lokiProfile: undefined, - preview: undefined, - }); -} -exports.generateChatMessage = generateChatMessage; -function generateOpenGroupMessage() { - const group = new types_1.OpenGroup({ - server: 'chat.example.server', - channel: 0, - conversationId: '0', - }); - return new outgoing_1.OpenGroupMessage({ - timestamp: Date.now(), - group, - attachments: undefined, - preview: undefined, - body: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', - quote: undefined, - }); -} -exports.generateOpenGroupMessage = generateOpenGroupMessage; -function generateClosedGroupMessage(groupId) { - return new outgoing_1.ClosedGroupChatMessage({ - identifier: uuid_1.v4(), - groupId: (groupId !== null && groupId !== void 0 ? groupId : generateFakePubKey().key), - chatMessage: generateChatMessage(), - }); -} -exports.generateClosedGroupMessage = generateClosedGroupMessage; -class MockPrivateConversation { - constructor(params) { - var _a; - const dayInSeconds = 86400; - this.isPrimary = params.isPrimary; - this.id = (_a = params.id, (_a !== null && _a !== void 0 ? _a : _1.TestUtils.generateFakePubKey().key)); - this.attributes = { - members: [], - left: false, - expireTimer: dayInSeconds, - profileSharing: true, - mentionedUs: false, - unreadCount: 99, - isArchived: false, - active_at: Date.now(), - timestamp: Date.now(), - secondaryStatus: !this.isPrimary, - }; - } - isPrivate() { - return true; - } - isOurLocalDevice() { - return false; - } - isBlocked() { - return false; - } - getPrimaryDevicePubKey() { - return this.isPrimary ? this.id : _1.TestUtils.generateFakePubKey().key; - } -} -exports.MockPrivateConversation = MockPrivateConversation; -//# sourceMappingURL=testUtils.js.map \ No newline at end of file diff --git a/ts/test/test-utils/utils/message.ts b/ts/test/test-utils/utils/message.ts index e2e71504a..21b365f7f 100644 --- a/ts/test/test-utils/utils/message.ts +++ b/ts/test/test-utils/utils/message.ts @@ -6,6 +6,7 @@ import { import { v4 as uuid } from 'uuid'; import { OpenGroup } from '../../../session/types'; import { generateFakePubKey } from './pubkey'; +import { ConversationAttributes } from '../../../../js/models/conversation'; export function generateChatMessage(identifier?: string): ChatMessage { return new ChatMessage({ @@ -46,3 +47,50 @@ export function generateClosedGroupMessage( chatMessage: generateChatMessage(), }); } + +interface MockPrivateConversationParams { + id?: string; + isPrimary: boolean; +} + +export class MockPrivateConversation { + public id: string; + public isPrimary: boolean; + public attributes: ConversationAttributes; + + constructor(params: MockPrivateConversationParams) { + const dayInSeconds = 86400; + + this.isPrimary = params.isPrimary; + this.id = params.id ?? generateFakePubKey().key; + + this.attributes = { + members: [], + left: false, + expireTimer: dayInSeconds, + profileSharing: true, + mentionedUs: false, + unreadCount: 99, + isArchived: false, + active_at: Date.now(), + timestamp: Date.now(), + secondaryStatus: !this.isPrimary, + }; + } + + public isPrivate() { + return true; + } + + public isOurLocalDevice() { + return false; + } + + public isBlocked() { + return false; + } + + public getPrimaryDevicePubKey() { + return this.isPrimary ? this.id : generateFakePubKey().key; + } +} From a62a19145ced094d04025430950df8bba93305dd Mon Sep 17 00:00:00 2001 From: Vincent Date: Mon, 29 Jun 2020 08:29:09 +1000 Subject: [PATCH 2/2] group-tests --- js/modules/data.d.ts | 2 +- ts/test/session/utils/Groups_test.ts | 17 ++++++++++++ ts/test/session/utils/SyncMessage_test.ts | 4 +-- ts/test/test-utils/utils/message.ts | 33 +++++++++++++++++------ 4 files changed, 45 insertions(+), 11 deletions(-) diff --git a/js/modules/data.d.ts b/js/modules/data.d.ts index 711cb0a29..a1ec157ed 100644 --- a/js/modules/data.d.ts +++ b/js/modules/data.d.ts @@ -1,5 +1,5 @@ import { ConversationType } from '../../ts/state/ducks/conversations'; -import { Mesasge } from '../../ts/types/Message'; +import { Message } from '../../ts/types/Message'; export type IdentityKey = { id: string; diff --git a/ts/test/session/utils/Groups_test.ts b/ts/test/session/utils/Groups_test.ts index 0aa2840c8..34d35c0c6 100644 --- a/ts/test/session/utils/Groups_test.ts +++ b/ts/test/session/utils/Groups_test.ts @@ -14,9 +14,26 @@ chai.use(chaiAsPromised); const { expect } = chai; describe('Groups Utils', () => { + const sandbox = sinon.createSandbox(); + + + + describe('getGroupMembers', () => { + let ConversationControllerStub: sinon.SinonStub; + + beforeEach(async () => { + const mockConversation = TestUtils.MockGroupConversation({ type: 'group' }); + + ConversationControllerStub = TestUtils.stubWindow('ConversationCollection', { + get: sandbox.stub().returns(mockConversation), + }); + }); + it('', async () => { // + + // should all be primary keys }); }); diff --git a/ts/test/session/utils/SyncMessage_test.ts b/ts/test/session/utils/SyncMessage_test.ts index 086fa0abb..c2403565f 100644 --- a/ts/test/session/utils/SyncMessage_test.ts +++ b/ts/test/session/utils/SyncMessage_test.ts @@ -51,10 +51,10 @@ describe('Sync Message Utils', () => { const numConversations = 20; const primaryConversations = new Array(numConversations / 2) .fill({}) - .map(() => new TestUtils.MockPrivateConversation({ isPrimary: true })); + .map(() => new TestUtils.MockConversation({ type: 'primary' })); const secondaryConversations = new Array(numConversations / 2) .fill({}) - .map(() => new TestUtils.MockPrivateConversation({ isPrimary: false })); + .map(() => new TestUtils.MockConversation({ type: 'secondary' })); const conversations = [...primaryConversations, ...secondaryConversations]; const sandbox = sinon.createSandbox(); diff --git a/ts/test/test-utils/utils/message.ts b/ts/test/test-utils/utils/message.ts index 21b365f7f..1bd76bd32 100644 --- a/ts/test/test-utils/utils/message.ts +++ b/ts/test/test-utils/utils/message.ts @@ -5,7 +5,7 @@ import { } from '../../../session/messages/outgoing'; import { v4 as uuid } from 'uuid'; import { OpenGroup } from '../../../session/types'; -import { generateFakePubKey } from './pubkey'; +import { generateFakePubKey, generateFakePubKeys } from './pubkey'; import { ConversationAttributes } from '../../../../js/models/conversation'; export function generateChatMessage(identifier?: string): ChatMessage { @@ -48,24 +48,37 @@ export function generateClosedGroupMessage( }); } -interface MockPrivateConversationParams { +interface MockConversationParams { id?: string; - isPrimary: boolean; + type: MockConversationType; + members?: Array; } -export class MockPrivateConversation { +export enum MockConversationType { + Primary = 'primary', + Secondary = 'secondary', + Group = 'group', +} + +export class MockConversation { public id: string; - public isPrimary: boolean; + public type: MockConversationType; public attributes: ConversationAttributes; + public isPrimary?: boolean; - constructor(params: MockPrivateConversationParams) { + constructor(params: MockConversationParams) { const dayInSeconds = 86400; - this.isPrimary = params.isPrimary; + this.type = params.type; this.id = params.id ?? generateFakePubKey().key; + this.isPrimary = this.type === MockConversationType.Primary; + + const members = this.type === MockConversationType.Group + ? params.members ?? generateFakePubKeys(10).map(m => m.key) + : []; this.attributes = { - members: [], + members, left: false, expireTimer: dayInSeconds, profileSharing: true, @@ -91,6 +104,10 @@ export class MockPrivateConversation { } public getPrimaryDevicePubKey() { + if (this.type === MockConversationType.Group) { + return undefined; + } + return this.isPrimary ? this.id : generateFakePubKey().key; } }