Skip to content

Commit

Permalink
Merge branch 'develop' into feature/delete-channel
Browse files Browse the repository at this point in the history
  • Loading branch information
siepra committed Apr 24, 2023
2 parents c4be0cf + 3df61b6 commit da372dd
Show file tree
Hide file tree
Showing 142 changed files with 10,079 additions and 6,204 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = {
'no-eval': 'off',
'no-void': 'off',
'no-unused-vars': 'off',
'no-irregular-whitespace': 'off',
'array-callback-return': 'off',
'comma-dangle': 'off',
'@typescript-eslint/naming-convention': 'off',
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/e2e-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,16 @@ jobs:
max_attempts: 3
command: cd packages/e2e-tests && npm run test newUser.crossplatform.test.ts

- name: Run invitation link test - Includes 2 separate application clients
uses: nick-fields/retry@v2
with:
timeout_minutes: 35
max_attempts: 3
command: cd packages/e2e-tests && npm run test invitationLink.crossplatform.test.ts

- name: Run leave community test
uses: nick-fields/retry@v2
with:
timeout_minutes: 40
max_attempts: 3
command: cd packages/e2e-tests && npm run test leaveCommunity.crossplatform.test.ts
command: cd packages/e2e-tests && npm run test leaveCommunity.crossplatform.test.ts
9 changes: 8 additions & 1 deletion .github/workflows/e2e-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,17 @@ jobs:
timeout_minutes: 35
max_attempts: 3
command: cd packages/e2e-tests && npm run test newUser.crossplatform.test.ts

- name: Run invitation link test - Includes 2 separate application clients
uses: nick-fields/retry@v2
with:
timeout_minutes: 35
max_attempts: 3
command: cd packages/e2e-tests && npm run test invitationLink.crossplatform.test.ts

- name: Run leave community test
uses: nick-fields/retry@v2
with:
timeout_minutes: 40
max_attempts: 3
command: cd packages/e2e-tests && npm run test leaveCommunity.crossplatform.test.ts
command: cd packages/e2e-tests && npm run test leaveCommunity.crossplatform.test.ts
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Encrypted p2p team chat with no servers, just Tor.
<br />
<!-- <a href="https://tryquiet.org"><strong>tryquiet.org »</strong></a> -->
<a href="https://github.com/TryQuiet/quiet/releases/tag/quiet%400.16.0"><strong>Downloads</strong></a> |
<a href="https://github.com/TryQuiet/quiet/releases/tag/quiet%401.2.0"><strong>Downloads</strong></a> |
<a href="#how-it-works"><strong>How it Works</strong></a> |
<a href="#features"><strong>Features</strong></a> |
<a href="https://github.com/TryQuiet/monorepo/wiki/Threat-Model"><strong>Threat Model</strong></a> |
Expand Down Expand Up @@ -52,7 +52,7 @@ See our [FAQ](https://github.com/TryQuiet/monorepo/wiki/Quiet-FAQ) for answers t

## Getting started

To try Quiet, download the [latest release](https://github.com/TryQuiet/quiet/releases/tag/quiet%401.0.0) for your platform (.dmg for macOS, .exe for Windows, etc.) and install it in the normal way. Then create a community and open the community's settings to invite members.
To try Quiet, download the [latest release](https://github.com/TryQuiet/quiet/releases/tag/quiet%401.2.0) for your platform (.dmg for macOS, .exe for Windows, etc.) and install it in the normal way. Then create a community and open the community's settings to invite members.

If you'd like to help develop Quiet, see [Contributing to Quiet](#contributing-to-quiet).

Expand Down Expand Up @@ -134,4 +134,4 @@ Join us, and let's figure this out.

Even though Quiet is completely peer-to-peer, it is mostly written in TypeScript and will be familiar to anyone accustomed to Node.js web development. Desktop and mobile versions share a common Node.js [backend](https://github.com/TryQuiet/monorepo/tree/master/packages/backend) and React [state manager](https://github.com/TryQuiet/monorepo/tree/master/packages/state-manager), with [Tor](https://torproject.org) binaries for each platform and architecture, using Electron and React Native and for their respective frontends.

To get started hacking on Quiet, follow the instructions for [Quiet Desktop](https://github.com/TryQuiet/monorepo/tree/master/packages/desktop#readme) or [Quiet Mobile](https://github.com/TryQuiet/monorepo/tree/master/packages/mobile#readme). (If you're new to the project, start with Quiet Desktop, as it's more stable and vastly easier to start hacking on.) Here are some [good first issues](https://github.com/TryQuiet/quiet/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22), and you can see upcoming priorities in our [project board](https://github.com/orgs/TryQuiet/projects/1).
To get started hacking on Quiet, follow the instructions for [Quiet Desktop](https://github.com/TryQuiet/monorepo/tree/master/packages/desktop#readme) or [Quiet Mobile](https://github.com/TryQuiet/monorepo/tree/master/packages/mobile#readme). (If you're new to the project, start with Quiet Desktop, as it's more stable and vastly easier to start hacking on.) Here are some [good first issues](https://github.com/orgs/TryQuiet/projects/3/views/1?filterQuery=label%3A%22good+first+issue%22), and you can see upcoming priorities in our [project board](https://github.com/orgs/TryQuiet/projects/3/views/1).
56 changes: 56 additions & 0 deletions packages/backend/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,62 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [1.2.0](https://github.com/TryQuiet/backend/compare/@quiet/[email protected]...@quiet/[email protected]) (2023-04-18)

**Note:** Version bump only for package @quiet/backend





# [1.2.0-alpha.27](https://github.com/TryQuiet/backend/compare/@quiet/[email protected]...@quiet/[email protected]) (2023-04-18)

**Note:** Version bump only for package @quiet/backend





# [1.2.0-alpha.26](https://github.com/TryQuiet/backend/compare/@quiet/[email protected]...@quiet/[email protected]) (2023-04-17)

**Note:** Version bump only for package @quiet/backend





# [1.2.0-alpha.25](https://github.com/TryQuiet/backend/compare/@quiet/[email protected]...@quiet/[email protected]) (2023-04-14)

**Note:** Version bump only for package @quiet/backend





# [1.2.0-alpha.24](https://github.com/TryQuiet/backend/compare/@quiet/[email protected]...@quiet/[email protected]) (2023-04-14)

**Note:** Version bump only for package @quiet/backend





# [1.2.0-alpha.23](https://github.com/TryQuiet/backend/compare/@quiet/[email protected]...@quiet/[email protected]) (2023-04-13)

**Note:** Version bump only for package @quiet/backend





# [1.2.0-alpha.22](https://github.com/TryQuiet/backend/compare/@quiet/[email protected]...@quiet/[email protected]) (2023-04-12)

**Note:** Version bump only for package @quiet/backend





# [1.2.0-alpha.21](https://github.com/TryQuiet/backend/compare/@quiet/[email protected]...@quiet/[email protected]) (2023-04-07)

**Note:** Version bump only for package @quiet/backend
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions packages/backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@quiet/backend",
"version": "1.2.0-alpha.21",
"version": "1.2.0",
"description": "tlg-manager",
"types": "lib/index.d.ts",
"type": "module",
Expand All @@ -18,7 +18,7 @@
"lint-ci": "eslint --ext .jsx,.js,.ts,.tsx ./src/",
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules DEBUG=ipfs:*,backend:* node_modules/jest/bin/jest.js ./src/**/* --runInBand --verbose --testPathIgnorePatterns=\".src/(!?nodeTest*)|(.node_modules*)\"",
"test-ci": "cross-env NODE_OPTIONS=--experimental-vm-modules jest ./src/**/* --runInBand --colors --ci --silent --verbose --testPathIgnorePatterns=\".src/(!?nodeTest*)|(.node_modules*)|src/.*\\.tor.test\\.(t|j)s|src/storage/storageLargeFiles.test.ts$\"",
"test-ci-tor": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --runInBand --colors --ci --silent --verbose --testPathPattern=\"src/.*\\.tor.test\\.(t|j)s$\"",
"test-ci-tor": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --runInBand --colors --ci --silent --verbose --detectOpenHandles --forceExit --testPathPattern=\"src/.*\\.tor.test\\.(t|j)s$\"",
"test-ci-long-running": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --colors --ci --silent --verbose src/storage/storageLargeFiles.test.ts",
"test-connect": "cross-env NODE_OPTIONS=--experimental-vm-modules DEBUG='libp2p:websockets*' jest ./src/nodeTest/* --verbose",
"test-connect-ci": "cross-env NODE_OPTIONS=--experimental-vm-modules jest ./src/nodeTest/* --colors --ci --silent --verbose",
Expand Down Expand Up @@ -83,9 +83,9 @@
"@chainsafe/libp2p-gossipsub": "6.1.0",
"@chainsafe/libp2p-noise": "11.0.0",
"@peculiar/webcrypto": "1.2.2",
"@quiet/identity": "^1.2.0-alpha.20",
"@quiet/logger": "^1.2.0-alpha.20",
"@quiet/state-manager": "^1.2.0-alpha.21",
"@quiet/identity": "^1.2.0",
"@quiet/logger": "^1.2.0",
"@quiet/state-manager": "^1.2.0",
"abortable-iterator": "^3.0.0",
"class-validator": "^0.13.1",
"cli-table": "^0.3.6",
Expand Down
70 changes: 68 additions & 2 deletions packages/backend/src/libp2p/connectionsManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ describe('Connections manager - no tor', () => {
lastSeen: peerStats[remoteAddr].lastSeen
})
})

it('community is only launched once', async () => {
// At this moment, that test have to be skipped, because checking statues is called before launchCommunity method
it.skip('community is only launched once', async () => {
connectionsManager = new ConnectionsManager({
socketIOPort: 1234,
torControlPort: 4321,
Expand Down Expand Up @@ -339,4 +339,70 @@ describe('Connections manager - no tor', () => {

expect(launchSpy).toBeCalledTimes(1)
})

it('Bug reproduction - Error on startup - Error: TOR: Connection already established - Trigger launchCommunity and launchRegistrar from backend and state manager', async () => {
connectionsManager = new ConnectionsManager({
socketIOPort: 1234,
torControlPort: 4321,
options: {
env: {
appDataPath: tmpAppDataPath
},
}
})

const launchCommunityPayload: InitCommunityPayload = {
id: community.id,
peerId: userIdentity.peerId,
hiddenService: userIdentity.hiddenService,
certs: {
certificate: userIdentity.userCertificate,
key: userIdentity.userCsr.userKey,
CA: [community.rootCa]
},
peers: community.peerList
}

const launchRegistrarPayload: LaunchRegistrarPayload = {
id: community.id,
peerId: userIdentity.peerId.id,
rootCertString: community.CA.rootCertString,
rootKeyString: community.CA.rootKeyString,
privateKey: undefined
}

await connectionsManager.init()
await connectionsManager.localStorage.put(LocalDBKeys.COMMUNITY, launchCommunityPayload)
await connectionsManager.localStorage.put(LocalDBKeys.REGISTRAR, launchRegistrarPayload)

const peerAddress = '/dns4/test.onion/tcp/443/wss/p2p/peerid'
await connectionsManager.localStorage.put(LocalDBKeys.PEERS, {
[peerAddress]: {
peerId: 'QmaEvCkpUG7GxhgvMkk8wxurfi1ehjHhSUNRksWTmXN2ix',
connectionTime: 50,
lastSeen: 1000
}
})

await connectionsManager.closeAllServices()

const launchCommunitySpy = jest.spyOn(connectionsManager, 'launchCommunity').mockResolvedValue()
const launchRegistrarSpy = jest.spyOn(connectionsManager.registration, 'launchRegistrar').mockResolvedValue()

const url = `http://localhost:${1234}`
const socket = io(url)

const init = new Promise<void>(resolve => {
void connectionsManager.init()
socket.connect()
setTimeout(() => resolve(), 200)
})

await init

expect(launchCommunitySpy).toBeCalledTimes(1)
expect(launchRegistrarSpy).toBeCalledTimes(1)

socket.close()
})
})
76 changes: 73 additions & 3 deletions packages/backend/src/libp2p/connectionsManager.tor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { jest, beforeEach, describe, it, expect, afterEach } from '@jest/globals
import { communities, getFactory, identity, InitCommunityPayload, prepareStore } from '@quiet/state-manager'
import { createLibp2pAddress } from '../common/utils'
import { WebSockets } from './websocketOverTor'
import { initConnectionsManagerWithTor } from './utils'

const { getPorts } = await import('../common/utils')

Expand Down Expand Up @@ -41,8 +42,10 @@ describe('Connections manager', () => {
},
}
})
await connectionsManager.init()

const socket = await initConnectionsManagerWithTor(connectionsManager, ports.socksPort)
expect(connectionsManager.tor.process).not.toBeNull()
socket.close()
})

it('creates network', async () => {
Expand All @@ -57,14 +60,15 @@ describe('Connections manager', () => {
},
}
})
await connectionsManager.init()
const socket = await initConnectionsManagerWithTor(connectionsManager, ports.socksPort)
const spyOnDestroyHiddenService = jest.spyOn(connectionsManager.tor, 'destroyHiddenService')
const network = await connectionsManager.getNetwork()
expect(network.hiddenService.onionAddress.split('.')[0]).toHaveLength(56)
expect(network.hiddenService.privateKey).toHaveLength(99)
const peerId = await PeerId.createFromJSON(network.peerId)
expect(PeerId.isPeerId(peerId)).toBeTruthy()
expect(await spyOnDestroyHiddenService.mock.results[0].value).toBeTruthy()
socket.close()
})

it('dials many peers on start', async () => {
Expand All @@ -86,7 +90,7 @@ describe('Connections manager', () => {
},
}
})
await connectionsManager.init()
const socket = await initConnectionsManagerWithTor(connectionsManager, ports.socksPort)
const spyOnDial = jest.spyOn(WebSockets.prototype, 'dial')

const peerList = []
Expand All @@ -109,5 +113,71 @@ describe('Connections manager', () => {

await connectionsManager.launchCommunity(launchCommunityPayload)
expect(spyOnDial).toHaveBeenCalledTimes(peersCount)
socket.close()
})

it('Bug reproduction - iOS app crashing because lack of data server', async () => {
const store = prepareStore().store
const factory = await getFactory(store)
const community = await factory.create<ReturnType<typeof communities.actions.addNewCommunity>['payload']>('Community')
const userIdentity = await factory.create<ReturnType<typeof identity.actions.addNewIdentity>['payload']>(
'Identity', { id: community.id, nickname: 'john' }
)
const ports = await getPorts()

connectionsManager = new ConnectionsManager({
torBinaryPath: '../../3rd-party/tor/linux/tor',
torResourcesPath: '../../3rd-party/tor/linux',
socketIOPort: ports.socksPort,
options: {
env: {
appDataPath: tmpAppDataPath
},
}
})
const socket = await initConnectionsManagerWithTor(connectionsManager, ports.socksPort)
const spyOnDial = jest.spyOn(WebSockets.prototype, 'dial')

const peerList = []
const peersCount = 11
for (let pCount = 0; pCount < peersCount; pCount++) {
peerList.push(createLibp2pAddress(`${Math.random().toString(36).substring(2, 13)}.onion`, (await createPeerId()).toString()))
}

const launchCommunityPayload: InitCommunityPayload = {
id: community.id,
peerId: userIdentity.peerId,
hiddenService: userIdentity.hiddenService,
certs: {
certificate: userIdentity.userCertificate,
key: userIdentity.userCsr.userKey,
CA: [community.rootCa]
},
peers: peerList
}

await connectionsManager.launchCommunity(launchCommunityPayload)
expect(spyOnDial).toHaveBeenCalledTimes(peersCount)
await connectionsManager.closeAllServices()
socket.close()
connectionsManager = null

// IOS

const connectionsManager2 = new ConnectionsManager({
torControlPort: 4321,
torBinaryPath: '../../3rd-party/tor/linux/tor',
torResourcesPath: '../../3rd-party/tor/linux',
socketIOPort: ports.socksPort,
options: {
env: {
appDataPath: tmpAppDataPath
},
}
})
const launchSpy = jest.spyOn(connectionsManager2, 'launch').mockResolvedValue('address')
await connectionsManager2.init()
expect(launchSpy).toBeCalledTimes(1)
await connectionsManager2.closeAllServices()
})
})
Loading

0 comments on commit da372dd

Please sign in to comment.