Fix proxy test waiting condition (#250)

* Fix proxy test waiting condition

* update test command

* Update proxy.js

* Update proxy.js

* Update proxy.js
This commit is contained in:
extremeheat 2022-08-10 13:29:46 -04:00 committed by GitHub
commit d1ba619788
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 9 deletions

View file

@ -5,7 +5,7 @@
"main": "index.js",
"scripts": {
"build": "cd tools && node compileProtocol.js",
"test": "mocha --bail",
"test": "mocha --bail --exit",
"pretest": "npm run lint",
"lint": "standard",
"vanillaServer": "node tools/startVanillaServer.js",

View file

@ -1,18 +1,19 @@
const { createClient, createServer, Relay } = require('bedrock-protocol')
const { createClient, Server, Relay } = require('bedrock-protocol')
const { sleep, waitFor } = require('../src/datatypes/util')
function proxyTest (version, raknetBackend = 'raknet-node', timeout = 1000 * 40) {
console.log('with raknet backend', raknetBackend)
return waitFor(res => {
return waitFor(async res => {
const SERVER_PORT = 19000 + ((Math.random() * 100) | 0)
const CLIENT_PORT = 19000 + ((Math.random() * 100) | 0)
const server = createServer({
const server = new Server({
host: '0.0.0.0', // optional
port: SERVER_PORT, // optional
offline: true,
raknetBackend,
version // The server version
})
await server.listen()
server.on('connect', client => {
console.debug('Client has connected')
@ -40,16 +41,14 @@ function proxyTest (version, raknetBackend = 'raknet-node', timeout = 1000 * 40)
raknetBackend
})
relay.conLog = console.debug
relay.listen()
await relay.listen()
console.debug('Proxy started', server.options.version)
const client = createClient({ host: '127.0.0.1', port: CLIENT_PORT, version, username: 'Boat', offline: true, raknetBackend })
const client = createClient({ host: '127.0.0.1', port: CLIENT_PORT, version, username: 'Boat', offline: true, raknetBackend, skipPing: true })
console.debug('Client started')
client.on('error', console.log)
client.on('packet', console.log)
client.on('disconnect', packet => {
console.assert(packet.message === 'Hello world !')