Fix port collision caused by race condition in tests (#164)

* Fix port collision caused by race condition in tests

The ipv6 port is not randomized, if the previous ports for the last test didn't get freed in time, the server can crash on launch

* try again

* Update index.d.ts

* Update genPacketDumps.js
This commit is contained in:
extremeheat 2021-12-15 23:55:32 -05:00 committed by GitHub
commit bb2179a8cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

2
index.d.ts vendored
View file

@ -24,6 +24,8 @@ declare module "bedrock-protocol" {
}
export interface ClientOptions extends Options {
// The username to connect to the server as
username: string,
// The view distance in chunks
viewDistance?: number,
// Specifies which game edition to sign in as. Optional, but some servers verify this.

View file

@ -18,11 +18,11 @@ function hasDumps (version) {
let loop
async function dump (version, force = true) {
const random = ((Math.random() * 100) | 0)
const port = 19130 + random
const random = (Math.random() * 1000) | 0
const [port, v6] = [19132 + random, 19133 + random]
console.log('Starting dump server', version)
const handle = await vanillaServer.startServerAndWait(version || CURRENT_VERSION, 1000 * 120, { 'server-port': port })
const handle = await vanillaServer.startServerAndWait(version || CURRENT_VERSION, 1000 * 120, { 'server-port': port, 'server-portv6': v6 })
console.log('Started dump server', version)
const client = new Client({