Skip to content

Commit 843a37c

Browse files
committed
add e2e test
1 parent f1deccb commit 843a37c

File tree

16 files changed

+424
-117
lines changed

16 files changed

+424
-117
lines changed

packages/backend/src/nest/common/timed-queue.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export class TimedQueue {
6969
* Start processing the queue
7070
*/
7171
public start(): void {
72-
this.logger.info(`Starting timed queue`)
72+
this.logger.debug(`Starting timed queue`)
7373
if (!this.queue.running()) {
7474
this.queue.resume()
7575
}
@@ -81,14 +81,14 @@ export class TimedQueue {
8181
* @param cancelTasks If true cancel all in-progress tasks
8282
*/
8383
public stop(cancelTasks = false): void {
84-
this.logger.info(`Stopping timed queue`)
84+
this.logger.debug(`Stopping timed queue`)
8585
if (this.queue.running()) {
8686
this.queue.pause()
8787
this.queue.empty()
8888
}
8989

9090
if (cancelTasks) {
91-
this.logger.info(`Stopping current tasks in timed queue`)
91+
this.logger.debug(`Stopping current tasks in timed queue`)
9292
this.inProcess.forEach(async (task: NodeJS.Timeout | number) => {
9393
clearTimeout(task)
9494
})

packages/backend/src/nest/connections-manager/connections-manager.service.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ import {
5252
SetUserProfileResponse,
5353
} from '@quiet/types'
5454
import { CONFIG_OPTIONS, QSS_ALLOWED, QSS_ENDPOINT, SERVER_IO_PROVIDER, SOCKS_PROXY_AGENT } from '../const'
55-
import { Libp2pService } from '../libp2p/libp2p.service'
55+
import { Libp2pService, Libp2pState } from '../libp2p/libp2p.service'
5656
import { CreatedLibp2pPeerId, Libp2pEvents, Libp2pNodeParams, Libp2pPeerInfo } from '../libp2p/libp2p.types'
5757
import { LocalDbService } from '../local-db/local-db.service'
5858
import { LocalDBKeys } from '../local-db/local-db.types'
@@ -250,8 +250,7 @@ export class ConnectionsManagerService extends EventEmitter implements OnModuleI
250250
this.logger.info('Pausing!')
251251
await this.closeSocket()
252252
this.logger.info('Pausing libp2pService!')
253-
this.peerInfo = await this.libp2pService?.pause()
254-
this.logger.info('Found the following peer info on pause: ', this.peerInfo)
253+
await this.libp2pService?.pause()
255254
}
256255

257256
public async resume() {
@@ -794,6 +793,26 @@ export class ConnectionsManagerService extends EventEmitter implements OnModuleI
794793
callback(await this.storageService?.addUserProfile(payload.profile))
795794
}
796795
)
796+
797+
this.socketService.on(SocketActions.TOGGLE_P2P, async (payload: boolean, callback: (response: boolean) => void) => {
798+
try {
799+
if (payload) {
800+
await this.libp2pService.resume()
801+
await this.storageService.startSync()
802+
} else {
803+
await this.libp2pService.pause()
804+
await this.storageService.stopSync()
805+
}
806+
} catch (e) {
807+
this.logger.error('Error toggling libp2p service', e)
808+
}
809+
810+
if (this.libp2pService.state === Libp2pState.Started) {
811+
callback(true)
812+
} else {
813+
callback(false)
814+
}
815+
})
797816
}
798817

799818
/**

0 commit comments

Comments
 (0)