From 8bdc6cb9cf1576a242a2ec4dea1480adf478cec8 Mon Sep 17 00:00:00 2001 From: Emi Date: Tue, 28 Nov 2023 13:05:12 +0100 Subject: [PATCH 01/17] fix: handle paths with whitespaces --- packages/backend/src/nest/tor/tor.module.ts | 9 ++++++--- packages/backend/src/nest/tor/tor.service.ts | 5 ++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/backend/src/nest/tor/tor.module.ts b/packages/backend/src/nest/tor/tor.module.ts index f0024e7b49..09fb8b27e6 100644 --- a/packages/backend/src/nest/tor/tor.module.ts +++ b/packages/backend/src/nest/tor/tor.module.ts @@ -32,9 +32,12 @@ const torPasswordProvider = { useFactory: (torParamsProvider: TorParamsProvider) => { const password = crypto.randomBytes(16).toString('hex') if (!torParamsProvider.torPath) return null - const hashedPassword = child_process.execSync(`${torParamsProvider.torPath} --quiet --hash-password ${password}`, { - env: torParamsProvider.options?.env, - }) + const hashedPassword = child_process.execSync( + `"${torParamsProvider.torPath}" --quiet --hash-password ${password}`, + { + env: torParamsProvider.options?.env, + } + ) const torPassword = password const torHashedPassword = hashedPassword.toString().trim() diff --git a/packages/backend/src/nest/tor/tor.service.ts b/packages/backend/src/nest/tor/tor.service.ts index be7183103e..0cdf25550c 100644 --- a/packages/backend/src/nest/tor/tor.service.ts +++ b/packages/backend/src/nest/tor/tor.service.ts @@ -204,9 +204,8 @@ export class Tor extends EventEmitter implements OnModuleInit { reject(new Error("Can't spawn tor - no controlPort")) return } - this.process = child_process.spawn( - this.torParamsProvider.torPath, + `"${this.torParamsProvider.torPath}"`, [ '--SocksPort', this.socksPort.toString(), @@ -222,7 +221,7 @@ export class Tor extends EventEmitter implements OnModuleInit { this.torPasswordProvider.torHashedPassword, // ...this.torProcessParams ], - this.torParamsProvider.options + Object.assign(this.torParamsProvider.options, { shell: true }) ) this.process.stdout.on('data', (data: any) => { From e52adea3d0f27a60705c1faba5322d7fe096cf3f Mon Sep 17 00:00:00 2001 From: Emi Date: Tue, 28 Nov 2023 13:30:38 +0100 Subject: [PATCH 02/17] fix: handle paths with whitespaces --- packages/backend/src/nest/common/utils.ts | 2 +- packages/backend/src/nest/tor/tor.module.ts | 9 +++------ packages/backend/src/nest/tor/tor.service.ts | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/packages/backend/src/nest/common/utils.ts b/packages/backend/src/nest/common/utils.ts index 6b1b445486..9350fc5948 100644 --- a/packages/backend/src/nest/common/utils.ts +++ b/packages/backend/src/nest/common/utils.ts @@ -127,7 +127,7 @@ export const torBinForPlatform = (basePath = '', binName = 'tor'): string => { return basePath } const ext = process.platform === 'win32' ? '.exe' : '' - return path.join(torDirForPlatform(basePath), `${binName}`.concat(ext)) + return `"${path.join(torDirForPlatform(basePath), `${binName}`.concat(ext))}"` } export const torDirForPlatform = (basePath?: string): string => { diff --git a/packages/backend/src/nest/tor/tor.module.ts b/packages/backend/src/nest/tor/tor.module.ts index 09fb8b27e6..f0024e7b49 100644 --- a/packages/backend/src/nest/tor/tor.module.ts +++ b/packages/backend/src/nest/tor/tor.module.ts @@ -32,12 +32,9 @@ const torPasswordProvider = { useFactory: (torParamsProvider: TorParamsProvider) => { const password = crypto.randomBytes(16).toString('hex') if (!torParamsProvider.torPath) return null - const hashedPassword = child_process.execSync( - `"${torParamsProvider.torPath}" --quiet --hash-password ${password}`, - { - env: torParamsProvider.options?.env, - } - ) + const hashedPassword = child_process.execSync(`${torParamsProvider.torPath} --quiet --hash-password ${password}`, { + env: torParamsProvider.options?.env, + }) const torPassword = password const torHashedPassword = hashedPassword.toString().trim() diff --git a/packages/backend/src/nest/tor/tor.service.ts b/packages/backend/src/nest/tor/tor.service.ts index 0cdf25550c..98f102df5b 100644 --- a/packages/backend/src/nest/tor/tor.service.ts +++ b/packages/backend/src/nest/tor/tor.service.ts @@ -205,7 +205,7 @@ export class Tor extends EventEmitter implements OnModuleInit { return } this.process = child_process.spawn( - `"${this.torParamsProvider.torPath}"`, + `${this.torParamsProvider.torPath}`, [ '--SocksPort', this.socksPort.toString(), From 335677a999a47865209f4b6b5821fc4dc6c22e0c Mon Sep 17 00:00:00 2001 From: Emi Date: Tue, 28 Nov 2023 19:03:35 +0100 Subject: [PATCH 03/17] fix: e2e test for invitation link; chore: move DATA_DIR related statics to common package --- packages/backend/src/nest/app.module.ts | 2 +- packages/common/src/static.ts | 3 +++ packages/desktop/src/main/main.ts | 13 +++++++++---- packages/desktop/src/renderer/store/reducers.ts | 5 +++-- packages/desktop/src/shared/static.ts | 3 --- packages/e2e-tests/src/selectors.ts | 2 +- .../e2e-tests/src/tests/invitationLink.test.ts | 9 +++++---- packages/e2e-tests/src/utils.ts | 17 +++++++++++------ 8 files changed, 33 insertions(+), 21 deletions(-) diff --git a/packages/backend/src/nest/app.module.ts b/packages/backend/src/nest/app.module.ts index cf2fdc655d..03e987a178 100644 --- a/packages/backend/src/nest/app.module.ts +++ b/packages/backend/src/nest/app.module.ts @@ -127,7 +127,7 @@ export class AppModule { res.end() } }) - + console.log('ok') return { server, io } }, inject: [EXPRESS_PROVIDER], diff --git a/packages/common/src/static.ts b/packages/common/src/static.ts index 270bcdee89..8c297b4d10 100644 --- a/packages/common/src/static.ts +++ b/packages/common/src/static.ts @@ -1,3 +1,6 @@ +export const DESKTOP_DEV_DATA_DIR = 'Quietdev' +export const DESKTOP_DATA_DIR = 'Quiet2' + export enum Site { DOMAIN = 'tryquiet.org', MAIN_PAGE = 'https://tryquiet.org/', diff --git a/packages/desktop/src/main/main.ts b/packages/desktop/src/main/main.ts index 24174c5dd9..3e5ab64daa 100644 --- a/packages/desktop/src/main/main.ts +++ b/packages/desktop/src/main/main.ts @@ -9,9 +9,14 @@ import { getPorts, ApplicationPorts, closeHangingBackendProcess } from './backen import pkijs, { setEngine, CryptoEngine } from 'pkijs' import { Crypto } from '@peculiar/webcrypto' import logger from './logger' -import { DATA_DIR, DEV_DATA_DIR } from '../shared/static' import { fork, ChildProcess } from 'child_process' -import { argvInvitationCode, getFilesData, parseInvitationCodeDeepUrl } from '@quiet/common' +import { + DESKTOP_DATA_DIR, + DESKTOP_DEV_DATA_DIR, + argvInvitationCode, + getFilesData, + parseInvitationCodeDeepUrl, +} from '@quiet/common' import { updateDesktopFile, processInvitationCode } from './invitation' const ElectronStore = require('electron-store') ElectronStore.initRenderer() @@ -33,13 +38,13 @@ const webcrypto = new Crypto() global.crypto = webcrypto -let dataDir = DATA_DIR +let dataDir = DESKTOP_DATA_DIR let mainWindow: BrowserWindow | null let splash: BrowserWindow | null let invitationUrl: string | null if (isDev || process.env.DATA_DIR) { - dataDir = process.env.DATA_DIR || DEV_DATA_DIR + dataDir = process.env.DATA_DIR || DESKTOP_DEV_DATA_DIR } const appDataPath = path.join(app.getPath('appData'), dataDir) diff --git a/packages/desktop/src/renderer/store/reducers.ts b/packages/desktop/src/renderer/store/reducers.ts index d0cc10c344..14a778fcd0 100644 --- a/packages/desktop/src/renderer/store/reducers.ts +++ b/packages/desktop/src/renderer/store/reducers.ts @@ -25,13 +25,14 @@ import { navigationReducer } from './navigation/navigation.slice' import appHandlers from './handlers/app' -import { DEV_DATA_DIR } from '../../shared/static' import { Store } from '../sagas/store.types' +import { DESKTOP_DATA_DIR, DESKTOP_DEV_DATA_DIR } from '@quiet/common' const dataPath = process.env.APPDATA || (process.platform === 'darwin' ? process.env.HOME + '/Library/Application Support' : process.env.HOME + '/.config') -const appPath = process.env.DATA_DIR || (process.env.NODE_ENV === 'development' ? DEV_DATA_DIR : 'Quiet') +const appPath = + process.env.DATA_DIR || (process.env.NODE_ENV === 'development' ? DESKTOP_DEV_DATA_DIR : DESKTOP_DATA_DIR) const options = { projectName: 'quiet', diff --git a/packages/desktop/src/shared/static.ts b/packages/desktop/src/shared/static.ts index b0a95acfd7..c0cca57906 100644 --- a/packages/desktop/src/shared/static.ts +++ b/packages/desktop/src/shared/static.ts @@ -1,8 +1,5 @@ import mirrorKey from 'keymirror' -export const DEV_DATA_DIR = 'Quietdev' -export const DATA_DIR = 'Quiet2' - export const actionTypes = mirrorKey({ SET_APP_VERSION: undefined, }) diff --git a/packages/e2e-tests/src/selectors.ts b/packages/e2e-tests/src/selectors.ts index a6b2b69ef0..5aae3c79bd 100644 --- a/packages/e2e-tests/src/selectors.ts +++ b/packages/e2e-tests/src/selectors.ts @@ -445,7 +445,7 @@ export class DebugModeModal { const log = await this.driver.executeScript('arguments[0].click();', button) console.log('executeScript', log) } catch (e) { - console.log('Probably click properly close modal') + console.log('Probably clicked hidden close button on debug modal', e) } await new Promise(resolve => setTimeout(() => resolve(), 2000)) } diff --git a/packages/e2e-tests/src/tests/invitationLink.test.ts b/packages/e2e-tests/src/tests/invitationLink.test.ts index 8956672981..e4c8d95d97 100644 --- a/packages/e2e-tests/src/tests/invitationLink.test.ts +++ b/packages/e2e-tests/src/tests/invitationLink.test.ts @@ -3,13 +3,12 @@ import { CreateCommunityModal, DebugModeModal, JoinCommunityModal, - JoiningLoadingPanel, RegisterUsernameModal, App, Sidebar, WarningModal, } from '../selectors' -import { capitalizeFirstLetter, composeInvitationDeepUrl, parseInvitationCode, userJoinedMessage } from '@quiet/common' +import { composeInvitationDeepUrl, parseInvitationCode, userJoinedMessage } from '@quiet/common' import { execSync } from 'child_process' import { type SupportedPlatformDesktop } from '@quiet/types' @@ -26,7 +25,7 @@ describe('New user joins using invitation link while having app opened', () => { beforeAll(async () => { ownerApp = new App() - guestApp = new App({ useDataDir: false }) + guestApp = new App({ defaultDataDir: true }) }) beforeEach(async () => { @@ -141,7 +140,9 @@ describe('New user joins using invitation link while having app opened', () => { const copiedCode = url.hash.substring(1) expect(() => parseInvitationCode(copiedCode)).not.toThrow() const data = parseInvitationCode(copiedCode) - execSync(`${command[process.platform as SupportedPlatformDesktop]} "${composeInvitationDeepUrl(data)}"`) + const commandFull = `${command[process.platform as SupportedPlatformDesktop]} "${composeInvitationDeepUrl(data)}"` + console.log(`Calling ${commandFull}`) + execSync(commandFull) console.log('Guest opened invitation link') }) diff --git a/packages/e2e-tests/src/utils.ts b/packages/e2e-tests/src/utils.ts index e424d9b6f8..add72edeba 100644 --- a/packages/e2e-tests/src/utils.ts +++ b/packages/e2e-tests/src/utils.ts @@ -4,11 +4,12 @@ import { type SupportedPlatformDesktop } from '@quiet/types' import getPort from 'get-port' import path from 'path' import fs from 'fs' +import { DESKTOP_DATA_DIR } from '@quiet/common' export interface BuildSetupInit { port?: number debugPort?: number - useDataDir?: boolean + defaultDataDir?: boolean dataDir?: string fileName?: string } @@ -19,19 +20,20 @@ export class BuildSetup { public debugPort?: number public dataDir?: string private child?: ChildProcessWithoutNullStreams - private useDataDir: boolean + private defaultDataDir: boolean private fileName?: string - constructor({ port, debugPort, useDataDir = true, dataDir, fileName }: BuildSetupInit) { + constructor({ port, debugPort, defaultDataDir = false, dataDir, fileName }: BuildSetupInit) { this.port = port this.debugPort = debugPort - this.useDataDir = useDataDir + this.defaultDataDir = defaultDataDir this.dataDir = dataDir this.fileName = fileName if (fileName) { this.copyInstallerFile(fileName) } - if (this.useDataDir && !this.dataDir) { + if (this.defaultDataDir) this.dataDir = DESKTOP_DATA_DIR + if (!this.dataDir) { this.dataDir = `e2e_${(Math.random() * 10 ** 18).toString(36)}` } } @@ -100,9 +102,12 @@ export class BuildSetup { public async createChromeDriver() { await this.initPorts() const env = { - DATA_DIR: this.dataDir || 'Quiet', DEBUG: 'backend*,desktop*,utils*', + DATA_DIR: this.dataDir, } + // if (this.dataDir) { + // env = Object.assign(env, { DATA_DIR: this.dataDir }) + // } if (process.platform === 'win32') { console.log('!WINDOWS!') this.child = spawn(`cd node_modules/.bin & chromedriver.cmd --port=${this.port} --verbose`, [], { From 4c7387a645020a985ea965b088e8a9edf45b72ff Mon Sep 17 00:00:00 2001 From: Vin Kabuki Date: Wed, 29 Nov 2023 13:15:30 +0100 Subject: [PATCH 04/17] fix: mock torHashedPassword in tests --- .../connections-manager.service.tor.spec.ts | 2 +- packages/backend/src/nest/tor/tor.service.tor.spec.ts | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/nest/connections-manager/connections-manager.service.tor.spec.ts b/packages/backend/src/nest/connections-manager/connections-manager.service.tor.spec.ts index d2b9f28bd7..36424a1ff2 100644 --- a/packages/backend/src/nest/connections-manager/connections-manager.service.tor.spec.ts +++ b/packages/backend/src/nest/connections-manager/connections-manager.service.tor.spec.ts @@ -80,7 +80,7 @@ beforeEach(async () => { ], }) .overrideProvider(TOR_PASSWORD_PROVIDER) - .useValue({ torPassword: '', torHashedPassword: '' }) + .useValue({ torPassword: 'b5e447c10b0d99e7871636ee5e0839b5', torHashedPassword: '16:FCFFE21F3D9138906021FAADD9E49703CC41848A95F829E0F6E1BDBE63' }) .compile() connectionsManagerService = await module.resolve(ConnectionsManagerService) diff --git a/packages/backend/src/nest/tor/tor.service.tor.spec.ts b/packages/backend/src/nest/tor/tor.service.tor.spec.ts index 59e188463b..e2ec0706d9 100644 --- a/packages/backend/src/nest/tor/tor.service.tor.spec.ts +++ b/packages/backend/src/nest/tor/tor.service.tor.spec.ts @@ -19,7 +19,9 @@ describe('TorControl', () => { let tmpDir: DirResult let tmpAppDataPath: string - const torPassword = crypto.randomBytes(16).toString('hex') + const torPassword = 'b5e447c10b0d99e7871636ee5e0839b5' + const torHashedPassword = '16:FCFFE21F3D9138906021FAADD9E49703CC41848A95F829E0F6E1BDBE63' + beforeEach(async () => { jest.clearAllMocks() @@ -29,7 +31,7 @@ describe('TorControl', () => { imports: [TestModule, TorModule], }) .overrideProvider(TOR_PASSWORD_PROVIDER) - .useValue({ torPassword: torPassword, torHashedPassword: '' }) + .useValue({ torPassword, torHashedPassword }) .overrideProvider(TOR_PARAMS_PROVIDER) .useValue({ torPath: torBinForPlatform(), From f44011725ac0a9d2012632c25d5b2c837cb3b216 Mon Sep 17 00:00:00 2001 From: Emi Date: Tue, 5 Dec 2023 12:06:53 +0100 Subject: [PATCH 05/17] fix: wrap tor path in double quotes to handle spaces in path; spawn tor in shell; kill group of processes (shell: true spawns 2 processes) --- .../backend/src/nest/common/test.module.ts | 4 +-- packages/backend/src/nest/common/utils.ts | 21 ++++++++++- .../connections-manager.service.tor.spec.ts | 5 ++- packages/backend/src/nest/tor/tor.service.ts | 36 +++++++++++++------ packages/e2e-tests/src/utils.ts | 3 -- 5 files changed, 50 insertions(+), 19 deletions(-) diff --git a/packages/backend/src/nest/common/test.module.ts b/packages/backend/src/nest/common/test.module.ts index 12e79c308c..d653c1228c 100644 --- a/packages/backend/src/nest/common/test.module.ts +++ b/packages/backend/src/nest/common/test.module.ts @@ -25,11 +25,9 @@ import { createTmpDir, getCors, torBinForPlatform, torDirForPlatform } from './u const torPath = torBinForPlatform() const libPath = torDirForPlatform() -// torBinaryPath: '../../../../../3rd-party/tor/linux/tor', -// torResourcesPath: '../../../../../3rd-party/tor/linux', export const defaultConfigForTest = { socketIOPort: TEST_DATA_PORT, - torBinaryPath: torBinForPlatform(), + torBinaryPath: torPath, torResourcesPath: torPath, torControlPort: await getPort(), options: { diff --git a/packages/backend/src/nest/common/utils.ts b/packages/backend/src/nest/common/utils.ts index 9350fc5948..10c32c9456 100644 --- a/packages/backend/src/nest/common/utils.ts +++ b/packages/backend/src/nest/common/utils.ts @@ -6,7 +6,7 @@ import { UserData } from '@quiet/types' import createHttpsProxyAgent from 'https-proxy-agent' import PeerId from 'peer-id' import tmp from 'tmp' -import crypto from 'crypto' +import crypto, { sign } from 'crypto' import { type PermsData } from '@quiet/types' import { TestConfig } from '../const' import logger from './logger' @@ -14,6 +14,7 @@ import { Libp2pNodeParams } from '../libp2p/libp2p.types' import { createLibp2pAddress, createLibp2pListenAddress, isDefined } from '@quiet/common' import { Libp2pService } from '../libp2p/libp2p.service' import { CertFieldsTypes, getReqFieldValue, loadCSR } from '@quiet/identity' +import { exec } from 'child_process' const log = logger('test') @@ -249,3 +250,21 @@ export async function createPeerId(): Promise { const peerId = await PeerId.create() return peerIdFromKeys(peerId.marshalPubKey(), peerId.marshalPrivKey()) } + +export function killAll(pid: number, signal: string | number = 'SIGTERM') { + // Kills group of processes + console.log(`Killing processes group with pid ${pid}. Signal: ${signal}`) + if (process.platform == 'win32') { + exec(`taskkill /PID ${pid} /T /F`, (error, stdout, stderr) => { + console.log('taskkill stdout: ' + stdout) + console.log('taskkill stderr: ' + stderr) + if (error) { + console.log('error: ' + error.message) + } + }) + } else { + // see https://nodejs.org/api/child_process.html#child_process_options_detached + // If pid is less than -1, then sig is sent to every process in the process group whose ID is -pid. + process.kill(-pid, signal) + } +} diff --git a/packages/backend/src/nest/connections-manager/connections-manager.service.tor.spec.ts b/packages/backend/src/nest/connections-manager/connections-manager.service.tor.spec.ts index 36424a1ff2..7302b54b52 100644 --- a/packages/backend/src/nest/connections-manager/connections-manager.service.tor.spec.ts +++ b/packages/backend/src/nest/connections-manager/connections-manager.service.tor.spec.ts @@ -80,7 +80,10 @@ beforeEach(async () => { ], }) .overrideProvider(TOR_PASSWORD_PROVIDER) - .useValue({ torPassword: 'b5e447c10b0d99e7871636ee5e0839b5', torHashedPassword: '16:FCFFE21F3D9138906021FAADD9E49703CC41848A95F829E0F6E1BDBE63' }) + .useValue({ + torPassword: 'b5e447c10b0d99e7871636ee5e0839b5', + torHashedPassword: '16:FCFFE21F3D9138906021FAADD9E49703CC41848A95F829E0F6E1BDBE63', + }) .compile() connectionsManagerService = await module.resolve(ConnectionsManagerService) diff --git a/packages/backend/src/nest/tor/tor.service.ts b/packages/backend/src/nest/tor/tor.service.ts index 66dea78194..2ac93c45e0 100644 --- a/packages/backend/src/nest/tor/tor.service.ts +++ b/packages/backend/src/nest/tor/tor.service.ts @@ -1,11 +1,10 @@ import * as child_process from 'child_process' -import crypto from 'crypto' import * as fs from 'fs' import path from 'path' import getPort from 'get-port' -import { removeFilesFromDir } from '../common/utils' +import { killAll, removeFilesFromDir } from '../common/utils' import { EventEmitter } from 'events' -import { ConnectionProcessInfo, SocketActionTypes, SupportedPlatform } from '@quiet/types' +import { SocketActionTypes, SupportedPlatform } from '@quiet/types' import { Inject, OnModuleInit } from '@nestjs/common' import { ConfigOptions, ServerIoProviderTypes } from '../types' import { CONFIG_OPTIONS, QUIET_DIR, SERVER_IO_PROVIDER, TOR_PARAMS_PROVIDER, TOR_PASSWORD_PROVIDER } from '../const' @@ -16,7 +15,7 @@ import Logger from '../common/logger' export class Tor extends EventEmitter implements OnModuleInit { socksPort: number - process: child_process.ChildProcessWithoutNullStreams | any = null + process: child_process.ChildProcessWithoutNullStreams | null = null torDataDirectory: string torPidPath: string extraTorProcessParams: TorParams @@ -93,7 +92,7 @@ export class Tor extends EventEmitter implements OnModuleInit { try { this.clearHangingTorProcess() } catch (e) { - this.logger('Error occured while trying to clear hanging tor processes') + this.logger('Error occured while trying to clear hanging tor processes', e) } try { @@ -113,7 +112,7 @@ export class Tor extends EventEmitter implements OnModuleInit { resolve() } catch { this.logger('Killing tor') - await this.process.kill() + this.process?.pid && killAll(this.process?.pid) removeFilesFromDir(this.torDataDirectory) // eslint-disable-next-line @@ -161,7 +160,7 @@ export class Tor extends EventEmitter implements OnModuleInit { if (!torProcessId) return this.logger(`Found tor process with pid ${torProcessId}. Killing...`) try { - process.kill(Number(torProcessId), 'SIGTERM') + killAll(Number(torProcessId)) } catch (e) { this.logger.error(`Tried killing hanging tor process. Failed. Reason: ${e.message}`) } @@ -204,8 +203,12 @@ export class Tor extends EventEmitter implements OnModuleInit { reject(new Error("Can't spawn tor - no controlPort")) return } + const options: child_process.SpawnOptionsWithoutStdio = { + ...this.torParamsProvider.options, + shell: true, + } this.process = child_process.spawn( - `${this.torParamsProvider.torPath}`, + this.torParamsProvider.torPath, [ '--SocksPort', this.socksPort.toString(), @@ -221,8 +224,19 @@ export class Tor extends EventEmitter implements OnModuleInit { this.torPasswordProvider.torHashedPassword, // ...this.torProcessParams ], - Object.assign(this.torParamsProvider.options, { shell: true }) + options ) + this.process.stderr.on('data', e => { + this.logger.error('Tor process. Stderr:', e) + }) + + this.process.on('exit', (code, signal) => { + this.logger(`Tor exited with code ${code} and signal ${signal}`) + }) + + this.process.on('error', err => { + this.logger.error(`Tor process. Error occurred: ${err.message}`) + }) this.process.stdout.on('data', (data: any) => { this.logger(data.toString()) @@ -321,7 +335,7 @@ export class Tor extends EventEmitter implements OnModuleInit { public async kill(): Promise { return await new Promise((resolve, reject) => { - this.logger('Killing tor...') + this.logger('Killing tor... with pid', this.process?.pid) if (this.process === null) { this.logger('TOR: Process is not initalized.') resolve() @@ -337,7 +351,7 @@ export class Tor extends EventEmitter implements OnModuleInit { this.process?.on('error', () => { reject(new Error('TOR: Something went wrong with killing tor process')) }) - this.process?.kill() + this.process?.pid && killAll(this.process?.pid) }) } } diff --git a/packages/e2e-tests/src/utils.ts b/packages/e2e-tests/src/utils.ts index add72edeba..1abe46ec1d 100644 --- a/packages/e2e-tests/src/utils.ts +++ b/packages/e2e-tests/src/utils.ts @@ -105,9 +105,6 @@ export class BuildSetup { DEBUG: 'backend*,desktop*,utils*', DATA_DIR: this.dataDir, } - // if (this.dataDir) { - // env = Object.assign(env, { DATA_DIR: this.dataDir }) - // } if (process.platform === 'win32') { console.log('!WINDOWS!') this.child = spawn(`cd node_modules/.bin & chromedriver.cmd --port=${this.port} --verbose`, [], { From 6a1ed7b81f2ba0d454fe657bd67d68e89bc3427c Mon Sep 17 00:00:00 2001 From: Emi Date: Tue, 5 Dec 2023 12:18:12 +0100 Subject: [PATCH 06/17] fix: change exec to execFile for killing process on windows --- packages/backend/src/nest/common/utils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/nest/common/utils.ts b/packages/backend/src/nest/common/utils.ts index 10c32c9456..cc5d3ffb70 100644 --- a/packages/backend/src/nest/common/utils.ts +++ b/packages/backend/src/nest/common/utils.ts @@ -14,7 +14,7 @@ import { Libp2pNodeParams } from '../libp2p/libp2p.types' import { createLibp2pAddress, createLibp2pListenAddress, isDefined } from '@quiet/common' import { Libp2pService } from '../libp2p/libp2p.service' import { CertFieldsTypes, getReqFieldValue, loadCSR } from '@quiet/identity' -import { exec } from 'child_process' +import { execFile } from 'child_process' const log = logger('test') @@ -255,7 +255,7 @@ export function killAll(pid: number, signal: string | number = 'SIGTERM') { // Kills group of processes console.log(`Killing processes group with pid ${pid}. Signal: ${signal}`) if (process.platform == 'win32') { - exec(`taskkill /PID ${pid} /T /F`, (error, stdout, stderr) => { + execFile('taskkill /PID ' + pid + ' /T /F', (error, stdout, stderr) => { console.log('taskkill stdout: ' + stdout) console.log('taskkill stderr: ' + stderr) if (error) { From 563347054e4d79ae4dfd60f21ff44fb3c78f3fbe Mon Sep 17 00:00:00 2001 From: Emi Date: Tue, 5 Dec 2023 12:22:43 +0100 Subject: [PATCH 07/17] chore: update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4494171320..b6bcab367d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +[unreleased] + +* Handle spaces in tor process path. Run tor process in shell + [2.0.3-alpha.12] * Better descriptions of the joining process From e7bb7e63b8747801e7e17b74252eaa71a47fbd7c Mon Sep 17 00:00:00 2001 From: Emi Date: Tue, 5 Dec 2023 16:06:12 +0100 Subject: [PATCH 08/17] chore: debug e2e tests --- packages/backend/src/nest/tor/tor.service.ts | 39 ++++++++++--------- .../e2e-tests/src/tests/oneClient.test.ts | 2 +- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/packages/backend/src/nest/tor/tor.service.ts b/packages/backend/src/nest/tor/tor.service.ts index 2ac93c45e0..abd780f768 100644 --- a/packages/backend/src/nest/tor/tor.service.ts +++ b/packages/backend/src/nest/tor/tor.service.ts @@ -207,25 +207,26 @@ export class Tor extends EventEmitter implements OnModuleInit { ...this.torParamsProvider.options, shell: true, } - this.process = child_process.spawn( - this.torParamsProvider.torPath, - [ - '--SocksPort', - this.socksPort.toString(), - '--HTTPTunnelPort', - this.configOptions.httpTunnelPort?.toString(), - '--ControlPort', - this.controlPort.toString(), - '--PidFile', - this.torPidPath, - '--DataDirectory', - this.torDataDirectory, - '--HashedControlPassword', - this.torPasswordProvider.torHashedPassword, - // ...this.torProcessParams - ], - options - ) + const args = [ + '--SocksPort', + this.socksPort.toString(), + '--HTTPTunnelPort', + this.configOptions.httpTunnelPort?.toString(), + '--ControlPort', + this.controlPort.toString(), + '--PidFile', + this.torPidPath, + '--DataDirectory', + this.torDataDirectory, + '--HashedControlPassword', + this.torPasswordProvider.torHashedPassword, + // ...this.torProcessParams + ] + console.log('TOR ARGS', args) + console.log('TOR options', options) + console.log('TOR path', this.torParamsProvider.torPath) + console.log('TOR pid', this.process?.pid) + this.process = child_process.spawn(this.torParamsProvider.torPath, args, options) this.process.stderr.on('data', e => { this.logger.error('Tor process. Stderr:', e) }) diff --git a/packages/e2e-tests/src/tests/oneClient.test.ts b/packages/e2e-tests/src/tests/oneClient.test.ts index 090f268708..fe1828e63c 100644 --- a/packages/e2e-tests/src/tests/oneClient.test.ts +++ b/packages/e2e-tests/src/tests/oneClient.test.ts @@ -64,7 +64,7 @@ describe('One Client', () => { await registerModal.submit() }) - it('User waits for the modal JoiningLoadingPanel to disappear', async () => { + it.skip('User waits for the modal JoiningLoadingPanel to disappear', async () => { const loadingPanelCommunity = new JoiningLoadingPanel(app.driver) const isLoadingPanelCommunity = await loadingPanelCommunity.element.isDisplayed() expect(isLoadingPanelCommunity).toBeTruthy() From 8340e508566afd5d74668d58927e9342a0ae819d Mon Sep 17 00:00:00 2001 From: Emi Date: Wed, 6 Dec 2023 10:52:31 +0100 Subject: [PATCH 09/17] fix: wrap tor arguments in quotation marks if they're path --- packages/backend/src/nest/tor/tor.service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/nest/tor/tor.service.ts b/packages/backend/src/nest/tor/tor.service.ts index abd780f768..753ef955c3 100644 --- a/packages/backend/src/nest/tor/tor.service.ts +++ b/packages/backend/src/nest/tor/tor.service.ts @@ -215,9 +215,9 @@ export class Tor extends EventEmitter implements OnModuleInit { '--ControlPort', this.controlPort.toString(), '--PidFile', - this.torPidPath, + `"${this.torPidPath}"`, '--DataDirectory', - this.torDataDirectory, + `"${this.torDataDirectory}"`, '--HashedControlPassword', this.torPasswordProvider.torHashedPassword, // ...this.torProcessParams From f111fa9112eb0e34a7046fdec6c89a63d4b794c9 Mon Sep 17 00:00:00 2001 From: Emi Date: Wed, 6 Dec 2023 14:04:28 +0100 Subject: [PATCH 10/17] fix: killing hanging tor processes --- packages/backend/src/nest/tor/tor.service.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/nest/tor/tor.service.ts b/packages/backend/src/nest/tor/tor.service.ts index 753ef955c3..c13e5ff38e 100644 --- a/packages/backend/src/nest/tor/tor.service.ts +++ b/packages/backend/src/nest/tor/tor.service.ts @@ -158,9 +158,10 @@ export class Tor extends EventEmitter implements OnModuleInit { public clearHangingTorProcess() { const torProcessId = child_process.execSync(this.hangingTorProcessCommand()).toString('utf8').trim() if (!torProcessId) return - this.logger(`Found tor process with pid ${torProcessId}. Killing...`) + const ids = torProcessId.split('\n') // Spawning with {shell:true} starts 2 processes + this.logger(`Found tor process(es) with pid(s) ${ids}. Killing...`) try { - killAll(Number(torProcessId)) + killAll(Number(ids[0].trim())) } catch (e) { this.logger.error(`Tried killing hanging tor process. Failed. Reason: ${e.message}`) } @@ -352,7 +353,7 @@ export class Tor extends EventEmitter implements OnModuleInit { this.process?.on('error', () => { reject(new Error('TOR: Something went wrong with killing tor process')) }) - this.process?.pid && killAll(this.process?.pid) + // this.process?.pid && killAll(this.process?.pid) }) } } From 6bed943b871322aa68c2ebe12b6c6c0b75bc2197 Mon Sep 17 00:00:00 2001 From: Emi Date: Wed, 6 Dec 2023 17:18:16 +0100 Subject: [PATCH 11/17] test: add logs for debugging purposes --- packages/e2e-tests/src/tests/oneClient.test.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/e2e-tests/src/tests/oneClient.test.ts b/packages/e2e-tests/src/tests/oneClient.test.ts index fe1828e63c..8091fb0b77 100644 --- a/packages/e2e-tests/src/tests/oneClient.test.ts +++ b/packages/e2e-tests/src/tests/oneClient.test.ts @@ -60,8 +60,11 @@ describe('One Client', () => { const isRegisterModal = await registerModal.element.isDisplayed() expect(isRegisterModal).toBeTruthy() + console.log('Registration - vefore typeUsername') await registerModal.typeUsername('testuser') + console.log('Registration - before submit') await registerModal.submit() + console.log('Registration - after submit') }) it.skip('User waits for the modal JoiningLoadingPanel to disappear', async () => { @@ -71,9 +74,14 @@ describe('One Client', () => { }) it('User sees general channel', async () => { + console.log('User sees general channel - test start') + console.log('PAGE SOURCE', await app.driver.getPageSource()) const generalChannel = new Channel(app.driver, 'general') + console.log('User sees general channel - generalChannel') const isGeneralChannel = await generalChannel.element.isDisplayed() + console.log('User sees general channel - isGeneralChannel', isGeneralChannel) const generalChannelText = await generalChannel.element.getText() + console.log('User sees general channel - generalChannelText', generalChannelText) expect(isGeneralChannel).toBeTruthy() expect(generalChannelText).toEqual('# general') }) From 903760edeab37b3283b4bcd2c924ea97a1bcbe7f Mon Sep 17 00:00:00 2001 From: Emi Date: Tue, 23 Jan 2024 17:43:35 +0100 Subject: [PATCH 12/17] test: check if spawning tor needs detached mode --- packages/backend/src/nest/tor/tor.module.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend/src/nest/tor/tor.module.ts b/packages/backend/src/nest/tor/tor.module.ts index f0024e7b49..576a54ec27 100644 --- a/packages/backend/src/nest/tor/tor.module.ts +++ b/packages/backend/src/nest/tor/tor.module.ts @@ -19,7 +19,7 @@ const torParamsProvider = { LD_LIBRARY_PATH: configOptions.torResourcesPath, HOME: os.homedir(), }, - detached: true, + // detached: true, // TODO: check if this is needed } return { torPath, options } From d53493288a719c698c73060158cf1122b49dfc9e Mon Sep 17 00:00:00 2001 From: Emi Date: Wed, 24 Jan 2024 16:16:57 +0100 Subject: [PATCH 13/17] chore: debug --- .github/workflows/e2e-linux.yml | 13 +++++++++++++ .../messages/verifyMessage/verifyMessages.saga.ts | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/.github/workflows/e2e-linux.yml b/.github/workflows/e2e-linux.yml index 45dada8bbc..d4ec27d9bf 100644 --- a/.github/workflows/e2e-linux.yml +++ b/.github/workflows/e2e-linux.yml @@ -46,6 +46,19 @@ jobs: working-directory: ./packages/e2e-tests/Quiet run: chmod +x $FILE_NAME + - name: Extract version + id: extract_version + uses: Saionaro/extract-package-version@v1.2.1 + with: + path: packages/desktop + + - name: "Upload built app" + uses: actions/upload-artifact@v3 + with: + name: quiet-linux + path: ./packages/desktop/dist/Quiet-${{ steps.extract_version.outputs.version }}.AppImage + retention-days: 2 + - name: Run one client test uses: nick-fields/retry@v2 with: diff --git a/packages/state-manager/src/sagas/messages/verifyMessage/verifyMessages.saga.ts b/packages/state-manager/src/sagas/messages/verifyMessage/verifyMessages.saga.ts index c7b767f028..1a8dac2c05 100644 --- a/packages/state-manager/src/sagas/messages/verifyMessage/verifyMessages.saga.ts +++ b/packages/state-manager/src/sagas/messages/verifyMessage/verifyMessages.saga.ts @@ -22,6 +22,8 @@ export function* verifyMessagesSaga( yield* delay(500) } + console.log('verifyMessagesSaga messages', messages) + for (const message of messages) { let isVerified = Boolean(action.payload.isVerified) @@ -40,6 +42,8 @@ export function* verifyMessagesSaga( const expectedMessage = yield* call(verifyUserInfoMessage, user.username, channel) + console.log('verifyMessagesSaga expectedMessage', expectedMessage) + console.log('verifyMessagesSaga message.message', message.message) if (message.message !== expectedMessage) { console.error(`${user.username} tried to send a malicious info message`) isVerified = false From 8857f7b551661dcf6a962ecb3e2afd61327c3968 Mon Sep 17 00:00:00 2001 From: Emi Date: Thu, 25 Jan 2024 14:17:48 +0100 Subject: [PATCH 14/17] fix: kill tor processes properly; cleanup changelog --- CHANGELOG.md | 11 ++++++----- packages/backend/src/nest/common/utils.ts | 19 +------------------ .../src/nest/tor/tor.service.tor.spec.ts | 4 ++-- packages/backend/src/nest/tor/tor.service.ts | 17 ++++++++++------- 4 files changed, 19 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d76d0c3cd..d4993c6b71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ -[2.1.0] - unreleased +[Unreleased] + +* Handle spaces in tor process path. Run tor process in shell + +[2.0.1] * refactor: Remove SAVE_OWNER_CERTIFICATE event @@ -21,6 +25,7 @@ * Ask push notifications runtime permission on Android app start * Fix for multiplicating "welcome" messages when joining a community + * Fix: base jdenticon on pubkey instead of username - this way unregistered user with duplicated username will have different profile image * Updated old logo of Linux and Windows with rounded ones @@ -68,10 +73,6 @@ [2.0.3-alpha.16] -* Handle spaces in tor process path. Run tor process in shell - -[2.0.3-alpha.16] - * Fix: mobile app crashing on restart * Refactor: backend, storage module - extracting OrbitDB as another provider, refactor of CertificatesRequestsStore, CommunityMetadataStore, CertificatesStore as Nest providers, store tests adjustments, file structure diff --git a/packages/backend/src/nest/common/utils.ts b/packages/backend/src/nest/common/utils.ts index cc5d3ffb70..d2dc00e184 100644 --- a/packages/backend/src/nest/common/utils.ts +++ b/packages/backend/src/nest/common/utils.ts @@ -128,6 +128,7 @@ export const torBinForPlatform = (basePath = '', binName = 'tor'): string => { return basePath } const ext = process.platform === 'win32' ? '.exe' : '' + // Wrap path in quotes to handle spaces in path return `"${path.join(torDirForPlatform(basePath), `${binName}`.concat(ext))}"` } @@ -250,21 +251,3 @@ export async function createPeerId(): Promise { const peerId = await PeerId.create() return peerIdFromKeys(peerId.marshalPubKey(), peerId.marshalPrivKey()) } - -export function killAll(pid: number, signal: string | number = 'SIGTERM') { - // Kills group of processes - console.log(`Killing processes group with pid ${pid}. Signal: ${signal}`) - if (process.platform == 'win32') { - execFile('taskkill /PID ' + pid + ' /T /F', (error, stdout, stderr) => { - console.log('taskkill stdout: ' + stdout) - console.log('taskkill stderr: ' + stderr) - if (error) { - console.log('error: ' + error.message) - } - }) - } else { - // see https://nodejs.org/api/child_process.html#child_process_options_detached - // If pid is less than -1, then sig is sent to every process in the process group whose ID is -pid. - process.kill(-pid, signal) - } -} diff --git a/packages/backend/src/nest/tor/tor.service.tor.spec.ts b/packages/backend/src/nest/tor/tor.service.tor.spec.ts index e2ec0706d9..eaf6fa88ae 100644 --- a/packages/backend/src/nest/tor/tor.service.tor.spec.ts +++ b/packages/backend/src/nest/tor/tor.service.tor.spec.ts @@ -9,9 +9,10 @@ import { type DirResult } from 'tmp' import { jest } from '@jest/globals' import { TorControlAuthType } from './tor.types' import { TorControl } from './tor-control.service' -import crypto from 'crypto' import { sleep } from '../common/sleep' + jest.setTimeout(200_000) + describe('TorControl', () => { let module: TestingModule let torService: Tor @@ -22,7 +23,6 @@ describe('TorControl', () => { const torPassword = 'b5e447c10b0d99e7871636ee5e0839b5' const torHashedPassword = '16:FCFFE21F3D9138906021FAADD9E49703CC41848A95F829E0F6E1BDBE63' - beforeEach(async () => { jest.clearAllMocks() tmpDir = createTmpDir() diff --git a/packages/backend/src/nest/tor/tor.service.ts b/packages/backend/src/nest/tor/tor.service.ts index f26b139b78..0e3dd2140c 100644 --- a/packages/backend/src/nest/tor/tor.service.ts +++ b/packages/backend/src/nest/tor/tor.service.ts @@ -2,7 +2,7 @@ import * as child_process from 'child_process' import * as fs from 'fs' import path from 'path' import getPort from 'get-port' -import { killAll, removeFilesFromDir } from '../common/utils' +import { removeFilesFromDir } from '../common/utils' import { EventEmitter } from 'events' import { SocketActionTypes, SupportedPlatform } from '@quiet/types' import { Inject, OnModuleInit } from '@nestjs/common' @@ -112,7 +112,7 @@ export class Tor extends EventEmitter implements OnModuleInit { resolve() } catch { this.logger('Killing tor') - this.process?.pid && killAll(this.process?.pid) + this.clearHangingTorProcess() removeFilesFromDir(this.torDataDirectory) // eslint-disable-next-line @@ -160,10 +160,13 @@ export class Tor extends EventEmitter implements OnModuleInit { if (!torProcessId) return const ids = torProcessId.split('\n') // Spawning with {shell:true} starts 2 processes this.logger(`Found tor process(es) with pid(s) ${ids}. Killing...`) - try { - killAll(Number(ids[0].trim())) - } catch (e) { - this.logger.error(`Tried killing hanging tor process. Failed. Reason: ${e.message}`) + + for (const id of ids) { + try { + process.kill(Number(id.trim())) + } catch (e) { + this.logger.error(`Tried killing hanging tor process with id ${id}. Failed. Reason: ${e.message}`) + } } } @@ -357,7 +360,7 @@ export class Tor extends EventEmitter implements OnModuleInit { this.process?.on('error', () => { reject(new Error('TOR: Something went wrong with killing tor process')) }) - // this.process?.pid && killAll(this.process?.pid) + this.clearHangingTorProcess() }) } } From a4358f71f6a25ae3dac313e7e05e2d2e152d7fcb Mon Sep 17 00:00:00 2001 From: Emi Date: Thu, 25 Jan 2024 14:24:43 +0100 Subject: [PATCH 15/17] chore: cleanup --- packages/backend/src/nest/tor/tor.service.ts | 40 +++++++++---------- .../e2e-tests/src/tests/oneClient.test.ts | 5 --- .../verifyMessage/verifyMessages.saga.ts | 4 -- 3 files changed, 20 insertions(+), 29 deletions(-) diff --git a/packages/backend/src/nest/tor/tor.service.ts b/packages/backend/src/nest/tor/tor.service.ts index 0e3dd2140c..ff1f1fce0a 100644 --- a/packages/backend/src/nest/tor/tor.service.ts +++ b/packages/backend/src/nest/tor/tor.service.ts @@ -211,26 +211,26 @@ export class Tor extends EventEmitter implements OnModuleInit { ...this.torParamsProvider.options, shell: true, } - const args = [ - '--SocksPort', - this.socksPort.toString(), - '--HTTPTunnelPort', - this.configOptions.httpTunnelPort?.toString(), - '--ControlPort', - this.controlPort.toString(), - '--PidFile', - `"${this.torPidPath}"`, - '--DataDirectory', - `"${this.torDataDirectory}"`, - '--HashedControlPassword', - this.torPasswordProvider.torHashedPassword, - // ...this.torProcessParams - ] - console.log('TOR ARGS', args) - console.log('TOR options', options) - console.log('TOR path', this.torParamsProvider.torPath) - console.log('TOR pid', this.process?.pid) - this.process = child_process.spawn(this.torParamsProvider.torPath, args, options) + + this.process = child_process.spawn( + this.torParamsProvider.torPath, + [ + '--SocksPort', + this.socksPort.toString(), + '--HTTPTunnelPort', + this.configOptions.httpTunnelPort?.toString(), + '--ControlPort', + this.controlPort.toString(), + '--PidFile', + `"${this.torPidPath}"`, + '--DataDirectory', + `"${this.torDataDirectory}"`, + '--HashedControlPassword', + this.torPasswordProvider.torHashedPassword, + // ...this.torProcessParams + ], + options + ) this.process.stderr.on('data', e => { this.logger.error('Tor process. Stderr:', e) }) diff --git a/packages/e2e-tests/src/tests/oneClient.test.ts b/packages/e2e-tests/src/tests/oneClient.test.ts index be04721f64..05d22a077f 100644 --- a/packages/e2e-tests/src/tests/oneClient.test.ts +++ b/packages/e2e-tests/src/tests/oneClient.test.ts @@ -73,14 +73,9 @@ describe('One Client', () => { }) it('User sees general channel', async () => { - console.log('User sees general channel - test start') - console.log('PAGE SOURCE', await app.driver.getPageSource()) const generalChannel = new Channel(app.driver, 'general') - console.log('User sees general channel - generalChannel') const isGeneralChannel = await generalChannel.element.isDisplayed() - console.log('User sees general channel - isGeneralChannel', isGeneralChannel) const generalChannelText = await generalChannel.element.getText() - console.log('User sees general channel - generalChannelText', generalChannelText) expect(isGeneralChannel).toBeTruthy() expect(generalChannelText).toEqual('# general') }) diff --git a/packages/state-manager/src/sagas/messages/verifyMessage/verifyMessages.saga.ts b/packages/state-manager/src/sagas/messages/verifyMessage/verifyMessages.saga.ts index 1a8dac2c05..c7b767f028 100644 --- a/packages/state-manager/src/sagas/messages/verifyMessage/verifyMessages.saga.ts +++ b/packages/state-manager/src/sagas/messages/verifyMessage/verifyMessages.saga.ts @@ -22,8 +22,6 @@ export function* verifyMessagesSaga( yield* delay(500) } - console.log('verifyMessagesSaga messages', messages) - for (const message of messages) { let isVerified = Boolean(action.payload.isVerified) @@ -42,8 +40,6 @@ export function* verifyMessagesSaga( const expectedMessage = yield* call(verifyUserInfoMessage, user.username, channel) - console.log('verifyMessagesSaga expectedMessage', expectedMessage) - console.log('verifyMessagesSaga message.message', message.message) if (message.message !== expectedMessage) { console.error(`${user.username} tried to send a malicious info message`) isVerified = false From 11b674b0aa15d33f915582a24e31a9ab8500a4b0 Mon Sep 17 00:00:00 2001 From: Emi Date: Thu, 25 Jan 2024 14:47:00 +0100 Subject: [PATCH 16/17] chore: cleanup --- .github/workflows/e2e-linux.yml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/.github/workflows/e2e-linux.yml b/.github/workflows/e2e-linux.yml index d4ec27d9bf..45dada8bbc 100644 --- a/.github/workflows/e2e-linux.yml +++ b/.github/workflows/e2e-linux.yml @@ -46,19 +46,6 @@ jobs: working-directory: ./packages/e2e-tests/Quiet run: chmod +x $FILE_NAME - - name: Extract version - id: extract_version - uses: Saionaro/extract-package-version@v1.2.1 - with: - path: packages/desktop - - - name: "Upload built app" - uses: actions/upload-artifact@v3 - with: - name: quiet-linux - path: ./packages/desktop/dist/Quiet-${{ steps.extract_version.outputs.version }}.AppImage - retention-days: 2 - - name: Run one client test uses: nick-fields/retry@v2 with: From f358ae74128d59173d6413215a20cee2f5c818ae Mon Sep 17 00:00:00 2001 From: Emi Date: Thu, 25 Jan 2024 15:39:26 +0100 Subject: [PATCH 17/17] fix: killing tor process tests --- packages/backend/src/nest/tor/tor.service.tor.spec.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/backend/src/nest/tor/tor.service.tor.spec.ts b/packages/backend/src/nest/tor/tor.service.tor.spec.ts index eaf6fa88ae..cab5e0d919 100644 --- a/packages/backend/src/nest/tor/tor.service.tor.spec.ts +++ b/packages/backend/src/nest/tor/tor.service.tor.spec.ts @@ -150,19 +150,19 @@ describe('TorControl', () => { expect(status).toBe(false) }) - it('should find hanging tor process and kill it', async () => { + it('should find hanging tor processes and kill them', async () => { const processKill = jest.spyOn(process, 'kill') await torService.init() torService.clearHangingTorProcess() - expect(processKill).toHaveBeenCalledTimes(1) + expect(processKill).toHaveBeenCalledTimes(2) // Spawning with {shell:true} starts 2 processes so we need to kill 2 processes }) - it('should find hanging tor process and kill it if Quiet path includes space', async () => { + it('should find hanging tor processes and kill them if Quiet path includes space', async () => { tmpDir = createTmpDir('quietTest Tmp_') // On MacOS quiet data lands in '(...)/Application Support/(...)' which caused problems with grep tmpAppDataPath = tmpQuietDirPath(tmpDir.name) const processKill = jest.spyOn(process, 'kill') await torService.init() torService.clearHangingTorProcess() - expect(processKill).toHaveBeenCalledTimes(1) + expect(processKill).toHaveBeenCalledTimes(2) // Spawning with {shell:true} starts 2 processes so we need to kill 2 processes }) })