-
-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve CI setup for per version tests (#1267)
* Improve CI setup: move lint out of per version * fix * Simplify go back to all per version. * refactor cycle test to use supported versions * fix cycle packet test * Add v to version to avoid 1.19 running every 1.19 minor. * Add quotes. * Use versions from js file in ci.yml * Fix ci.yml syntax. * Fix matrix read. * fix * fix * fix gitignore
- Loading branch information
Showing
9 changed files
with
89 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
node_modules | ||
test/npm-debug.log | ||
test/server* | ||
test/server_* | ||
package-lock.json | ||
versions/ | ||
src/client/*.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* eslint-env mocha */ | ||
// Tests packet serialization/deserialization from with raw binary from minecraft-packets | ||
const { createSerializer, createDeserializer, states, supportedVersions } = require('minecraft-protocol') | ||
const mcPackets = require('minecraft-packets') | ||
const assert = require('assert') | ||
|
||
const makeClientSerializer = version => createSerializer({ state: states.PLAY, version, isServer: true }) | ||
const makeClientDeserializer = version => createDeserializer({ state: states.PLAY, version }) | ||
|
||
for (const supportedVersion of supportedVersions) { | ||
let serializer, deserializer, data | ||
const mcData = require('minecraft-data')(supportedVersion) | ||
const version = mcData.version | ||
|
||
function convertBufferToObject (buffer) { | ||
return deserializer.parsePacketBuffer(buffer) | ||
} | ||
|
||
function convertObjectToBuffer (object) { | ||
return serializer.createPacketBuffer(object) | ||
} | ||
|
||
function testBuffer (buffer, [packetName, packetIx]) { | ||
const parsed = convertBufferToObject(buffer).data | ||
const parsedBuffer = convertObjectToBuffer(parsed) | ||
const areEq = buffer.equals(parsedBuffer) | ||
assert.strictEqual(areEq, true, `Error when testing ${+packetIx + 1} ${packetName} packet`) | ||
} | ||
describe(`Test cycle packet for version ${supportedVersion}v`, () => { | ||
before(() => { | ||
serializer = makeClientSerializer(version.minecraftVersion) | ||
deserializer = makeClientDeserializer(version.minecraftVersion) | ||
}) | ||
data = mcPackets.pc[version.minecraftVersion] | ||
it('Has packet data', () => { | ||
if (data === undefined) { | ||
// many version do not have data, so print a log for now | ||
// assert when most versions have packet data | ||
console.log(`Version ${version.minecraftVersion} has no packet dump.`) | ||
} | ||
}) | ||
// server -> client | ||
if (data !== undefined) { | ||
Object.entries(data['from-server']).forEach(([packetName, packetData]) => { | ||
it(`${packetName} packet`, () => { | ||
for (const i in packetData) { | ||
testBuffer(packetData[i].raw, [packetName, i]) | ||
} | ||
}) | ||
}) | ||
} | ||
}) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters