Skip to content

Commit

Permalink
fix: backend unit tests with tor
Browse files Browse the repository at this point in the history
  • Loading branch information
EmiM committed Oct 25, 2023
1 parent 010da05 commit 00fbf5d
Showing 1 changed file with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ import crypto from 'crypto'
import { CustomEvent } from '@libp2p/interfaces/events'
import { jest, beforeEach, describe, it, expect, afterEach } from '@jest/globals'
import { communities, getFactory, identity, prepareStore, Store } from '@quiet/state-manager'
import { createPeerId, createTmpDir, libp2pInstanceParams, removeFilesFromDir, tmpQuietDirPath } from '../common/utils'
import {
createPeerId,
createTmpDir,
generateLibp2pPSK,
libp2pInstanceParams,
removeFilesFromDir,
tmpQuietDirPath,
} from '../common/utils'

import { NetworkStats, type Community, type Identity, type InitCommunityPayload } from '@quiet/types'
import { LazyModuleLoader } from '@nestjs/core'
Expand Down Expand Up @@ -87,8 +94,6 @@ beforeEach(async () => {
localDbService = await module.resolve(LocalDbService)
registrationService = await module.resolve(RegistrationService)
tor = await module.resolve(Tor)

console.log('tor ', tor)
await tor.init()

const torPassword = crypto.randomBytes(16).toString('hex')
Expand All @@ -106,6 +111,11 @@ beforeEach(async () => {
connectionsManagerService.libp2pService = libp2pService

quietDir = await module.resolve(QUIET_DIR)

const libp2pPSK = new Uint8Array(95)
const psk = generateLibp2pPSK(libp2pPSK)
const pskBase64 = psk.toString('base64')
await localDbService.put(LocalDBKeys.PSK, pskBase64)
})

afterEach(async () => {
Expand All @@ -117,11 +127,6 @@ afterEach(async () => {
})

describe('Connections manager', () => {
it('runs tor by default', async () => {
await connectionsManagerService.init()
console.log(connectionsManagerService.isTorInit)
})

it('saves peer stats when peer has been disconnected', async () => {
class RemotePeerEventDetail {
peerId: string
Expand All @@ -135,7 +140,6 @@ describe('Connections manager', () => {
}
}
const emitSpy = jest.spyOn(libp2pService, 'emit')
// const emitSpy = jest.spyOn(libp2pService, 'emit')

const launchCommunityPayload: InitCommunityPayload = {
id: community.id,
Expand Down

0 comments on commit 00fbf5d

Please sign in to comment.