mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-23 11:31:57 +03:00
update
Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
parent
48e1f6fcc5
commit
4f84876c1e
58
server/ws/src/__tests__/remote.test.ts
Normal file
58
server/ws/src/__tests__/remote.test.ts
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
//
|
||||||
|
// Copyright © 2020, 2021 Anticrm Platform Contributors.
|
||||||
|
// Copyright © 2021 Hardcore Engineering Inc.
|
||||||
|
//
|
||||||
|
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License. You may
|
||||||
|
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
//
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
//
|
||||||
|
|
||||||
|
import { readResponse, serialize } from '@anticrm/platform'
|
||||||
|
import { _Token } from '../server'
|
||||||
|
import { encode } from 'jwt-simple'
|
||||||
|
import WebSocket from 'ws'
|
||||||
|
|
||||||
|
describe('server', () => {
|
||||||
|
function connect (): WebSocket {
|
||||||
|
const payload: _Token = {
|
||||||
|
workspace: 'latest'
|
||||||
|
}
|
||||||
|
const token = encode(payload, 'secret')
|
||||||
|
return new WebSocket('wss://pacific-refuge-43514.herokuapp.com/' + token)
|
||||||
|
}
|
||||||
|
|
||||||
|
it('should connect to server', (done) => {
|
||||||
|
const conn = connect()
|
||||||
|
conn.on('open', () => {
|
||||||
|
conn.close()
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should send many requests', (done) => {
|
||||||
|
const conn = connect()
|
||||||
|
const total = 10
|
||||||
|
// const start = Date.now()
|
||||||
|
conn.on('open', () => {
|
||||||
|
for (let i = 0; i < total; i++) {
|
||||||
|
conn.send(serialize({ method: 'findAll', params: ['core:class:Class', {}], id: i }))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
let received = 0
|
||||||
|
conn.on('message', (msg: string) => {
|
||||||
|
readResponse(msg)
|
||||||
|
if (++received === total) {
|
||||||
|
// console.log('resp:', resp, ' Time: ', Date.now() - start)
|
||||||
|
conn.close()
|
||||||
|
done()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
Loading…
Reference in New Issue
Block a user