From 11883cb9896a156ab051b3891c4ae823c389624b Mon Sep 17 00:00:00 2001 From: Beaudan Date: Thu, 6 Dec 2018 15:07:49 +1100 Subject: [PATCH] Cleaner separation of loki tests --- libloki/test/libloki-protocol_test.js | 28 ++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/libloki/test/libloki-protocol_test.js b/libloki/test/libloki-protocol_test.js index cac7a4330..1cb942d0d 100644 --- a/libloki/test/libloki-protocol_test.js +++ b/libloki/test/libloki-protocol_test.js @@ -2,14 +2,13 @@ 'use strict'; -describe('ConversationCollection', () => { +describe('FallBackSessionCipher', () => { let fallbackCipher; let identityKey; - let testKey; let address; const store = textsecure.storage.protocol; - beforeEach(async () => { + before(async () => { clearDatabase(); identityKey = await libsignal.KeyHelper.generateIdentityKeyPair(); store.put('identityKey', identityKey); @@ -17,16 +16,9 @@ describe('ConversationCollection', () => { const pubKeyString = StringView.arrayBufferToHex(key); address = new libsignal.SignalProtocolAddress( pubKeyString, - 1 // sourceDevice + 1 ); - testKey = { - pubKey: libsignal.crypto.getRandomBytes(33), - privKey: libsignal.crypto.getRandomBytes(32), - }; fallbackCipher = new libloki.FallBackSessionCipher(address); - textsecure.storage.put('maxPreKeyId', 0); - textsecure.storage.put('signedKeyId', 2); - await store.storeSignedPreKey(1, testKey); }); it('should encrypt fallback cipher messages as friend requests', async () => { @@ -34,6 +26,20 @@ describe('ConversationCollection', () => { const { type } = await fallbackCipher.encrypt(buffer); assert.strictEqual(type, textsecure.protobuf.Envelope.Type.FRIEND_REQUEST); }); +}); + +describe('LibLoki Protocol', () => { + let testKey; + const store = textsecure.storage.protocol; + + beforeEach(async () => { + clearDatabase(); + testKey = { + pubKey: libsignal.crypto.getRandomBytes(33), + privKey: libsignal.crypto.getRandomBytes(32), + }; + await store.storeSignedPreKey(1, testKey); + }); it('should should generate a new prekey bundle for a new contact', async () => { const pubKey = libsignal.crypto.getRandomBytes(32);