From 9d7d3bbe6ec1b5e29688eb789f19e3705779307e Mon Sep 17 00:00:00 2001 From: Vincent Date: Fri, 27 Mar 2020 11:29:50 +1100 Subject: [PATCH] message functions init --- config/test-integration-session-2.json | 6 --- config/test-integration-session-3.json | 6 +++ integration_test/common.js | 28 ++++++----- integration_test/integration_test.js | 8 +-- integration_test/link_device_test.js | 2 +- integration_test/message_functions_test.js | 48 ++++++++++++++++++ integration_test/message_sync_test.js | 58 ++++++++++++++++++++++ integration_test/test_test.js | 45 ----------------- 8 files changed, 134 insertions(+), 67 deletions(-) delete mode 100644 config/test-integration-session-2.json create mode 100644 config/test-integration-session-3.json create mode 100644 integration_test/message_functions_test.js create mode 100644 integration_test/message_sync_test.js delete mode 100644 integration_test/test_test.js diff --git a/config/test-integration-session-2.json b/config/test-integration-session-2.json deleted file mode 100644 index e6a66e69d..000000000 --- a/config/test-integration-session-2.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "storageProfile": "testIntegration2Profile", - "openDevTools": false, - "updatesEnabled": false, - "localServerPort": "8082" -} diff --git a/config/test-integration-session-3.json b/config/test-integration-session-3.json new file mode 100644 index 000000000..9165effd6 --- /dev/null +++ b/config/test-integration-session-3.json @@ -0,0 +1,6 @@ +{ + "storageProfile": "testIntegration3Profile", + "openDevTools": false, + "updatesEnabled": false, + "localServerPort": "8489" +} diff --git a/integration_test/common.js b/integration_test/common.js index 5bcc7e40e..562afebe3 100644 --- a/integration_test/common.js +++ b/integration_test/common.js @@ -35,6 +35,13 @@ module.exports = { '054e1ca8681082dbd9aad1cf6fc89a32254e15cba50c75b5a73ac10a0b96bcbd2a', TEST_DISPLAY_NAME2: 'integration_tester_2', + TEST_MNEMONIC3: + 'alpine lukewarm oncoming blender kiwi fuel lobster upkeep vogue simplest gasp fully simplest', + TEST_PUBKEY3: + '05f8662b6e83da5a31007cc3ded44c601f191e07999acb6db2314a896048d9036c', + TEST_DISPLAY_NAME3: 'integration_tester_3', + + /* ************** OPEN GROUPS ****************** */ VALID_GROUP_URL: 'https://chat.getsession.org', VALID_GROUP_URL2: 'https://chat-dev.lokinet.org', @@ -98,14 +105,10 @@ module.exports = { const killStr = process.platform === 'win32' ? 'taskkill /im electron.exe /t /f' - : 'killall -9 electron'; + : 'pkill -f "node_modules/.bin/electron"'; return new Promise(resolve => { - exec(killStr, (err, stdout, stderr) => { - if (err) { - resolve({ stdout, stderr }); - } else { - resolve({ stdout, stderr }); - } + exec(killStr, (_err, stdout, stderr) => { + resolve({ stdout, stderr }); }); }); }, @@ -166,13 +169,14 @@ module.exports = { return app1; }, - async startAndStub2(props) { - const app2 = await this.startAndStub({ - env: 'test-integration-session-2', + async startAndStubN(props, n) { + // Make app with stub as number n + const appN = await this.startAndStub({ + env: `test-integration-session-${n}`, ...props, }); - return app2; + return appN; }, async restoreFromMnemonic(app1, mnemonic, displayName) { @@ -207,7 +211,7 @@ module.exports = { const [app1, app2] = await Promise.all([ this.startAndStub(app1Props), - this.startAndStub2(app2Props), + this.startAndStubN(app2Props, 2), ]); /** add each other as friends */ diff --git a/integration_test/integration_test.js b/integration_test/integration_test.js index 1315d7a8f..6e557ecd3 100644 --- a/integration_test/integration_test.js +++ b/integration_test/integration_test.js @@ -9,10 +9,12 @@ const common = require('./common'); require('./registration_test'); require('./open_group_test'); require('./add_friends_test'); -require('./link_device_test'); -require('./closed_group_test'); +// require('./link_device_test'); +// require('./closed_group_test'); + + +require('./message_sync_test'); -// require('./test_test'); before(async () => { // start the app once before all tests to get the platform-dependent diff --git a/integration_test/link_device_test.js b/integration_test/link_device_test.js index 14e60af03..d0fd66a36 100644 --- a/integration_test/link_device_test.js +++ b/integration_test/link_device_test.js @@ -27,7 +27,7 @@ describe('Link Device', function() { [app, app2] = await Promise.all([ common.startAndStub(app1Props), - common.startAndStub2(app2Props), + common.startAndStubN(app2Props, 2), ]); }); diff --git a/integration_test/message_functions_test.js b/integration_test/message_functions_test.js new file mode 100644 index 000000000..d0fd66a36 --- /dev/null +++ b/integration_test/message_functions_test.js @@ -0,0 +1,48 @@ +/* eslint-disable prefer-destructuring */ +/* eslint-disable more/no-then */ +/* eslint-disable func-names */ +/* eslint-disable import/no-extraneous-dependencies */ +const common = require('./common'); +const { afterEach, beforeEach, describe, it } = require('mocha'); + +describe('Link Device', function() { + let app; + let app2; + this.timeout(60000); + this.slow(15000); + + beforeEach(async () => { + await common.killallElectron(); + await common.stopStubSnodeServer(); + + const app1Props = { + mnemonic: common.TEST_MNEMONIC1, + displayName: common.TEST_DISPLAY_NAME1, + stubSnode: true, + }; + + const app2Props = { + stubSnode: true, + }; + + [app, app2] = await Promise.all([ + common.startAndStub(app1Props), + common.startAndStubN(app2Props, 2), + ]); + }); + + afterEach(async () => { + await common.killallElectron(); + await common.stopStubSnodeServer(); + }); + + it('link two desktop devices', async () => { + await common.linkApp2ToApp(app, app2); + }); + + it('unlink two devices', async () => { + await common.linkApp2ToApp(app, app2); + await common.timeout(1000); + await common.triggerUnlinkApp2FromApp(app, app2); + }); +}); diff --git a/integration_test/message_sync_test.js b/integration_test/message_sync_test.js new file mode 100644 index 000000000..3d1b340ce --- /dev/null +++ b/integration_test/message_sync_test.js @@ -0,0 +1,58 @@ +/* eslint-disable func-names */ +/* eslint-disable import/no-extraneous-dependencies */ +const common = require('./common'); +const { afterEach, beforeEach, describe, it } = require('mocha'); + + +describe('Message Syncing', function() { + let app; + let app2; + let app3; + this.timeout(60000); + this.slow(15000); + + beforeEach(async () => { + // await common.killallElectron(); + await common.stopStubSnodeServer(); + + const app1Props = { + mnemonic: common.TEST_MNEMONIC1, + displayName: common.TEST_DISPLAY_NAME1, + stubSnode: true, + }; + + const app2Props = { + mnemonic: common.TEST_MNEMONIC2, + displayName: common.TEST_DISPLAY_NAME2, + stubSnode: true, + }; + + const app3Props = { + mnemonic: common.TEST_MNEMONIC3, + displayName: common.TEST_DISPLAY_NAME3, + stubSnode: true, + }; + + [app, app2, app3] = await Promise.all([ + common.startAndStub(app1Props), + common.startAndStubN(app2Props, 2), + common.startAndStubN(app3Props, 3), + ]); + }); + + afterEach(async () => { + await common.killallElectron(); + await common.stopStubSnodeServer(); + }); + + it('message syncing between linked devices', async () => { + await common.linkApp2ToApp(app, app2); + }); + + it('unlink two devices', async () => { + await common.linkApp2ToApp(app, app2); + await common.timeout(1000); + await common.triggerUnlinkApp2FromApp(app, app2); + }); + +}); \ No newline at end of file diff --git a/integration_test/test_test.js b/integration_test/test_test.js deleted file mode 100644 index caa2b33b4..000000000 --- a/integration_test/test_test.js +++ /dev/null @@ -1,45 +0,0 @@ -// /* eslint-disable func-names */ -// /* eslint-disable import/no-extraneous-dependencies */ -// const common = require('./common'); -// const { afterEach, beforeEach, describe, it } = require('mocha'); - - -// describe('Do Vince test', function() { -// let app; -// let app2; -// this.timeout(60000); -// this.slow(15000); - -// beforeEach(async () => { -// await common.killallElectron(); -// await common.stopStubSnodeServer(); - -// const app1Props = { -// mnemonic: common.TEST_MNEMONIC1, -// displayName: common.TEST_DISPLAY_NAME1, -// stubSnode: true, -// }; - -// const app2Props = { -// mnemonic: common.TEST_MNEMONIC2, -// displayName: common.TEST_DISPLAY_NAME2, -// stubSnode: true, -// }; - -// [app, app2] = await Promise.all([ -// common.startAndStub(app1Props), -// common.startAndStub2(app2Props), -// ]); -// }); - -// afterEach(async () => { -// await common.stopApp(app); -// await common.killallElectron(); -// await common.stopStubSnodeServer(); -// }); - -// it('Can do first check', async () => { -// app = await common.startAndAssureCleanedApp(); -// return app; -// }); -// }); \ No newline at end of file